Merge pull request #9173 from Theta-Dev/video-sub-count

Show subscriber count on video details page
This commit is contained in:
Stypox 2022-12-04 20:50:13 +01:00 committed by GitHub
commit a6f57a8665
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 10 deletions

View File

@ -1561,9 +1561,9 @@ public final class VideoDetailFragment
binding.detailSubChannelThumbnailView.setVisibility(View.GONE);
if (!isEmpty(info.getSubChannelName())) {
displayBothUploaderAndSubChannel(info);
displayBothUploaderAndSubChannel(info, activity);
} else if (!isEmpty(info.getUploaderName())) {
displayUploaderAsSubChannel(info);
displayUploaderAsSubChannel(info, activity);
} else {
binding.detailUploaderTextView.setVisibility(View.GONE);
binding.detailUploaderThumbnailView.setVisibility(View.GONE);
@ -1676,23 +1676,42 @@ public final class VideoDetailFragment
noVideoStreams ? R.drawable.ic_headset_shadow : R.drawable.ic_play_arrow_shadow);
}
private void displayUploaderAsSubChannel(final StreamInfo info) {
private void displayUploaderAsSubChannel(final StreamInfo info, final Context context) {
binding.detailSubChannelTextView.setText(info.getUploaderName());
binding.detailSubChannelTextView.setVisibility(View.VISIBLE);
binding.detailSubChannelTextView.setSelected(true);
if (info.getUploaderSubscriberCount() > -1) {
binding.detailUploaderTextView.setText(
Localization.shortSubscriberCount(context, info.getUploaderSubscriberCount()));
binding.detailUploaderTextView.setVisibility(View.VISIBLE);
} else {
binding.detailUploaderTextView.setVisibility(View.GONE);
}
}
private void displayBothUploaderAndSubChannel(final StreamInfo info) {
private void displayBothUploaderAndSubChannel(final StreamInfo info, final Context context) {
binding.detailSubChannelTextView.setText(info.getSubChannelName());
binding.detailSubChannelTextView.setVisibility(View.VISIBLE);
binding.detailSubChannelTextView.setSelected(true);
binding.detailSubChannelThumbnailView.setVisibility(View.VISIBLE);
final StringBuilder subText = new StringBuilder();
if (!isEmpty(info.getUploaderName())) {
binding.detailUploaderTextView.setText(
subText.append(
String.format(getString(R.string.video_detail_by), info.getUploaderName()));
}
if (info.getUploaderSubscriberCount() > -1) {
if (subText.length() > 0) {
subText.append(Localization.DOT_SEPARATOR);
}
subText.append(
Localization.shortSubscriberCount(context, info.getUploaderSubscriberCount()));
}
if (subText.length() > 0) {
binding.detailUploaderTextView.setText(subText);
binding.detailUploaderTextView.setVisibility(View.VISIBLE);
binding.detailUploaderTextView.setSelected(true);
} else {

View File

@ -319,9 +319,7 @@
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="@dimen/video_item_detail_uploader_text_size"
android:textStyle="bold"
tools:ignore="RtlHardcoded"
tools:text="Uploader" />
</LinearLayout>

View File

@ -306,9 +306,7 @@
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="@dimen/video_item_detail_uploader_text_size"
android:textStyle="bold"
tools:ignore="RtlHardcoded"
tools:text="Uploader" />