mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2025-11-18 16:15:14 +00:00
Created the first draft.
This commit is contained in:
@@ -83,4 +83,15 @@ public interface PlaylistStreamDAO extends BasicDAO<PlaylistStreamEntity> {
|
||||
+ " GROUP BY " + JOIN_PLAYLIST_ID
|
||||
+ " ORDER BY " + PLAYLIST_NAME + " COLLATE NOCASE ASC")
|
||||
Flowable<List<PlaylistMetadataEntry>> getPlaylistMetadata();
|
||||
|
||||
@Transaction
|
||||
@Query("DELETE FROM " + PLAYLIST_STREAM_JOIN_TABLE
|
||||
+ " WHERE " + JOIN_PLAYLIST_ID + "=:playlistId"
|
||||
+ " AND " + JOIN_STREAM_ID + " IN ("
|
||||
+ " SELECT " + JOIN_STREAM_ID
|
||||
+ " FROM " + PLAYLIST_STREAM_JOIN_TABLE
|
||||
+ " WHERE " + JOIN_PLAYLIST_ID + "=:playlistId"
|
||||
+ " GROUP BY " + JOIN_STREAM_ID
|
||||
+ " HAVING COUNT(*) > 1 )" )
|
||||
Flowable<List<PlaylistMetadataEntry>> removeDuplicates(long playlistId);
|
||||
}
|
||||
|
||||
@@ -367,6 +367,8 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
|
||||
.create()
|
||||
.show();
|
||||
}
|
||||
} else if (item.getItemId() == R.id.menu_item_remove_duplicates) {
|
||||
openRemoveDuplicatesDialog();
|
||||
} else {
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
@@ -621,6 +623,24 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
|
||||
changeThumbnailUrl(newThumbnailUrl);
|
||||
}
|
||||
|
||||
|
||||
private void openRemoveDuplicatesDialog() {
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(this.getActivity());
|
||||
|
||||
builder.setTitle("R.string.duplicate_stream_in_playlist_title")
|
||||
.setMessage("test")
|
||||
.setPositiveButton(android.R.string.yes, (dialog, i) -> {
|
||||
removeDuplicatesInPlaylist();
|
||||
})
|
||||
.setNeutralButton(R.string.cancel, null);
|
||||
|
||||
builder.create().show();
|
||||
}
|
||||
|
||||
private void removeDuplicatesInPlaylist() {
|
||||
|
||||
}
|
||||
|
||||
private void deleteItem(final PlaylistStreamEntry item) {
|
||||
if (itemListAdapter == null) {
|
||||
return;
|
||||
|
||||
@@ -86,6 +86,12 @@ 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>> getPlaylistStreams(final long playlistId) {
|
||||
return playlistStreamTable.getOrderedStreamsOf(playlistId).subscribeOn(Schedulers.io());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user