mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-01 09:53:33 +00:00
feat: implemented playlist deletion starting from current track
This commit is contained in:
parent
185a671f82
commit
ed30198c8d
4 changed files with 64 additions and 10 deletions
|
|
@ -254,6 +254,21 @@ public class MediaManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void removeRange(ListenableFuture<MediaBrowser> mediaBrowserListenableFuture, List<Child> media, int fromItem, int toItem) {
|
||||||
|
if (mediaBrowserListenableFuture != null) {
|
||||||
|
mediaBrowserListenableFuture.addListener(() -> {
|
||||||
|
try {
|
||||||
|
if (mediaBrowserListenableFuture.isDone()) {
|
||||||
|
mediaBrowserListenableFuture.get().removeMediaItems(fromItem, toItem);
|
||||||
|
removeRangeDatabase(media, fromItem, toItem);
|
||||||
|
}
|
||||||
|
} catch (ExecutionException | InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}, MoreExecutors.directExecutor());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void getCurrentIndex(ListenableFuture<MediaBrowser> mediaBrowserListenableFuture, MediaIndexCallback callback) {
|
public static void getCurrentIndex(ListenableFuture<MediaBrowser> mediaBrowserListenableFuture, MediaIndexCallback callback) {
|
||||||
if (mediaBrowserListenableFuture != null) {
|
if (mediaBrowserListenableFuture != null) {
|
||||||
mediaBrowserListenableFuture.addListener(() -> {
|
mediaBrowserListenableFuture.addListener(() -> {
|
||||||
|
|
@ -320,6 +335,14 @@ public class MediaManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void removeRangeDatabase(List<Child> media, int fromItem, int toItem) {
|
||||||
|
List<Child> toRemove = media.subList(fromItem, toItem);
|
||||||
|
|
||||||
|
media.removeAll(toRemove);
|
||||||
|
|
||||||
|
getQueueRepository().insertAll(media, true, 0);
|
||||||
|
}
|
||||||
|
|
||||||
public static void clearDatabase() {
|
public static void clearDatabase() {
|
||||||
getQueueRepository().deleteAll();
|
getQueueRepository().deleteAll();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,7 @@ public class PlayerQueueFragment extends Fragment implements ClickCallback {
|
||||||
try {
|
try {
|
||||||
MediaBrowser mediaBrowser = mediaBrowserListenableFuture.get();
|
MediaBrowser mediaBrowser = mediaBrowserListenableFuture.get();
|
||||||
initShuffleButton(mediaBrowser);
|
initShuffleButton(mediaBrowser);
|
||||||
|
initCleanButton(mediaBrowser);
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
@ -197,6 +198,16 @@ public class PlayerQueueFragment extends Fragment implements ClickCallback {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void initCleanButton(MediaBrowser mediaBrowser) {
|
||||||
|
bind.playerCleanQueueButton.setOnClickListener(view -> {
|
||||||
|
int startPosition = mediaBrowser.getCurrentMediaItemIndex() + 1;
|
||||||
|
int endPosition = playerSongQueueAdapter.getItems().size();
|
||||||
|
|
||||||
|
MediaManager.removeRange(mediaBrowserListenableFuture, playerSongQueueAdapter.getItems(), startPosition, endPosition);
|
||||||
|
bind.playerQueueRecyclerView.getAdapter().notifyItemRangeRemoved(startPosition, endPosition);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void updateNowPlayingItem() {
|
private void updateNowPlayingItem() {
|
||||||
playerSongQueueAdapter.notifyDataSetChanged();
|
playerSongQueueAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
@ -10,14 +9,34 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<androidx.core.widget.NestedScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:paddingTop="8dp"
|
||||||
|
android:paddingBottom="@dimen/global_padding_bottom">
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/player_queue_recycler_view"
|
android:id="@+id/player_queue_recycler_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:clipToPadding="false"
|
android:orientation="vertical" />
|
||||||
android:orientation="vertical"
|
|
||||||
android:paddingTop="8dp"
|
<TextView
|
||||||
android:paddingBottom="@dimen/global_padding_bottom" />
|
android:id="@+id/player_clean_queue_button"
|
||||||
|
style="@style/TitleMedium"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
android:text="@string/player_queue_clean_all_button"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</androidx.core.widget.NestedScrollView>
|
||||||
</com.cappielloantonio.tempo.helper.recyclerview.NestedScrollableHost>
|
</com.cappielloantonio.tempo.helper.recyclerview.NestedScrollableHost>
|
||||||
|
|
||||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
|
|
|
||||||
|
|
@ -123,6 +123,7 @@
|
||||||
<string name="menu_search_button">Search</string>
|
<string name="menu_search_button">Search</string>
|
||||||
<string name="menu_settings_button">Settings</string>
|
<string name="menu_settings_button">Settings</string>
|
||||||
<string name="player_playback_speed">%1$.2fx</string>
|
<string name="player_playback_speed">%1$.2fx</string>
|
||||||
|
<string name="player_queue_clean_all_button">Clean play queue</string>
|
||||||
<string name="player_server_priority">Server Priority</string>
|
<string name="player_server_priority">Server Priority</string>
|
||||||
<string name="playlist_catalogue_title">Playlist Catalogue</string>
|
<string name="playlist_catalogue_title">Playlist Catalogue</string>
|
||||||
<string name="playlist_catalogue_title_expanded">Browse Playlists</string>
|
<string name="playlist_catalogue_title_expanded">Browse Playlists</string>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue