aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2013-04-10 19:26:18 -0700
committerScott Jackson <daneren2005@gmail.com>2013-04-10 19:26:18 -0700
commit1f8d2d2a0e600e502fea109be825034bc4725a31 (patch)
tree85a8483578a9b23091009f2bb032f5b0efaa7af7
parente6fa8b0d0c201c8c788f9f0c9d8ecea71948bafd (diff)
downloaddsub-1f8d2d2a0e600e502fea109be825034bc4725a31.tar.gz
dsub-1f8d2d2a0e600e502fea109be825034bc4725a31.tar.bz2
dsub-1f8d2d2a0e600e502fea109be825034bc4725a31.zip
Use a centrally defined replace function
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/fragments/MainFragment.java6
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/fragments/SelectArtistFragment.java5
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java5
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java5
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicTabFragment.java15
5 files changed, 16 insertions, 20 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/fragments/MainFragment.java b/subsonic-android/src/github/daneren2005/dsub/fragments/MainFragment.java
index e9134257..8f3682bd 100644
--- a/subsonic-android/src/github/daneren2005/dsub/fragments/MainFragment.java
+++ b/subsonic-android/src/github/daneren2005/dsub/fragments/MainFragment.java
@@ -7,7 +7,6 @@ import android.net.Uri;
import android.os.Bundle;
import android.os.StatFs;
import android.preference.PreferenceManager;
-import android.support.v4.app.FragmentTransaction;
import android.view.ContextMenu;
import android.view.LayoutInflater;
import android.view.View;
@@ -234,10 +233,7 @@ public class MainFragment extends LibraryFunctionsFragment {
args.putInt(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_OFFSET, 0);
fragment.setArguments(args);
- final FragmentTransaction trans = getFragmentManager().beginTransaction();
- trans.replace(R.id.home_layout, fragment);
- trans.addToBackStack(null);
- trans.commit();
+ replaceFragment(fragment, R.id.home_layout);
}
private void showAboutDialog() {
diff --git a/subsonic-android/src/github/daneren2005/dsub/fragments/SelectArtistFragment.java b/subsonic-android/src/github/daneren2005/dsub/fragments/SelectArtistFragment.java
index cf53862b..0efac370 100644
--- a/subsonic-android/src/github/daneren2005/dsub/fragments/SelectArtistFragment.java
+++ b/subsonic-android/src/github/daneren2005/dsub/fragments/SelectArtistFragment.java
@@ -161,10 +161,7 @@ public class SelectArtistFragment extends LibraryFunctionsFragment implements Ad
args.putString(Constants.INTENT_EXTRA_NAME_NAME, artist.getName());
fragment.setArguments(args);
- final FragmentTransaction trans = getFragmentManager().beginTransaction();
- trans.replace(R.id.select_artist_layout, fragment);
- trans.addToBackStack(null);
- trans.commit();
+ replaceFragment(fragment, R.id.select_artist_layout);
}
}
diff --git a/subsonic-android/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/subsonic-android/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
index ea730db7..cba310a3 100644
--- a/subsonic-android/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
+++ b/subsonic-android/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
@@ -186,10 +186,7 @@ public class SelectDirectoryFragment extends LibraryFunctionsFragment implements
args.putString(Constants.INTENT_EXTRA_NAME_NAME, entry.getTitle());
fragment.setArguments(args);
- final FragmentTransaction trans = getFragmentManager().beginTransaction();
- trans.replace(R.id.select_album_layout, fragment);
- trans.addToBackStack(null);
- trans.commit();
+ replaceFragment(fragment, R.id.select_album_layout);
} else if (entry.isVideo()) {
if(entryExists(entry)) {
playExternalPlayer(entry);
diff --git a/subsonic-android/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java b/subsonic-android/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java
index 67e26b9a..35684be9 100644
--- a/subsonic-android/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java
+++ b/subsonic-android/src/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java
@@ -148,10 +148,7 @@ public class SelectPlaylistFragment extends LibraryFunctionsFragment implements
args.putString(Constants.INTENT_EXTRA_NAME_PLAYLIST_NAME, playlist.getName());
fragment.setArguments(args);
- FragmentTransaction trans = getFragmentManager().beginTransaction();
- trans.replace(R.id.select_playlist_layout, fragment);
- trans.addToBackStack(null);
- trans.commit();
+ replaceFragment(fragment, R.id.select_playlist_layout);
}
@Override
diff --git a/subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicTabFragment.java b/subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicTabFragment.java
index f3e283e0..639284b8 100644
--- a/subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicTabFragment.java
+++ b/subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicTabFragment.java
@@ -22,6 +22,7 @@ import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
+import android.support.v4.app.FragmentTransaction;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
@@ -80,6 +81,16 @@ public class SubsonicTabFragment extends SherlockFragment {
protected void refresh() {
}
+
+ public void replaceFragment(SubsonicTabFragment fragment, int id) {
+ this.setPrimaryFragment(false);
+ fragment.setPrimaryFragment(true);
+
+ FragmentTransaction trans = getFragmentManager().beginTransaction();
+ trans.replace(id, fragment);
+ trans.addToBackStack(null);
+ trans.commit();
+ }
protected void exit() {
context.stopService(new Intent(context, DownloadServiceImpl.class));
@@ -108,13 +119,11 @@ public class SubsonicTabFragment extends SherlockFragment {
}
public void setPrimaryFragment(boolean primary) {
+ primaryFragment = primary;
if(primary) {
- primaryFragment = true;
if(context != null) {
context.setTitle(title);
}
- } else {
- primaryFragment = false;
}
}