From a18f2790263bdcb8c158b8d82c6d3a3b2651d279 Mon Sep 17 00:00:00 2001 From: svyatoslavrecord Date: Fri, 29 Jun 2018 14:47:36 +0300 Subject: [PATCH] Stop button in AudioPlayerActivity --- .../ui/activity/AudioPlayerActivity.java | 11 +++++++++++ demo/src/main/res/drawable/ic_stop_black_24dp.xml | 9 +++++++++ demo/src/main/res/layout/audio_player_activity.xml | 13 +++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 demo/src/main/res/drawable/ic_stop_black_24dp.xml diff --git a/demo/src/main/java/com/devbrackets/android/playlistcoredemo/ui/activity/AudioPlayerActivity.java b/demo/src/main/java/com/devbrackets/android/playlistcoredemo/ui/activity/AudioPlayerActivity.java index d51040e..c41da23 100644 --- a/demo/src/main/java/com/devbrackets/android/playlistcoredemo/ui/activity/AudioPlayerActivity.java +++ b/demo/src/main/java/com/devbrackets/android/playlistcoredemo/ui/activity/AudioPlayerActivity.java @@ -61,6 +61,7 @@ public class AudioPlayerActivity extends AppCompatActivity implements PlaylistLi private ImageButton previousButton; private ImageButton playPauseButton; + private ImageButton stopButton; private ImageButton nextButton; private MediaRouteButton castButton; @@ -235,6 +236,7 @@ private void updatePlayPauseImage(boolean isPlaying) { */ public void loadCompleted() { playPauseButton.setVisibility(View.VISIBLE); + stopButton.setVisibility(View.VISIBLE); previousButton.setVisibility(View.VISIBLE); nextButton.setVisibility(View.VISIBLE ); @@ -247,6 +249,7 @@ public void loadCompleted() { */ public void restartLoading() { playPauseButton.setVisibility(View.INVISIBLE); + stopButton.setVisibility(View.INVISIBLE); previousButton.setVisibility(View.INVISIBLE); nextButton.setVisibility(View.INVISIBLE ); @@ -308,6 +311,7 @@ private void retrieveViews() { previousButton = findViewById(R.id.audio_player_previous); playPauseButton = findViewById(R.id.audio_player_play_pause); + stopButton = findViewById(R.id.audio_player_stop); nextButton = findViewById(R.id.audio_player_next); castButton = findViewById(R.id.media_route_button); @@ -335,6 +339,13 @@ public void onClick(View v) { } }); + stopButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + playlistManager.invokeStop(); + } + }); + nextButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { diff --git a/demo/src/main/res/drawable/ic_stop_black_24dp.xml b/demo/src/main/res/drawable/ic_stop_black_24dp.xml new file mode 100644 index 0000000..bb8bff4 --- /dev/null +++ b/demo/src/main/res/drawable/ic_stop_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/demo/src/main/res/layout/audio_player_activity.xml b/demo/src/main/res/layout/audio_player_activity.xml index dcd08bc..73db883 100644 --- a/demo/src/main/res/layout/audio_player_activity.xml +++ b/demo/src/main/res/layout/audio_player_activity.xml @@ -163,6 +163,19 @@ android:layout_width="44dp" android:layout_height="match_parent"/> + + + +