aboutsummaryrefslogtreecommitdiff
path: root/src/github/daneren2005
diff options
context:
space:
mode:
authordaneren2005 <daneren2005@gmail.com>2013-10-21 16:11:23 -0700
committerdaneren2005 <daneren2005@gmail.com>2013-10-21 16:11:23 -0700
commit0908bdf7ce01e7bf5051d4d43a0ed956c676071e (patch)
tree114cbaaa03b4d8dd69ab217e487daa248debf1d7 /src/github/daneren2005
parent397819fbc4d4c2104c7e7933ef86bba07f19b80c (diff)
downloaddsub-0908bdf7ce01e7bf5051d4d43a0ed956c676071e.tar.gz
dsub-0908bdf7ce01e7bf5051d4d43a0ed956c676071e.tar.bz2
dsub-0908bdf7ce01e7bf5051d4d43a0ed956c676071e.zip
#162 More abstract way to determine activity clicked, obey option to hide chat tab
Diffstat (limited to 'src/github/daneren2005')
-rw-r--r--src/github/daneren2005/dsub/activity/SubsonicActivity.java61
1 files changed, 34 insertions, 27 deletions
diff --git a/src/github/daneren2005/dsub/activity/SubsonicActivity.java b/src/github/daneren2005/dsub/activity/SubsonicActivity.java
index a0effd6b..8eae5d7c 100644
--- a/src/github/daneren2005/dsub/activity/SubsonicActivity.java
+++ b/src/github/daneren2005/dsub/activity/SubsonicActivity.java
@@ -64,6 +64,8 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte
private static final String TAG = SubsonicActivity.class.getSimpleName();
private static ImageLoader IMAGE_LOADER;
protected static String theme;
+ private static String[] drawerItemsDescriptions = ["Home", "Library", "Playlists", "Podcasts", "Chat", "Now Playing", "Settings", "Exit"];
+ private static String[] drawerItems;
private boolean destroyed = false;
protected List<SubsonicFragment> backStack = new ArrayList<SubsonicFragment>();
protected SubsonicFragment currentFragment;
@@ -132,38 +134,43 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte
LayoutInflater layoutInflater = getLayoutInflater();
layoutInflater.inflate(viewId, rootView);
- String[] drawerListItems = getResources().getStringArray(R.array.drawerItems);
+ if(drawerItems == null) {
+ drawerItems = getResources().getStringArray(R.array.drawerItems);
+
+ SharedPreferences prefs = Util.getPreferences(this);
+ // Selectively remove chat listing: [4]
+ if(!prefs.getBoolean(Constants.PREFERENCES_KEY_CHAT_ENABLED, true)) {
+ List<String> tmp = new ArrayList<String>(Arrays.asList(drawerItems));
+ tmp.remove(4);
+ drawerItems = tmp.toArray();
+
+ tmp = new ArrayList<String>(Arrays.asList(drawerItemsDescriptions));
+ tmp.remove(4);
+ drawerItemsDescriptions = tmp.toArray();
+ }
+ }
drawerList = (ListView) findViewById(R.id.left_drawer);
- drawerList.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, drawerListItems));
+ drawerList.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, drawerItems));
drawerList.setOnItemClickListener(new ListView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
- switch(position) {
- case 0:
- startActivity(SubsonicFragmentActivity.class);
- break;
- case 1:
- startFragmentActivity("Artist");
- break;
- case 2:
- startFragmentActivity("Playlist");
- break;
- case 3:
- startFragmentActivity("Podcast");
- break;
- case 4:
- startFragmentActivity("Chat");
- break;
- case 5:
- startActivity(DownloadActivity.class);
- break;
- case 6:
- startActivity(SettingsActivity.class);
- break;
- case 7:
- exit();
- break;
+ if("Home".equals(drawerItemsDescriptions[position]) {
+ startActivity(SubsonicFragmentActivity.class);
+ } else if("Library".equals(drawerItemsDescriptions[position]) {
+ startFragmentActivity("Artist");
+ } else if("Playlists".equals(drawerItemsDescriptions[position]) {
+ startFragmentActivity("Playlist");
+ } else if("Podcasts".equals(drawerItemsDescriptions[position]) {
+ startFragmentActivity("Podcast");
+ } else if("Chat".equals(drawerItemsDescriptions[position]) {
+ startFragmentActivity("Chat");
+ } else if("Now Playing".equals(drawerItemsDescriptions[position]) {
+ startActivity(DownloadActivity.class);
+ } else if("Settings".equals(drawerItemsDescriptions[position]) {
+ startActivity(SettingsActivity.class);
+ } else if("Exit".equals(drawerItemsDescriptions[position]) {
+ exit();
}
}
});