mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-23 16:40:32 +00:00
fix issue: thumbnail update when element deleted + thumbnail update when element added and no thumbnail
This commit is contained in:
parent
dad88b83fb
commit
8de367e03f
@ -152,9 +152,19 @@ public final class PlaylistAppendDialog extends PlaylistDialog {
|
||||
final Toast successToast = Toast.makeText(getContext(),
|
||||
R.string.playlist_add_stream_success, Toast.LENGTH_SHORT);
|
||||
|
||||
playlistDisposables.add(manager.appendToPlaylist(playlist.uid, streams)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(ignored -> successToast.show()));
|
||||
if(playlist.thumbnailUrl.equals("https://i.ytimg.com/")){ //empty playlist
|
||||
playlistDisposables.add(manager.createPlaylist(playlist.name, streams)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(ignored -> successToast.show()));
|
||||
playlistDisposables.add(manager.deletePlaylist(playlist.uid)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(ignored -> successToast.show()));
|
||||
}
|
||||
else {
|
||||
playlistDisposables.add(manager.appendToPlaylist(playlist.uid, streams)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(ignored -> successToast.show()));
|
||||
}
|
||||
|
||||
getDialog().dismiss();
|
||||
}
|
||||
|
@ -413,10 +413,24 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
|
||||
disposables.add(disposable);
|
||||
}
|
||||
|
||||
private void updateThumbnailUrl() {
|
||||
String newThumbnailUrl;
|
||||
|
||||
if(!itemListAdapter.getItemsList().isEmpty()){
|
||||
newThumbnailUrl = ((PlaylistStreamEntry)itemListAdapter.getItemsList().get(0)).thumbnailUrl;
|
||||
}
|
||||
else newThumbnailUrl = "https://i.ytimg.com/";
|
||||
|
||||
changeThumbnailUrl(newThumbnailUrl);
|
||||
}
|
||||
|
||||
private void deleteItem(final PlaylistStreamEntry item) {
|
||||
if (itemListAdapter == null) return;
|
||||
|
||||
itemListAdapter.removeItem(item);
|
||||
if(playlistManager.getPlaylistThumbnail(playlistId).equals(item.thumbnailUrl)) // If yes change for the first thumbnail of the list
|
||||
updateThumbnailUrl();
|
||||
|
||||
setVideoCount(itemListAdapter.getItemsList().size());
|
||||
saveChanges();
|
||||
}
|
||||
|
@ -103,6 +103,10 @@ public class LocalPlaylistManager {
|
||||
return modifyPlaylist(playlistId, null, thumbnailUrl);
|
||||
}
|
||||
|
||||
public String getPlaylistThumbnail(final long playlistId) {
|
||||
return playlistTable.getPlaylist(playlistId).blockingFirst().get(0).getThumbnailUrl();
|
||||
}
|
||||
|
||||
private Maybe<Integer> modifyPlaylist(final long playlistId,
|
||||
@Nullable final String name,
|
||||
@Nullable final String thumbnailUrl) {
|
||||
|
Loading…
Reference in New Issue
Block a user