From 8f9eaa22e603b4b28058d18535ba34f8fad0bff4 Mon Sep 17 00:00:00 2001 From: camo0112 <56369484+camo0112@users.noreply.github.com> Date: Fri, 9 Apr 2021 12:23:54 +0530 Subject: [PATCH] Fix display of channel details when it has no videos --- .../newpipe/fragments/list/BaseListInfoFragment.java | 7 ++++++- .../fragments/list/channel/ChannelFragment.java | 12 +++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListInfoFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListInfoFragment.java index 6874f80d5..e98dc9fda 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListInfoFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListInfoFragment.java @@ -12,6 +12,7 @@ import org.schabi.newpipe.error.UserAction; import org.schabi.newpipe.extractor.ListExtractor; import org.schabi.newpipe.extractor.ListInfo; import org.schabi.newpipe.extractor.Page; +import org.schabi.newpipe.extractor.channel.ChannelInfo; import org.schabi.newpipe.extractor.exceptions.ContentNotSupportedException; import org.schabi.newpipe.util.Constants; import org.schabi.newpipe.views.NewPipeRecyclerView; @@ -227,7 +228,11 @@ public abstract class BaseListInfoFragment showListFooter(hasMoreItems()); } else { infoListAdapter.clearStreamItemList(); - showEmptyState(); + // showEmptyState should be called only if there is no item as + // well as no header in infoListAdapter + if (!(result instanceof ChannelInfo && infoListAdapter.getItemCount() == 1)) { + showEmptyState(); + } } } diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java index a94581cfd..e02e18a86 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java @@ -449,8 +449,8 @@ public class ChannelFragment extends BaseListInfoFragment if (!TextUtils.isEmpty(currentInfo.getParentChannelName())) { headerBinding.subChannelTitleView.setText(String.format( - getString(R.string.channel_created_by), - currentInfo.getParentChannelName()) + getString(R.string.channel_created_by), + currentInfo.getParentChannelName()) ); headerBinding.subChannelTitleView.setVisibility(View.VISIBLE); headerBinding.subChannelAvatarView.setVisibility(View.VISIBLE); @@ -462,7 +462,13 @@ public class ChannelFragment extends BaseListInfoFragment menuRssButton.setVisible(!TextUtils.isEmpty(result.getFeedUrl())); } - playlistControlBinding.getRoot().setVisibility(View.VISIBLE); + // PlaylistControls should be visible only if there is some item in + // infoListAdapter other than header + if (infoListAdapter.getItemCount() != 1) { + playlistControlBinding.getRoot().setVisibility(View.VISIBLE); + } else { + playlistControlBinding.getRoot().setVisibility(View.GONE); + } for (final Throwable throwable : result.getErrors()) { if (throwable instanceof ContentNotSupportedException) {