Add support for INFINITE_ and MORE_THAN_100_ITEMS in playlists

This commit is contained in:
Stypox 2020-03-17 18:41:39 +01:00 committed by wb9688
parent e51314b104
commit 2710d9de5b
3 changed files with 13 additions and 3 deletions

View File

@ -136,7 +136,7 @@ dependencies {
exclude module: 'support-annotations'
})
implementation 'com.github.TeamNewPipe:NewPipeExtractor:a5155fb'
implementation 'com.github.XiangRongLin:NewPipeExtractor:6a23efa8d41a05f37b8f523aa08af7e0a9d6c4e1'
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.23.0'

View File

@ -27,6 +27,7 @@ import org.schabi.newpipe.extractor.InfoItem;
import org.schabi.newpipe.extractor.ListExtractor;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
import org.schabi.newpipe.extractor.playlist.PlaylistInfo;
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import org.schabi.newpipe.extractor.stream.StreamType;
@ -302,8 +303,15 @@ public class PlaylistFragment extends BaseListInfoFragment<PlaylistInfo> {
IMAGE_LOADER.displayImage(result.getUploaderAvatarUrl(), headerUploaderAvatar,
ImageDisplayConstants.DISPLAY_AVATAR_OPTIONS);
headerStreamCount.setText(getResources().getQuantityString(R.plurals.videos,
(int) result.getStreamCount(), (int) result.getStreamCount()));
int streamCount = (int) result.getStreamCount();
if (streamCount == PlaylistExtractor.MORE_THAN_100_ITEMS) {
headerStreamCount.setText(getResources().getString(R.string.playlist_more_than_100_items));
} else if (streamCount == PlaylistExtractor.INFINITE_ITEMS) {
headerStreamCount.setText(getResources().getString(R.string.playlist_infinite_items));
} else {
headerStreamCount.setText(getResources().getQuantityString(R.plurals.videos, streamCount, streamCount));
}
if (!result.getErrors().isEmpty()) {
showSnackBarError(result.getErrors(), UserAction.REQUESTED_PLAYLIST,

View File

@ -458,6 +458,8 @@
<string name="playlist_thumbnail_change_success">Playlist thumbnail changed.</string>
<string name="playlist_delete_failure">Could not delete playlist.</string>
<string name="playlist_no_uploader">Auto-generated (no uploader found)</string>
<string name="playlist_more_than_100_items">100+ videos</string>
<string name="playlist_infinite_items">∞ videos</string>
<!-- Players -->
<string name="caption_none">No Captions</string>
<string name="resize_fit">Fit</string>