diff options
author | Scott Jackson <daneren2005@gmail.com> | 2012-09-13 21:20:45 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2012-09-13 21:20:45 -0700 |
commit | d0e7ff24e162532daf90176f21059c06ae0f9e84 (patch) | |
tree | bd448785d4ecff9014a0aef4ed1b36ce4c3932d3 /subsonic-android/src | |
parent | 75a688847ca797905106d95bf6f41660c6ed650b (diff) | |
download | dsub-d0e7ff24e162532daf90176f21059c06ae0f9e84.tar.gz dsub-d0e7ff24e162532daf90176f21059c06ae0f9e84.tar.bz2 dsub-d0e7ff24e162532daf90176f21059c06ae0f9e84.zip |
Finished removing AlbumActivities bottom buttons and integrate them into the Action Bar
Diffstat (limited to 'subsonic-android/src')
-rw-r--r-- | subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java | 94 |
1 files changed, 21 insertions, 73 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java index abbfe67b..9d1936ab 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java @@ -57,10 +57,9 @@ public class SelectAlbumActivity extends SubsonicTabActivity { private View footer; private View emptyView; private com.actionbarsherlock.view.MenuItem selectAll; - private Button playLastButton; - private Button pinButton; - private Button unpinButton; - private Button deleteButton; + private com.actionbarsherlock.view.MenuItem cache; + private com.actionbarsherlock.view.MenuItem delete; + private com.actionbarsherlock.view.MenuItem playLast; private Button moreButton; private boolean licenseValid; @@ -88,53 +87,16 @@ public class SelectAlbumActivity extends SubsonicTabActivity { Util.startActivityWithoutTransition(SelectAlbumActivity.this, intent); } else if (entry.isVideo()) { playVideo(entry); - } else { - enableButtons(); } } } }); - playLastButton = (Button) findViewById(R.id.select_album_play_last); - pinButton = (Button) findViewById(R.id.select_album_pin); - unpinButton = (Button) findViewById(R.id.select_album_unpin); - deleteButton = (Button) findViewById(R.id.select_album_delete); moreButton = (Button) footer.findViewById(R.id.select_album_more); emptyView = findViewById(R.id.select_album_empty); - playLastButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - download(true, false, false, false, false); - selectAll(false, false); - } - }); - pinButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - download(true, true, false, false, false); - selectAll(false, false); - } - }); - unpinButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - unpin(); - selectAll(false, false); - } - }); - deleteButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - delete(); - selectAll(false, false); - } - }); - registerForContextMenu(entryList); - enableButtons(); - String id = getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_ID); String name = getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_NAME); String playlistId = getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_PLAYLIST_ID); @@ -157,6 +119,9 @@ public class SelectAlbumActivity extends SubsonicTabActivity { com.actionbarsherlock.view.MenuInflater inflater = getSupportMenuInflater(); inflater.inflate(R.menu.select_album, menu); selectAll = menu.findItem(R.id.menu_select); + cache = menu.findItem(R.id.menu_cache); + delete = menu.findItem(R.id.menu_delete); + playLast = menu.findItem(R.id.menu_play_last); return true; } @@ -167,6 +132,10 @@ public class SelectAlbumActivity extends SubsonicTabActivity { case R.id.menu_play_now: playNow(false); return true; + case R.id.menu_play_last: + download(true, false, false, false, false); + selectAll(false, false); + return true; case R.id.menu_shuffle: playNow(true); return true; @@ -176,6 +145,14 @@ public class SelectAlbumActivity extends SubsonicTabActivity { case R.id.menu_refresh: refresh(); return true; + case R.id.menu_cache: + download(true, true, false, false, false); + selectAll(false, false); + return true; + case R.id.menu_delete: + delete(); + selectAll(false, false); + return true; case R.id.menu_exit: intent = new Intent(this, MainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); @@ -378,34 +355,6 @@ public class SelectAlbumActivity extends SubsonicTabActivity { : R.string.select_album_n_unselected; Util.toast(this, getString(toastResId, selectedCount)); } - - enableButtons(); - } - - private void enableButtons() { - if (getDownloadService() == null) { - return; - } - - List<MusicDirectory.Entry> selection = getSelectedSongs(); - boolean enabled = !selection.isEmpty(); - boolean unpinEnabled = false; - boolean deleteEnabled = false; - - for (MusicDirectory.Entry song : selection) { - DownloadFile downloadFile = getDownloadService().forSong(song); - if (downloadFile.isCompleteFileAvailable()) { - deleteEnabled = true; - } - if (downloadFile.isSaved()) { - unpinEnabled = true; - } - } - - playLastButton.setEnabled(enabled); - pinButton.setEnabled(enabled && !Util.isOffline(this)); - unpinButton.setEnabled(unpinEnabled); - deleteButton.setEnabled(deleteEnabled); } private List<MusicDirectory.Entry> getSelectedSongs() { @@ -556,12 +505,11 @@ public class SelectAlbumActivity extends SubsonicTabActivity { if (songCount > 0) { getImageLoader().loadImage(getSupportActionBar(), entries.get(0)); entryList.addFooterView(footer); - playLastButton.setVisibility(View.VISIBLE); - pinButton.setVisibility(View.VISIBLE); - unpinButton.setVisibility(View.VISIBLE); - deleteButton.setVisibility(View.VISIBLE); } else { selectAll.setVisible(false); + cache.setVisible(false); + delete.setVisible(false); + playLast.setVisible(false); } emptyView.setVisibility(entries.isEmpty() ? View.VISIBLE : View.GONE); |