From 7a33b529e08b46637ba899ec515eca10963fb424 Mon Sep 17 00:00:00 2001 From: Adam Baker Date: Mon, 30 May 2016 19:43:27 +0100 Subject: [PATCH] Add a clear playlist option. Fixes #2 --- .../github/nutomic/controldlna/gui/MainActivity.java | 3 +++ .../github/nutomic/controldlna/gui/RouteFragment.java | 11 +++++++++++ src/main/res/menu/menu.xml | 3 +++ src/main/res/values/strings.xml | 5 ++++- 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/github/nutomic/controldlna/gui/MainActivity.java b/src/main/java/com/github/nutomic/controldlna/gui/MainActivity.java index 855e12e..ee3c00b 100644 --- a/src/main/java/com/github/nutomic/controldlna/gui/MainActivity.java +++ b/src/main/java/com/github/nutomic/controldlna/gui/MainActivity.java @@ -188,6 +188,9 @@ public class MainActivity extends ActionBarActivity { case R.id.refreshdev: mServerFragment.triggerSearch(); return true; + case R.id.clearplaylist: + mRouteFragment.clearPlaylist(); + return true; case R.id.about: Intent a = new Intent(this, AboutActivity.class); startActivity(a); diff --git a/src/main/java/com/github/nutomic/controldlna/gui/RouteFragment.java b/src/main/java/com/github/nutomic/controldlna/gui/RouteFragment.java index 3480399..6caefcb 100644 --- a/src/main/java/com/github/nutomic/controldlna/gui/RouteFragment.java +++ b/src/main/java/com/github/nutomic/controldlna/gui/RouteFragment.java @@ -624,6 +624,17 @@ public class RouteFragment extends MediaRouteDiscoveryFragment implements mMediaRouterPlayService.append(playlist); } + /** + * Deletes the current playlist and stops playback + */ + public void clearPlaylist() + { + mMediaRouterPlayService.stop(); + changePlayPauseState(false); + mPlaylistAdapter.clear(); + mMediaRouterPlayService.setPlaylist(new ArrayList()); + } + /** * Generates a time string in the format mm:ss from a time value in seconds. * diff --git a/src/main/res/menu/menu.xml b/src/main/res/menu/menu.xml index 7962260..f3792b2 100644 --- a/src/main/res/menu/menu.xml +++ b/src/main/res/menu/menu.xml @@ -8,6 +8,9 @@ + diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index f7675b5..b54a5a9 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -46,10 +46,13 @@ Refresh Devices + + Clear Playlist + About - + ControlDLNA - a UPnP media control point \nOriginal version: \nCopyright (c) 2013, Felix Ableitner, All rights reserved.