mirror of
https://github.com/CappielloAntonio/tempo.git
synced 2026-02-05 08:33:07 +00:00
Fix song removing in playlist by position
This commit is contained in:
@@ -156,7 +156,7 @@ public class PlaylistEditorDialog extends DialogFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
|
public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
|
||||||
playlistEditorViewModel.removeFromPlaylistSongLiveList(playlistDialogSongHorizontalAdapter.getItem(viewHolder.getBindingAdapterPosition()));
|
playlistEditorViewModel.removeFromPlaylistSongLiveList(viewHolder.getBindingAdapterPosition());
|
||||||
bind.playlistSongRecyclerView.getAdapter().notifyItemRemoved(viewHolder.getBindingAdapterPosition());
|
bind.playlistSongRecyclerView.getAdapter().notifyItemRemoved(viewHolder.getBindingAdapterPosition());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,9 +74,9 @@ public class PlaylistEditorViewModel extends AndroidViewModel {
|
|||||||
return songLiveList;
|
return songLiveList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeFromPlaylistSongLiveList(Song song) {
|
public void removeFromPlaylistSongLiveList(int position) {
|
||||||
List<Song> songs = songLiveList.getValue();
|
List<Song> songs = songLiveList.getValue();
|
||||||
Objects.requireNonNull(songs).remove(song);
|
Objects.requireNonNull(songs).remove(position);
|
||||||
songLiveList.postValue(songs);
|
songLiveList.postValue(songs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user