Skip to content

Commit c289550

Browse files
committed
Show radio instead of Youtube logo in mixes
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)
1 parent 079b98e commit c289550

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

app/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ dependencies {
149149
exclude module: 'support-annotations'
150150
})
151151

152-
implementation 'com.github.TeamNewPipe:NewPipeExtractor:f3913e241e379adf0091319091e8f895c5fcfd07'
152+
implementation 'com.github.XiangRongLin:NewPipeExtractor:5c87409b254e6707563557b7ebe7716c810b5382'
153153
testImplementation 'junit:junit:4.12'
154154
testImplementation 'org.mockito:mockito-core:2.23.0'
155155

app/src/main/java/org/schabi/newpipe/fragments/list/playlist/PlaylistFragment.java

+19-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import android.view.MenuItem;
1212
import android.view.View;
1313
import android.view.ViewGroup;
14-
import android.widget.ImageView;
1514
import android.widget.TextView;
1615

1716
import androidx.annotation.NonNull;
@@ -26,8 +25,10 @@
2625
import org.schabi.newpipe.extractor.InfoItem;
2726
import org.schabi.newpipe.extractor.ListExtractor;
2827
import org.schabi.newpipe.extractor.NewPipe;
28+
import org.schabi.newpipe.extractor.ServiceList;
2929
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
3030
import org.schabi.newpipe.extractor.playlist.PlaylistInfo;
31+
import org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper;
3132
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
3233
import org.schabi.newpipe.extractor.stream.StreamType;
3334
import org.schabi.newpipe.fragments.list.BaseListInfoFragment;
@@ -49,6 +50,7 @@
4950
import java.util.List;
5051
import java.util.concurrent.atomic.AtomicBoolean;
5152

53+
import de.hdodenhof.circleimageview.CircleImageView;
5254
import io.reactivex.Flowable;
5355
import io.reactivex.Single;
5456
import io.reactivex.android.schedulers.AndroidSchedulers;
@@ -73,7 +75,7 @@ public class PlaylistFragment extends BaseListInfoFragment<PlaylistInfo> {
7375
private TextView headerTitleView;
7476
private View headerUploaderLayout;
7577
private TextView headerUploaderName;
76-
private ImageView headerUploaderAvatar;
78+
private CircleImageView headerUploaderAvatar;
7779
private TextView headerStreamCount;
7880
private View playlistCtrl;
7981

@@ -301,8 +303,21 @@ public void handleResult(@NonNull final PlaylistInfo result) {
301303

302304
playlistCtrl.setVisibility(View.VISIBLE);
303305

304-
IMAGE_LOADER.displayImage(result.getUploaderAvatarUrl(), headerUploaderAvatar,
305-
ImageDisplayConstants.DISPLAY_AVATAR_OPTIONS);
306+
String avatarUrl = result.getUploaderAvatarUrl();
307+
if (result.getServiceId() == ServiceList.YouTube.getServiceId()
308+
&& (YoutubeParsingHelper.isYoutubeMixId(result.getId())
309+
|| YoutubeParsingHelper.isYoutubeMusicMixId(result.getId()))) {
310+
// this is an auto-generated playlist (e.g. Youtube mix), so a radio is shown
311+
headerUploaderAvatar.setImageResource(
312+
ThemeHelper.resolveResourceIdFromAttr(requireContext(), R.attr.ic_radio));
313+
headerUploaderAvatar.setBorderColor(
314+
getResources().getColor(R.color.transparent_background_color));
315+
316+
} else {
317+
IMAGE_LOADER.displayImage(avatarUrl, headerUploaderAvatar,
318+
ImageDisplayConstants.DISPLAY_AVATAR_OPTIONS);
319+
}
320+
306321
headerStreamCount.setText(Localization
307322
.localizeStreamCount(getContext(), result.getStreamCount()));
308323

0 commit comments

Comments
 (0)