1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-23 00:20:32 +00:00

Improve placeholder channel banner handling

Now the placeholder gets hidden if there is no banner url or the user disabled images, to save space
This commit is contained in:
Stypox 2023-04-21 17:05:28 +02:00
parent 1061bce4f3
commit c48e702a50
No known key found for this signature in database
GPG Key ID: 4BDF1B40A49FDD23
3 changed files with 18 additions and 11 deletions

View File

@ -1,5 +1,6 @@
package org.schabi.newpipe.fragments.list.channel; package org.schabi.newpipe.fragments.list.channel;
import static org.schabi.newpipe.extractor.utils.Utils.isBlank;
import static org.schabi.newpipe.ktx.TextViewUtils.animateTextColor; import static org.schabi.newpipe.ktx.TextViewUtils.animateTextColor;
import static org.schabi.newpipe.ktx.ViewUtils.animate; import static org.schabi.newpipe.ktx.ViewUtils.animate;
import static org.schabi.newpipe.ktx.ViewUtils.animateBackgroundColor; import static org.schabi.newpipe.ktx.ViewUtils.animateBackgroundColor;
@ -146,6 +147,10 @@ public class ChannelFragment extends BaseStateFragment<ChannelInfo>
binding.tabLayout.setupWithViewPager(binding.viewPager); binding.tabLayout.setupWithViewPager(binding.viewPager);
binding.channelTitleView.setText(name); binding.channelTitleView.setText(name);
if (!PicassoHelper.getShouldLoadImages()) {
// do not waste space for the banner if it is not going to be loaded
binding.channelBannerImage.setImageDrawable(null);
}
} }
@Override @Override
@ -575,9 +580,14 @@ public class ChannelFragment extends BaseStateFragment<ChannelInfo>
currentInfo = result; currentInfo = result;
setInitialData(result.getServiceId(), result.getOriginalUrl(), result.getName()); setInitialData(result.getServiceId(), result.getOriginalUrl(), result.getName());
binding.getRoot().setVisibility(View.VISIBLE); if (PicassoHelper.getShouldLoadImages() && !isBlank(result.getBannerUrl())) {
PicassoHelper.loadBanner(result.getBannerUrl()).tag(PICASSO_CHANNEL_TAG) PicassoHelper.loadBanner(result.getBannerUrl()).tag(PICASSO_CHANNEL_TAG)
.into(binding.channelBannerImage); .into(binding.channelBannerImage);
} else {
// do not waste space for the banner, if the user disabled images or there is not one
binding.channelBannerImage.setImageDrawable(null);
}
PicassoHelper.loadAvatar(result.getAvatarUrl()).tag(PICASSO_CHANNEL_TAG) PicassoHelper.loadAvatar(result.getAvatarUrl()).tag(PICASSO_CHANNEL_TAG)
.into(binding.channelAvatarView); .into(binding.channelAvatarView);
PicassoHelper.loadAvatar(result.getParentChannelAvatarUrl()).tag(PICASSO_CHANNEL_TAG) PicassoHelper.loadAvatar(result.getParentChannelAvatarUrl()).tag(PICASSO_CHANNEL_TAG)

View File

@ -109,11 +109,7 @@ public final class PicassoHelper {
} }
public static RequestCreator loadBanner(final String url) { public static RequestCreator loadBanner(final String url) {
if (!shouldLoadImages || isBlank(url)) { return loadImageDefault(url, R.drawable.placeholder_channel_banner);
return picassoInstance.load((String) null);
} else {
return picassoInstance.load(url);
}
} }
public static RequestCreator loadPlaylistThumbnail(final String url) { public static RequestCreator loadPlaylistThumbnail(final String url) {

View File

@ -28,10 +28,11 @@
<ImageView <ImageView
android:id="@+id/channel_banner_image" android:id="@+id/channel_banner_image"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="70dp" android:layout_height="wrap_content"
android:background="@drawable/placeholder_channel_banner" android:maxHeight="70dp"
android:src="@drawable/placeholder_channel_banner"
android:adjustViewBounds="true" android:adjustViewBounds="true"
android:scaleType="centerCrop" android:scaleType="fitCenter"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription" /> tools:ignore="ContentDescription" />