mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-23 08:30:44 +00:00
Made the channel-images in the grid list bigger
Also improved the handling of additional information (expanded description, video count, subscriber count)
This commit is contained in:
parent
5942add141
commit
764b6aa2b1
@ -1,14 +1,9 @@
|
|||||||
package org.schabi.newpipe.info_list.holder;
|
package org.schabi.newpipe.info_list.holder;
|
||||||
|
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import org.schabi.newpipe.R;
|
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.info_list.InfoItemBuilder;
|
||||||
import org.schabi.newpipe.local.history.HistoryRecordManager;
|
|
||||||
import org.schabi.newpipe.util.Localization;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Created by Christian Schabesberger on 12.02.17.
|
* Created by Christian Schabesberger on 12.02.17.
|
||||||
@ -31,40 +26,7 @@ import org.schabi.newpipe.util.Localization;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public class ChannelInfoItemHolder extends ChannelMiniInfoItemHolder {
|
public class ChannelInfoItemHolder extends ChannelMiniInfoItemHolder {
|
||||||
private final TextView itemChannelDescriptionView;
|
|
||||||
|
|
||||||
public ChannelInfoItemHolder(final InfoItemBuilder infoItemBuilder, final ViewGroup parent) {
|
public ChannelInfoItemHolder(final InfoItemBuilder infoItemBuilder, final ViewGroup parent) {
|
||||||
super(infoItemBuilder, R.layout.list_channel_item, 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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,26 @@
|
|||||||
package org.schabi.newpipe.info_list.holder;
|
package org.schabi.newpipe.info_list.holder;
|
||||||
|
|
||||||
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
import org.schabi.newpipe.extractor.InfoItem;
|
import org.schabi.newpipe.extractor.InfoItem;
|
||||||
import org.schabi.newpipe.extractor.channel.ChannelInfoItem;
|
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.info_list.InfoItemBuilder;
|
||||||
import org.schabi.newpipe.local.history.HistoryRecordManager;
|
import org.schabi.newpipe.local.history.HistoryRecordManager;
|
||||||
import org.schabi.newpipe.util.PicassoHelper;
|
import org.schabi.newpipe.util.PicassoHelper;
|
||||||
import org.schabi.newpipe.util.Localization;
|
import org.schabi.newpipe.util.Localization;
|
||||||
|
|
||||||
public class ChannelMiniInfoItemHolder extends InfoItemHolder {
|
public class ChannelMiniInfoItemHolder extends InfoItemHolder {
|
||||||
public final ImageView itemThumbnailView;
|
private final ImageView itemThumbnailView;
|
||||||
public final TextView itemTitleView;
|
private final TextView itemTitleView;
|
||||||
private final TextView itemAdditionalDetailView;
|
private final TextView itemAdditionalDetailView;
|
||||||
|
private final TextView itemChannelDescriptionView;
|
||||||
|
|
||||||
ChannelMiniInfoItemHolder(final InfoItemBuilder infoItemBuilder, final int layoutId,
|
ChannelMiniInfoItemHolder(final InfoItemBuilder infoItemBuilder, final int layoutId,
|
||||||
final ViewGroup parent) {
|
final ViewGroup parent) {
|
||||||
@ -24,6 +29,7 @@ public class ChannelMiniInfoItemHolder extends InfoItemHolder {
|
|||||||
itemThumbnailView = itemView.findViewById(R.id.itemThumbnailView);
|
itemThumbnailView = itemView.findViewById(R.id.itemThumbnailView);
|
||||||
itemTitleView = itemView.findViewById(R.id.itemTitleView);
|
itemTitleView = itemView.findViewById(R.id.itemTitleView);
|
||||||
itemAdditionalDetailView = itemView.findViewById(R.id.itemAdditionalDetails);
|
itemAdditionalDetailView = itemView.findViewById(R.id.itemAdditionalDetails);
|
||||||
|
itemChannelDescriptionView = itemView.findViewById(R.id.itemChannelDescriptionView);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChannelMiniInfoItemHolder(final InfoItemBuilder infoItemBuilder,
|
public ChannelMiniInfoItemHolder(final InfoItemBuilder infoItemBuilder,
|
||||||
@ -40,7 +46,14 @@ public class ChannelMiniInfoItemHolder extends InfoItemHolder {
|
|||||||
final ChannelInfoItem item = (ChannelInfoItem) infoItem;
|
final ChannelInfoItem item = (ChannelInfoItem) infoItem;
|
||||||
|
|
||||||
itemTitleView.setText(item.getName());
|
itemTitleView.setText(item.getName());
|
||||||
|
|
||||||
|
final String detailLine = getDetailLine(item);
|
||||||
|
if (detailLine == null) {
|
||||||
|
itemAdditionalDetailView.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
itemAdditionalDetailView.setVisibility(View.VISIBLE);
|
||||||
itemAdditionalDetailView.setText(getDetailLine(item));
|
itemAdditionalDetailView.setText(getDetailLine(item));
|
||||||
|
}
|
||||||
|
|
||||||
PicassoHelper.loadAvatar(item.getThumbnailUrl()).into(itemThumbnailView);
|
PicassoHelper.loadAvatar(item.getThumbnailUrl()).into(itemThumbnailView);
|
||||||
|
|
||||||
@ -56,14 +69,35 @@ public class ChannelMiniInfoItemHolder extends InfoItemHolder {
|
|||||||
}
|
}
|
||||||
return true;
|
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) {
|
@Nullable
|
||||||
String details = "";
|
private String getDetailLine(final ChannelInfoItem item) {
|
||||||
if (item.getSubscriberCount() >= 0) {
|
if (item.getStreamCount() >= 0 && item.getSubscriberCount() >= 0) {
|
||||||
details += Localization.shortSubscriberCount(itemBuilder.getContext(),
|
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());
|
item.getSubscriberCount());
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
return details;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,12 +39,24 @@
|
|||||||
android:id="@+id/itemAdditionalDetails"
|
android:id="@+id/itemAdditionalDetails"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/itemTitleView"
|
android:layout_below="@id/itemTitleView"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true"
|
||||||
android:lines="1"
|
android:lines="1"
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
android:textSize="@dimen/video_item_search_upload_date_text_size"
|
android:textSize="@dimen/video_item_search_upload_date_text_size"
|
||||||
tools:ignore="RtlHardcoded"
|
tools:ignore="RtlHardcoded"
|
||||||
tools:text="10M subscribers" />
|
tools:text="10M subscribers • 100 videos" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/itemChannelDescriptionView"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@id/itemAdditionalDetails"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
|
android:textSize="@dimen/video_item_search_upload_date_text_size"
|
||||||
|
android:gravity="center"
|
||||||
|
tools:ignore="RtlHardcoded"
|
||||||
|
tools:text="@tools:sample/lorem/random" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
<dimen name="video_item_grid_thumbnail_image_width">164dp</dimen>
|
<dimen name="video_item_grid_thumbnail_image_width">164dp</dimen>
|
||||||
<dimen name="video_item_grid_thumbnail_image_height">92dp</dimen>
|
<dimen name="video_item_grid_thumbnail_image_height">92dp</dimen>
|
||||||
|
|
||||||
<dimen name="channel_item_grid_thumbnail_image_size">42dp</dimen>
|
<dimen name="channel_item_grid_thumbnail_image_size">92dp</dimen>
|
||||||
<dimen name="channel_item_grid_min_width">128dp</dimen>
|
<dimen name="channel_item_grid_min_width">128dp</dimen>
|
||||||
<!-- Calculated: 2*video_item_search_padding + video_item_search_thumbnail_image_height -->
|
<!-- Calculated: 2*video_item_search_padding + video_item_search_thumbnail_image_height -->
|
||||||
<dimen name="video_item_search_height">96dp</dimen>
|
<dimen name="video_item_search_height">96dp</dimen>
|
||||||
|
Loading…
Reference in New Issue
Block a user