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;
import static org.schabi.newpipe.extractor.utils.Utils.isBlank;
import static org.schabi.newpipe.ktx.TextViewUtils.animateTextColor;
import static org.schabi.newpipe.ktx.ViewUtils.animate;
import static org.schabi.newpipe.ktx.ViewUtils.animateBackgroundColor;
@ -146,6 +147,10 @@ public class ChannelFragment extends BaseStateFragment<ChannelInfo>
binding.tabLayout.setupWithViewPager(binding.viewPager);
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
@ -575,9 +580,14 @@ public class ChannelFragment extends BaseStateFragment<ChannelInfo>
currentInfo = result;
setInitialData(result.getServiceId(), result.getOriginalUrl(), result.getName());
binding.getRoot().setVisibility(View.VISIBLE);
PicassoHelper.loadBanner(result.getBannerUrl()).tag(PICASSO_CHANNEL_TAG)
.into(binding.channelBannerImage);
if (PicassoHelper.getShouldLoadImages() && !isBlank(result.getBannerUrl())) {
PicassoHelper.loadBanner(result.getBannerUrl()).tag(PICASSO_CHANNEL_TAG)
.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)
.into(binding.channelAvatarView);
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) {
if (!shouldLoadImages || isBlank(url)) {
return picassoInstance.load((String) null);
} else {
return picassoInstance.load(url);
}
return loadImageDefault(url, R.drawable.placeholder_channel_banner);
}
public static RequestCreator loadPlaylistThumbnail(final String url) {

View File

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