aboutsummaryrefslogtreecommitdiff
path: root/src/github/daneren2005
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2013-10-21 19:46:21 -0700
committerScott Jackson <daneren2005@gmail.com>2013-10-21 19:46:21 -0700
commit2486cd6f72042052dfb45697d11e558e345c302a (patch)
treee1e49e84230bd1a47d7f1583a686450a29bae745 /src/github/daneren2005
parenta7202d11d8cb4831e0ce3ea24756f1d32ea4f71a (diff)
downloaddsub-2486cd6f72042052dfb45697d11e558e345c302a.tar.gz
dsub-2486cd6f72042052dfb45697d11e558e345c302a.tar.bz2
dsub-2486cd6f72042052dfb45697d11e558e345c302a.zip
Fix some issues with new drawer fragments
Diffstat (limited to 'src/github/daneren2005')
-rw-r--r--src/github/daneren2005/dsub/activity/SubsonicActivity.java33
-rw-r--r--src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java6
-rw-r--r--src/github/daneren2005/dsub/fragments/MainFragment.java1
3 files changed, 25 insertions, 15 deletions
diff --git a/src/github/daneren2005/dsub/activity/SubsonicActivity.java b/src/github/daneren2005/dsub/activity/SubsonicActivity.java
index 8eae5d7c..da9c25a6 100644
--- a/src/github/daneren2005/dsub/activity/SubsonicActivity.java
+++ b/src/github/daneren2005/dsub/activity/SubsonicActivity.java
@@ -20,6 +20,7 @@ package github.daneren2005.dsub.activity;
import android.content.Context;
import android.content.Intent;
+import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.media.AudioManager;
import android.os.Build;
@@ -58,13 +59,14 @@ import github.daneren2005.dsub.util.Util;
import java.io.File;
import java.io.PrintWriter;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
public class SubsonicActivity extends ActionBarActivity implements OnItemSelectedListener {
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[] 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>();
@@ -142,11 +144,11 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte
if(!prefs.getBoolean(Constants.PREFERENCES_KEY_CHAT_ENABLED, true)) {
List<String> tmp = new ArrayList<String>(Arrays.asList(drawerItems));
tmp.remove(4);
- drawerItems = tmp.toArray();
+ drawerItems = tmp.toArray(new String[0]);
tmp = new ArrayList<String>(Arrays.asList(drawerItemsDescriptions));
tmp.remove(4);
- drawerItemsDescriptions = tmp.toArray();
+ drawerItemsDescriptions = tmp.toArray(new String[0]);
}
}
drawerList = (ListView) findViewById(R.id.left_drawer);
@@ -155,21 +157,21 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte
drawerList.setOnItemClickListener(new ListView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
- if("Home".equals(drawerItemsDescriptions[position]) {
- startActivity(SubsonicFragmentActivity.class);
- } else if("Library".equals(drawerItemsDescriptions[position]) {
+ if("Home".equals(drawerItemsDescriptions[position])) {
+ startFragmentActivity("");
+ } else if("Library".equals(drawerItemsDescriptions[position])) {
startFragmentActivity("Artist");
- } else if("Playlists".equals(drawerItemsDescriptions[position]) {
+ } else if("Playlists".equals(drawerItemsDescriptions[position])) {
startFragmentActivity("Playlist");
- } else if("Podcasts".equals(drawerItemsDescriptions[position]) {
+ } else if("Podcasts".equals(drawerItemsDescriptions[position])) {
startFragmentActivity("Podcast");
- } else if("Chat".equals(drawerItemsDescriptions[position]) {
+ } else if("Chat".equals(drawerItemsDescriptions[position])) {
startFragmentActivity("Chat");
- } else if("Now Playing".equals(drawerItemsDescriptions[position]) {
+ } else if("Now Playing".equals(drawerItemsDescriptions[position])) {
startActivity(DownloadActivity.class);
- } else if("Settings".equals(drawerItemsDescriptions[position]) {
+ } else if("Settings".equals(drawerItemsDescriptions[position])) {
startActivity(SettingsActivity.class);
- } else if("Exit".equals(drawerItemsDescriptions[position]) {
+ } else if("Exit".equals(drawerItemsDescriptions[position])) {
exit();
}
}
@@ -287,12 +289,15 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte
if(this.getClass() != SubsonicFragmentActivity.class) {
finish();
}
+ drawer.closeDrawers();
}
public void startFragmentActivity(String fragmentType) {
Intent intent = new Intent();
intent.setClass(SubsonicActivity.this, SubsonicFragmentActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- intent.putExtra(Constants.INTENT_EXTRA_FRAGMENT_TYPE, fragmentType);
+ if(!"".equals(fragmentType)) {
+ intent.putExtra(Constants.INTENT_EXTRA_FRAGMENT_TYPE, fragmentType);
+ }
startActivity(intent);
finish();
}
@@ -349,7 +354,7 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte
recreateSpinner();
}
- private void recreateSpinner() {
+ protected void recreateSpinner() {
if(backStack.size() > 0) {
spinnerAdapter.clear();
for(int i = 0; i < backStack.size(); i++) {
diff --git a/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java b/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java
index 6d1231ca..adb0eb62 100644
--- a/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java
+++ b/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java
@@ -25,6 +25,8 @@ import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentTransaction;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
@@ -278,8 +280,9 @@ public class SubsonicFragmentActivity extends SubsonicActivity {
// Clear existing stack
for(int i = backStack.size() - 1; i >= 0; i--) {
- trans.remove((Fragment) backStack.get(i));
+ trans.remove(backStack.get(i));
}
+ trans.remove(currentFragment);
backStack.clear();
// Create new stack
@@ -291,6 +294,7 @@ public class SubsonicFragmentActivity extends SubsonicActivity {
trans.commit();
supportInvalidateOptionsMenu();
recreateSpinner();
+ drawer.closeDrawers();
}
private SubsonicFragment getNewFragment(String fragmentType) {
diff --git a/src/github/daneren2005/dsub/fragments/MainFragment.java b/src/github/daneren2005/dsub/fragments/MainFragment.java
index e1bd8db6..01dee95e 100644
--- a/src/github/daneren2005/dsub/fragments/MainFragment.java
+++ b/src/github/daneren2005/dsub/fragments/MainFragment.java
@@ -185,6 +185,7 @@ public class MainFragment extends SubsonicFragment {
}
}
});
+ setTitle(R.string.common_appname);
}
private void setActiveServer(int instance) {