mirror of
				https://github.com/TeamNewPipe/NewPipe
				synced 2025-10-31 15:23:00 +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()); | ||||
|     } | ||||
|   | ||||
| @@ -12,8 +12,14 @@ | ||||
|         android:id="@+id/menu_item_rename_playlist" | ||||
|         android:title="@string/rename_playlist" | ||||
|         app:showAsAction="never" /> | ||||
|  | ||||
|     <item | ||||
|         android:id="@+id/menu_item_remove_watched" | ||||
|         android:title="@string/remove_watched" | ||||
|         app:showAsAction="never" /> | ||||
|  | ||||
|     <item | ||||
|         android:id="@+id/menu_item_remove_duplicates" | ||||
|         android:title="@string/remove_duplicates" | ||||
|         app:showAsAction="never" /> | ||||
| </menu> | ||||
|   | ||||
| @@ -626,6 +626,7 @@ | ||||
|     <string name="systems_language">System default</string> | ||||
|     <string name="remove_watched">Remove watched</string> | ||||
|     <string name="remove_watched_popup_title">Remove watched videos?</string> | ||||
|     <string name="remove_duplicates">Remove duplicates</string> | ||||
|     <string name="remove_watched_popup_warning">Videos that have been watched before and after being added to the playlist will be removed. | ||||
| \nAre you sure\? This cannot be undone!</string> | ||||
|     <string name="remove_watched_popup_yes_and_partially_watched_videos">Yes, and partially watched videos</string> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Jared Fantaye
					Jared Fantaye