Implemented the "remove duplicates" feature.
This commit is contained in:
parent
0933b335e6
commit
82d74d18ee
4 changed files with 36 additions and 14 deletions
|
|
@ -627,8 +627,8 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
|
|||
private void openRemoveDuplicatesDialog() {
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(this.getActivity());
|
||||
|
||||
builder.setTitle("R.string.duplicate_stream_in_playlist_title")
|
||||
.setMessage("test")
|
||||
builder.setTitle(R.string.remove_duplicates_title)
|
||||
.setMessage(R.string.remove_duplicates_message)
|
||||
.setPositiveButton(android.R.string.yes, (dialog, i) -> {
|
||||
removeDuplicatesInPlaylist();
|
||||
})
|
||||
|
|
@ -638,7 +638,20 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
|
|||
}
|
||||
|
||||
private void removeDuplicatesInPlaylist() {
|
||||
final List<PlaylistStreamEntry> itemsToKeep = playlistManager
|
||||
.getDistinctPlaylistStreams(playlistId).blockingFirst();
|
||||
|
||||
itemListAdapter.clearStreamItemList();
|
||||
itemListAdapter.addItems(itemsToKeep);
|
||||
saveChanges();
|
||||
|
||||
final long videoCount = itemListAdapter.getItemsList().size();
|
||||
setVideoCount(videoCount);
|
||||
if (videoCount == 0) {
|
||||
showEmptyState();
|
||||
}
|
||||
//TODO: Do we have to show loading?
|
||||
//hideLoading();
|
||||
}
|
||||
|
||||
private void deleteItem(final PlaylistStreamEntry item) {
|
||||
|
|
|
|||
|
|
@ -86,10 +86,9 @@ public class LocalPlaylistManager {
|
|||
return playlistStreamTable.getPlaylistMetadata().subscribeOn(Schedulers.io());
|
||||
}
|
||||
|
||||
public Flowable<List<PlaylistMetadataEntry>> removeDuplicateStreams() {
|
||||
// TODO: Delete Duplicates and rebuild the index
|
||||
// TODO: Rebuild the index
|
||||
return playlistStreamTable.getPlaylistMetadata().subscribeOn(Schedulers.io());
|
||||
public Flowable<List<PlaylistStreamEntry>> getDistinctPlaylistStreams(final long playlistId) {
|
||||
return playlistStreamTable
|
||||
.getStreamsWithoutDuplicates(playlistId).subscribeOn(Schedulers.io());
|
||||
}
|
||||
|
||||
public Flowable<List<PlaylistStreamEntry>> getPlaylistStreams(final long playlistId) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue