diff --git a/app/src/main/java/org/schabi/newpipe/info_list/holder/ChannelInfoItemHolder.java b/app/src/main/java/org/schabi/newpipe/info_list/holder/ChannelInfoItemHolder.java
index cf1ed255b..f8133d3de 100644
--- a/app/src/main/java/org/schabi/newpipe/info_list/holder/ChannelInfoItemHolder.java
+++ b/app/src/main/java/org/schabi/newpipe/info_list/holder/ChannelInfoItemHolder.java
@@ -1,14 +1,9 @@
package org.schabi.newpipe.info_list.holder;
import android.view.ViewGroup;
-import android.widget.TextView;
import org.schabi.newpipe.R;
-import org.schabi.newpipe.extractor.InfoItem;
-import org.schabi.newpipe.extractor.channel.ChannelInfoItem;
import org.schabi.newpipe.info_list.InfoItemBuilder;
-import org.schabi.newpipe.local.history.HistoryRecordManager;
-import org.schabi.newpipe.util.Localization;
/*
* Created by Christian Schabesberger on 12.02.17.
@@ -31,40 +26,7 @@ import org.schabi.newpipe.util.Localization;
*/
public class ChannelInfoItemHolder extends ChannelMiniInfoItemHolder {
- private final TextView itemChannelDescriptionView;
-
public ChannelInfoItemHolder(final InfoItemBuilder infoItemBuilder, final ViewGroup parent) {
super(infoItemBuilder, R.layout.list_channel_item, parent);
- itemChannelDescriptionView = itemView.findViewById(R.id.itemChannelDescriptionView);
- }
-
- @Override
- public void updateFromItem(final InfoItem infoItem,
- final HistoryRecordManager historyRecordManager) {
- super.updateFromItem(infoItem, historyRecordManager);
-
- if (!(infoItem instanceof ChannelInfoItem)) {
- return;
- }
- final ChannelInfoItem item = (ChannelInfoItem) infoItem;
-
- itemChannelDescriptionView.setText(item.getDescription());
- }
-
- @Override
- protected String getDetailLine(final ChannelInfoItem item) {
- String details = super.getDetailLine(item);
-
- if (item.getStreamCount() >= 0) {
- final String formattedVideoAmount = Localization.localizeStreamCount(
- itemBuilder.getContext(), item.getStreamCount());
-
- if (!details.isEmpty()) {
- details += " • " + formattedVideoAmount;
- } else {
- details = formattedVideoAmount;
- }
- }
- return details;
}
}
diff --git a/app/src/main/java/org/schabi/newpipe/info_list/holder/ChannelMiniInfoItemHolder.java b/app/src/main/java/org/schabi/newpipe/info_list/holder/ChannelMiniInfoItemHolder.java
index 89398a1e5..c625c3c5c 100644
--- a/app/src/main/java/org/schabi/newpipe/info_list/holder/ChannelMiniInfoItemHolder.java
+++ b/app/src/main/java/org/schabi/newpipe/info_list/holder/ChannelMiniInfoItemHolder.java
@@ -1,21 +1,26 @@
package org.schabi.newpipe.info_list.holder;
+import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
+import androidx.annotation.Nullable;
+
import org.schabi.newpipe.R;
import org.schabi.newpipe.extractor.InfoItem;
import org.schabi.newpipe.extractor.channel.ChannelInfoItem;
+import org.schabi.newpipe.extractor.utils.Utils;
import org.schabi.newpipe.info_list.InfoItemBuilder;
import org.schabi.newpipe.local.history.HistoryRecordManager;
import org.schabi.newpipe.util.PicassoHelper;
import org.schabi.newpipe.util.Localization;
public class ChannelMiniInfoItemHolder extends InfoItemHolder {
- public final ImageView itemThumbnailView;
- public final TextView itemTitleView;
+ private final ImageView itemThumbnailView;
+ private final TextView itemTitleView;
private final TextView itemAdditionalDetailView;
+ private final TextView itemChannelDescriptionView;
ChannelMiniInfoItemHolder(final InfoItemBuilder infoItemBuilder, final int layoutId,
final ViewGroup parent) {
@@ -24,6 +29,7 @@ public class ChannelMiniInfoItemHolder extends InfoItemHolder {
itemThumbnailView = itemView.findViewById(R.id.itemThumbnailView);
itemTitleView = itemView.findViewById(R.id.itemTitleView);
itemAdditionalDetailView = itemView.findViewById(R.id.itemAdditionalDetails);
+ itemChannelDescriptionView = itemView.findViewById(R.id.itemChannelDescriptionView);
}
public ChannelMiniInfoItemHolder(final InfoItemBuilder infoItemBuilder,
@@ -40,7 +46,14 @@ public class ChannelMiniInfoItemHolder extends InfoItemHolder {
final ChannelInfoItem item = (ChannelInfoItem) infoItem;
itemTitleView.setText(item.getName());
- itemAdditionalDetailView.setText(getDetailLine(item));
+
+ final String detailLine = getDetailLine(item);
+ if (detailLine == null) {
+ itemAdditionalDetailView.setVisibility(View.GONE);
+ } else {
+ itemAdditionalDetailView.setVisibility(View.VISIBLE);
+ itemAdditionalDetailView.setText(getDetailLine(item));
+ }
PicassoHelper.loadAvatar(item.getThumbnailUrl()).into(itemThumbnailView);
@@ -56,14 +69,35 @@ public class ChannelMiniInfoItemHolder extends InfoItemHolder {
}
return true;
});
+
+ if (itemChannelDescriptionView != null) {
+ // itemChannelDescriptionView will be null in the mini variant
+ if (Utils.isBlank(item.getDescription())) {
+ itemChannelDescriptionView.setVisibility(View.GONE);
+ } else {
+ itemChannelDescriptionView.setVisibility(View.VISIBLE);
+ itemChannelDescriptionView.setText(item.getDescription());
+ itemChannelDescriptionView.setMaxLines(detailLine == null ? 3 : 2);
+ }
+ }
}
- protected String getDetailLine(final ChannelInfoItem item) {
- String details = "";
- if (item.getSubscriberCount() >= 0) {
- details += Localization.shortSubscriberCount(itemBuilder.getContext(),
+ @Nullable
+ private String getDetailLine(final ChannelInfoItem item) {
+ if (item.getStreamCount() >= 0 && item.getSubscriberCount() >= 0) {
+ return Localization.concatenateStrings(
+ Localization.shortSubscriberCount(itemBuilder.getContext(),
+ item.getSubscriberCount()),
+ Localization.localizeStreamCount(itemBuilder.getContext(),
+ item.getStreamCount()));
+ } else if (item.getStreamCount() >= 0) {
+ return Localization.localizeStreamCount(itemBuilder.getContext(),
+ item.getStreamCount());
+ } else if (item.getSubscriberCount() >= 0) {
+ return Localization.shortSubscriberCount(itemBuilder.getContext(),
item.getSubscriberCount());
+ } else {
+ return null;
}
- return details;
}
}
diff --git a/app/src/main/res/layout/list_channel_grid_item.xml b/app/src/main/res/layout/list_channel_grid_item.xml
index 3112a849f..0aec4e6e0 100644
--- a/app/src/main/res/layout/list_channel_grid_item.xml
+++ b/app/src/main/res/layout/list_channel_grid_item.xml
@@ -39,12 +39,24 @@
android:id="@+id/itemAdditionalDetails"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_below="@+id/itemTitleView"
+ android:layout_below="@id/itemTitleView"
android:layout_centerHorizontal="true"
android:lines="1"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textSize="@dimen/video_item_search_upload_date_text_size"
tools:ignore="RtlHardcoded"
- tools:text="10M subscribers" />
+ tools:text="10M subscribers • 100 videos" />
+
+
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
index 9f7e50c19..5693ec7c4 100644
--- a/app/src/main/res/values/dimens.xml
+++ b/app/src/main/res/values/dimens.xml
@@ -30,7 +30,7 @@
164dp
92dp
- 42dp
+ 92dp
128dp
96dp