Skip to content

Commit

Permalink
Show radio instead of Youtube logo in mixes
Browse files Browse the repository at this point in the history
YouTube mixes have YouTube as a creator, though YouTube's logo is not safe to use as it is a trademark (better safe than sorry)
  • Loading branch information
Stypox committed Apr 10, 2020
1 parent d60c8c1 commit 1a278bf
Showing 1 changed file with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
Expand All @@ -27,7 +26,6 @@
import org.schabi.newpipe.extractor.ListExtractor;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
import org.schabi.newpipe.extractor.playlist.PlaylistInfo;
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import org.schabi.newpipe.extractor.stream.StreamType;
Expand All @@ -50,6 +48,7 @@
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;

import de.hdodenhof.circleimageview.CircleImageView;
import io.reactivex.Flowable;
import io.reactivex.Single;
import io.reactivex.android.schedulers.AndroidSchedulers;
Expand All @@ -74,7 +73,7 @@ public class PlaylistFragment extends BaseListInfoFragment<PlaylistInfo> {
private TextView headerTitleView;
private View headerUploaderLayout;
private TextView headerUploaderName;
private ImageView headerUploaderAvatar;
private CircleImageView headerUploaderAvatar;
private TextView headerStreamCount;
private View playlistCtrl;

Expand Down Expand Up @@ -302,8 +301,19 @@ public void handleResult(@NonNull final PlaylistInfo result) {

playlistCtrl.setVisibility(View.VISIBLE);

IMAGE_LOADER.displayImage(result.getUploaderAvatarUrl(), headerUploaderAvatar,
ImageDisplayConstants.DISPLAY_AVATAR_OPTIONS);
String avatarUrl = result.getUploaderAvatarUrl();
if (avatarUrl.contains("upload.wikimedia.org")) {
// this is an auto-generated playlist (e.g. Youtube mixes) with an avatar
// that could be a trademark and thus not be safe to use
headerUploaderAvatar.setImageResource(
ThemeHelper.resolveResourceIdFromAttr(requireContext(), R.attr.ic_radio));
headerUploaderAvatar.setBorderColor(
getResources().getColor(R.color.transparent_background_color));
} else {
IMAGE_LOADER.displayImage(avatarUrl, headerUploaderAvatar,
ImageDisplayConstants.DISPLAY_AVATAR_OPTIONS);
}

headerStreamCount.setText(Localization
.localizeStreamCount(getContext(), result.getStreamCount()));

Expand Down

0 comments on commit 1a278bf

Please sign in to comment.