From 2c6bf316e1587ba9c91e0ac3c059911dd1d73438 Mon Sep 17 00:00:00 2001 From: Adrian Ulrich Date: Sun, 20 Mar 2016 18:20:29 +0100 Subject: [PATCH] implement bindControlButtons() --- .../android/vanilla/FullPlaybackActivity.java | 13 +------------ .../android/vanilla/LibraryActivity.java | 1 + .../android/vanilla/MiniPlaybackActivity.java | 14 +------------- .../android/vanilla/PlaybackActivity.java | 19 +++++++++++++++++++ 4 files changed, 22 insertions(+), 25 deletions(-) diff --git a/src/ch/blinkenlights/android/vanilla/FullPlaybackActivity.java b/src/ch/blinkenlights/android/vanilla/FullPlaybackActivity.java index 4e8e2d68..94338c8f 100644 --- a/src/ch/blinkenlights/android/vanilla/FullPlaybackActivity.java +++ b/src/ch/blinkenlights/android/vanilla/FullPlaybackActivity.java @@ -162,12 +162,6 @@ public class FullPlaybackActivity extends PlaybackActivity mCoverView = coverView; mSlidingView = findViewById(R.id.sliding_view); - View previousButton = findViewById(R.id.previous); - previousButton.setOnClickListener(this); - mPlayPauseButton = (ImageButton)findViewById(R.id.play_pause); - mPlayPauseButton.setOnClickListener(this); - View nextButton = findViewById(R.id.next); - nextButton.setOnClickListener(this); TableLayout table = (TableLayout)findViewById(R.id.info_table); if (table != null) { @@ -195,12 +189,7 @@ public class FullPlaybackActivity extends PlaybackActivity mFormatView = (TextView)findViewById(R.id.format); mReplayGainView = (TextView)findViewById(R.id.replaygain); - mShuffleButton = (ImageButton)findViewById(R.id.shuffle); - mShuffleButton.setOnClickListener(this); - registerForContextMenu(mShuffleButton); - mEndButton = (ImageButton)findViewById(R.id.end_action); - mEndButton.setOnClickListener(this); - registerForContextMenu(mEndButton); + bindControlButtons(); setControlsVisible(settings.getBoolean(PrefKeys.VISIBLE_CONTROLS, PrefDefaults.VISIBLE_CONTROLS)); setExtraInfoVisible(settings.getBoolean(PrefKeys.VISIBLE_EXTRA_INFO, PrefDefaults.VISIBLE_EXTRA_INFO)); diff --git a/src/ch/blinkenlights/android/vanilla/LibraryActivity.java b/src/ch/blinkenlights/android/vanilla/LibraryActivity.java index 58df3551..358f400d 100644 --- a/src/ch/blinkenlights/android/vanilla/LibraryActivity.java +++ b/src/ch/blinkenlights/android/vanilla/LibraryActivity.java @@ -200,6 +200,7 @@ public class LibraryActivity } loadAlbumIntent(getIntent()); + bindControlButtons(); } @Override diff --git a/src/ch/blinkenlights/android/vanilla/MiniPlaybackActivity.java b/src/ch/blinkenlights/android/vanilla/MiniPlaybackActivity.java index ac0f96ff..bd1e3cc7 100644 --- a/src/ch/blinkenlights/android/vanilla/MiniPlaybackActivity.java +++ b/src/ch/blinkenlights/android/vanilla/MiniPlaybackActivity.java @@ -46,19 +46,7 @@ public class MiniPlaybackActivity extends PlaybackActivity { mCoverView.setOnClickListener(this); mCoverView.setup(mLooper, this, CoverBitmap.STYLE_OVERLAPPING_BOX); - View previousButton = findViewById(R.id.previous); - previousButton.setOnClickListener(this); - mPlayPauseButton = (ImageButton)findViewById(R.id.play_pause); - mPlayPauseButton.setOnClickListener(this); - View nextButton = findViewById(R.id.next); - nextButton.setOnClickListener(this); - - mShuffleButton = (ImageButton)findViewById(R.id.shuffle); - mShuffleButton.setOnClickListener(this); - registerForContextMenu(mShuffleButton); - mEndButton = (ImageButton)findViewById(R.id.end_action); - mEndButton.setOnClickListener(this); - registerForContextMenu(mEndButton); + bindControlButtons(); } @Override diff --git a/src/ch/blinkenlights/android/vanilla/PlaybackActivity.java b/src/ch/blinkenlights/android/vanilla/PlaybackActivity.java index 4876e24a..c0fc3d33 100644 --- a/src/ch/blinkenlights/android/vanilla/PlaybackActivity.java +++ b/src/ch/blinkenlights/android/vanilla/PlaybackActivity.java @@ -305,6 +305,25 @@ public abstract class PlaybackActivity extends Activity return fs_start; } + /** + * Sets up onClick listeners for our common control buttons bar + */ + protected void bindControlButtons() { + View previousButton = findViewById(R.id.previous); + previousButton.setOnClickListener(this); + mPlayPauseButton = (ImageButton)findViewById(R.id.play_pause); + mPlayPauseButton.setOnClickListener(this); + View nextButton = findViewById(R.id.next); + nextButton.setOnClickListener(this); + + mShuffleButton = (ImageButton)findViewById(R.id.shuffle); + mShuffleButton.setOnClickListener(this); + registerForContextMenu(mShuffleButton); + mEndButton = (ImageButton)findViewById(R.id.end_action); + mEndButton.setOnClickListener(this); + registerForContextMenu(mEndButton); + } + /** * Called by PlaybackService to update the current song. */