aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-09-30 19:50:42 -0700
committerScott Jackson <daneren2005@gmail.com>2014-09-30 19:50:42 -0700
commit474af4f10f6e9a2e3de48b06430404c8ab4d3a6a (patch)
tree8b20037ab38b76d00cd86169af34531b18d6fc0d /src
parentc790cff9edb53d0bed8bef8179af7b19ead58d19 (diff)
downloaddsub-474af4f10f6e9a2e3de48b06430404c8ab4d3a6a.tar.gz
dsub-474af4f10f6e9a2e3de48b06430404c8ab4d3a6a.tar.bz2
dsub-474af4f10f6e9a2e3de48b06430404c8ab4d3a6a.zip
#408 Animate fragment transitions
Diffstat (limited to 'src')
-rw-r--r--src/github/daneren2005/dsub/activity/SubsonicActivity.java12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/github/daneren2005/dsub/activity/SubsonicActivity.java b/src/github/daneren2005/dsub/activity/SubsonicActivity.java
index 6544b685..2865ef8f 100644
--- a/src/github/daneren2005/dsub/activity/SubsonicActivity.java
+++ b/src/github/daneren2005/dsub/activity/SubsonicActivity.java
@@ -45,6 +45,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
+import android.view.animation.AnimationUtils;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
@@ -542,6 +543,7 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte
if(secondaryContainer == null) {
FragmentTransaction trans = getSupportFragmentManager().beginTransaction();
+ trans.setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left, R.anim.enter_from_left, R.anim.exit_to_right);
trans.hide(oldFragment);
trans.add(R.id.fragment_container, fragment, tag + "");
trans.commit();
@@ -555,12 +557,16 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte
if(backStack.size() > 1) {
// Move old right to left if there is a backstack already
SubsonicFragment newLeftFragment = backStack.get(backStack.size() - 1);
+ if(replaceCurrent) {
+ trans.setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left, R.anim.enter_from_left, R.anim.exit_to_right);
+ }
trans.remove(newLeftFragment);
// Only move right to left if replaceCurrent is false
if(!replaceCurrent) {
SubsonicFragment oldLeftFragment = backStack.get(backStack.size() - 2);
oldLeftFragment.setSecondaryFragment(false);
+ trans.setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left, R.anim.enter_from_left, R.anim.exit_to_right);
trans.hide(oldLeftFragment);
// Make sure remove is finished before adding
@@ -568,6 +574,7 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte
getSupportFragmentManager().executePendingTransactions();
trans = getSupportFragmentManager().beginTransaction();
+ trans.setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left, R.anim.enter_from_left, R.anim.exit_to_right);
trans.add(R.id.fragment_container, newLeftFragment, newLeftFragment.getSupportTag() + "");
} else {
backStack.remove(backStack.size() - 1);
@@ -594,6 +601,7 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte
if(secondaryContainer == null) {
FragmentTransaction trans = getSupportFragmentManager().beginTransaction();
+ trans.setCustomAnimations(R.anim.enter_from_left, R.anim.exit_to_right, R.anim.enter_from_right, R.anim.exit_to_left);
trans.remove(oldFrag);
trans.show(currentFragment);
trans.commit();
@@ -601,10 +609,12 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte
FragmentTransaction trans = getSupportFragmentManager().beginTransaction();
// Remove old right fragment
+ trans.setCustomAnimations(R.anim.enter_from_left, R.anim.exit_to_right, R.anim.enter_from_right, R.anim.exit_to_left);
trans.remove(oldFrag);
// Only switch places if there is a backstack, otherwise primary container is correct
if(backStack.size() > 0) {
+ trans.setCustomAnimations(0, 0, 0, 0);
// Add current left fragment to right side
trans.remove(currentFragment);
@@ -613,12 +623,14 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte
getSupportFragmentManager().executePendingTransactions();
trans = getSupportFragmentManager().beginTransaction();
+ trans.setCustomAnimations(R.anim.enter_from_left, R.anim.exit_to_right, R.anim.enter_from_right, R.anim.exit_to_left);
trans.add(R.id.fragment_second_container, currentFragment, currentFragment.getSupportTag() + "");
SubsonicFragment newLeftFragment = backStack.get(backStack.size() - 1);
newLeftFragment.setSecondaryFragment(true);
trans.show(newLeftFragment);
} else {
+ secondaryContainer.startAnimation(AnimationUtils.loadAnimation(this, R.anim.exit_to_right));
secondaryContainer.setVisibility(View.GONE);
}