fix issue: thumbnail update when element deleted + thumbnail update when element added and no thumbnail
This commit is contained in:
parent
dad88b83fb
commit
8de367e03f
3 changed files with 31 additions and 3 deletions
|
@ -152,9 +152,19 @@ public final class PlaylistAppendDialog extends PlaylistDialog {
|
||||||
final Toast successToast = Toast.makeText(getContext(),
|
final Toast successToast = Toast.makeText(getContext(),
|
||||||
R.string.playlist_add_stream_success, Toast.LENGTH_SHORT);
|
R.string.playlist_add_stream_success, Toast.LENGTH_SHORT);
|
||||||
|
|
||||||
|
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)
|
playlistDisposables.add(manager.appendToPlaylist(playlist.uid, streams)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(ignored -> successToast.show()));
|
.subscribe(ignored -> successToast.show()));
|
||||||
|
}
|
||||||
|
|
||||||
getDialog().dismiss();
|
getDialog().dismiss();
|
||||||
}
|
}
|
||||||
|
|
|
@ -413,10 +413,24 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
|
||||||
disposables.add(disposable);
|
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) {
|
private void deleteItem(final PlaylistStreamEntry item) {
|
||||||
if (itemListAdapter == null) return;
|
if (itemListAdapter == null) return;
|
||||||
|
|
||||||
itemListAdapter.removeItem(item);
|
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());
|
setVideoCount(itemListAdapter.getItemsList().size());
|
||||||
saveChanges();
|
saveChanges();
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,6 +103,10 @@ public class LocalPlaylistManager {
|
||||||
return modifyPlaylist(playlistId, null, thumbnailUrl);
|
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,
|
private Maybe<Integer> modifyPlaylist(final long playlistId,
|
||||||
@Nullable final String name,
|
@Nullable final String name,
|
||||||
@Nullable final String thumbnailUrl) {
|
@Nullable final String thumbnailUrl) {
|
||||||
|
|
Loading…
Reference in a new issue