1
0
mirror of https://github.com/TeamNewPipe/NewPipe.git synced 2024-11-24 20:15:16 +01:00

Show proper text for live streams watching/listening count

This commit is contained in:
Mauricio Colli 2019-10-27 23:37:36 -03:00
parent 71f1bbdcc1
commit 6e546703a9
No known key found for this signature in database
GPG Key ID: F200BFD6F29DDD85
4 changed files with 36 additions and 2 deletions

View File

@ -1067,7 +1067,13 @@ public class VideoDetailFragment
uploaderThumb.setImageDrawable(ContextCompat.getDrawable(activity, R.drawable.buddy));
if (info.getViewCount() >= 0) {
videoCountView.setText(Localization.localizeViewCount(activity, info.getViewCount()));
if (info.getStreamType().equals(StreamType.AUDIO_LIVE_STREAM)) {
videoCountView.setText(Localization.listeningCount(activity, info.getViewCount()));
} else if (info.getStreamType().equals(StreamType.LIVE_STREAM)) {
videoCountView.setText(Localization.watchingCount(activity, info.getViewCount()));
} else {
videoCountView.setText(Localization.localizeViewCount(activity, info.getViewCount()));
}
videoCountView.setVisibility(View.VISIBLE);
} else {
videoCountView.setVisibility(View.GONE);

View File

@ -7,6 +7,7 @@ import android.widget.TextView;
import org.schabi.newpipe.R;
import org.schabi.newpipe.extractor.InfoItem;
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import org.schabi.newpipe.extractor.stream.StreamType;
import org.schabi.newpipe.info_list.InfoItemBuilder;
import org.schabi.newpipe.local.history.HistoryRecordManager;
import org.schabi.newpipe.util.Localization;
@ -53,7 +54,13 @@ public class StreamInfoItemHolder extends StreamMiniInfoItemHolder {
private String getStreamInfoDetailLine(final StreamInfoItem infoItem) {
String viewsAndDate = "";
if (infoItem.getViewCount() >= 0) {
viewsAndDate = Localization.shortViewCount(itemBuilder.getContext(), infoItem.getViewCount());
if (infoItem.getStreamType().equals(StreamType.AUDIO_LIVE_STREAM)) {
viewsAndDate = Localization.listeningCount(itemBuilder.getContext(), infoItem.getViewCount());
} else if (infoItem.getStreamType().equals(StreamType.LIVE_STREAM)) {
viewsAndDate = Localization.watchingCount(itemBuilder.getContext(), infoItem.getViewCount());
} else {
viewsAndDate = Localization.shortViewCount(itemBuilder.getContext(), infoItem.getViewCount());
}
}
if (!TextUtils.isEmpty(infoItem.getTextualUploadDate())) {
if (viewsAndDate.isEmpty()) {

View File

@ -141,6 +141,14 @@ public class Localization {
}
}
public static String listeningCount(Context context, long listeningCount) {
return getQuantity(context, R.plurals.listening, R.string.no_one_listening, listeningCount, shortCount(context, listeningCount));
}
public static String watchingCount(Context context, long watchingCount) {
return getQuantity(context, R.plurals.watching, R.string.no_one_watching, watchingCount, shortCount(context, watchingCount));
}
public static String shortViewCount(Context context, long viewCount) {
return getQuantity(context, R.plurals.views, R.string.no_views, viewCount, shortCount(context, viewCount));
}

View File

@ -263,6 +263,19 @@
<item quantity="one">%s view</item>
<item quantity="other">%s views</item>
</plurals>
<string name="no_one_watching">No one is watching</string>
<plurals name="watching">
<item quantity="one">%s watching</item>
<item quantity="other">%s watching</item>
</plurals>
<string name="no_one_listening">No one is listening</string>
<plurals name="listening">
<item quantity="one">%s listener</item>
<item quantity="other">%s listeners</item>
</plurals>
<string name="no_videos">No videos</string>
<plurals name="videos">
<item quantity="one">%s video</item>