summaryrefslogtreecommitdiffstats
path: root/core/java/android
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/transition/Fade.java23
-rw-r--r--core/java/android/transition/TransitionInflater.java10
-rw-r--r--core/java/android/transition/Visibility.java37
3 files changed, 55 insertions, 15 deletions
diff --git a/core/java/android/transition/Fade.java b/core/java/android/transition/Fade.java
index e70dc0c..71559da 100644
--- a/core/java/android/transition/Fade.java
+++ b/core/java/android/transition/Fade.java
@@ -63,23 +63,23 @@ public class Fade extends Visibility {
/**
* Fading mode used in {@link #Fade(int)} to make the transition
* operate on targets that are appearing. Maybe be combined with
- * {@link #OUT} to fade both in and out.
+ * {@link #OUT} to fade both in and out. Equivalent to
+ * {@link Visibility#IN}.
*/
- public static final int IN = 0x1;
+ public static final int IN = Visibility.IN;
+
/**
* Fading mode used in {@link #Fade(int)} to make the transition
* operate on targets that are disappearing. Maybe be combined with
- * {@link #IN} to fade both in and out.
+ * {@link #IN} to fade both in and out. Equivalent to
+ * {@link Visibility#OUT}.
*/
- public static final int OUT = 0x2;
-
- private int mFadingMode;
+ public static final int OUT = Visibility.OUT;
/**
* Constructs a Fade transition that will fade targets in and out.
*/
public Fade() {
- this(IN | OUT);
}
/**
@@ -90,7 +90,7 @@ public class Fade extends Visibility {
* {@link #IN} and {@link #OUT}.
*/
public Fade(int fadingMode) {
- mFadingMode = fadingMode;
+ setMode(fadingMode);
}
/**
@@ -115,9 +115,6 @@ public class Fade extends Visibility {
public Animator onAppear(ViewGroup sceneRoot, View view,
TransitionValues startValues,
TransitionValues endValues) {
- if ((mFadingMode & IN) != IN || endValues == null) {
- return null;
- }
if (DBG) {
View startView = (startValues != null) ? startValues.view : null;
Log.d(LOG_TAG, "Fade.onAppear: startView, startVis, endView, endVis = " +
@@ -129,10 +126,6 @@ public class Fade extends Visibility {
@Override
public Animator onDisappear(ViewGroup sceneRoot, final View view, TransitionValues startValues,
TransitionValues endValues) {
- if ((mFadingMode & OUT) != OUT) {
- return null;
- }
-
return createAnimation(view, 1, 0);
}
diff --git a/core/java/android/transition/TransitionInflater.java b/core/java/android/transition/TransitionInflater.java
index 58d743c..9e43201 100644
--- a/core/java/android/transition/TransitionInflater.java
+++ b/core/java/android/transition/TransitionInflater.java
@@ -349,6 +349,16 @@ public class TransitionInflater {
transition.setMatchOrder(parseMatchOrder(matchOrder));
}
a.recycle();
+ if (transition instanceof Visibility) {
+ a = mContext.obtainStyledAttributes(attrs,
+ com.android.internal.R.styleable.VisibilityTransition);
+ int mode = a.getInt(
+ com.android.internal.R.styleable.VisibilityTransition_visibilityMode, 0);
+ a.recycle();
+ if (mode != 0) {
+ ((Visibility)transition).setMode(mode);
+ }
+ }
return transition;
}
diff --git a/core/java/android/transition/Visibility.java b/core/java/android/transition/Visibility.java
index 947e1a7..aa9f04e 100644
--- a/core/java/android/transition/Visibility.java
+++ b/core/java/android/transition/Visibility.java
@@ -43,6 +43,20 @@ public abstract class Visibility extends Transition {
private static final String PROPNAME_PARENT = "android:visibility:parent";
private static final String PROPNAME_SCREEN_LOCATION = "android:visibility:screenLocation";
+ /**
+ * Mode used in {@link #setMode(int)} to make the transition
+ * operate on targets that are appearing. Maybe be combined with
+ * {@link #OUT} to target Visibility changes both in and out.
+ */
+ public static final int IN = 0x1;
+
+ /**
+ * Mode used in {@link #setMode(int)} to make the transition
+ * operate on targets that are disappearing. Maybe be combined with
+ * {@link #IN} to target Visibility changes both in and out.
+ */
+ public static final int OUT = 0x2;
+
private static final String[] sTransitionProperties = {
PROPNAME_VISIBILITY,
PROPNAME_PARENT,
@@ -58,6 +72,22 @@ public abstract class Visibility extends Transition {
ViewGroup endParent;
}
+ private int mMode = IN | OUT;
+
+ /**
+ * Changes the transition to support appearing and/or disappearing Views, depending
+ * on <code>mode</code>.
+ *
+ * @param mode The behavior supported by this transition, a combination of
+ * {@link #IN} and {@link #OUT}.
+ */
+ public void setMode(int mode) {
+ if ((mode & ~(IN | OUT)) != 0) {
+ throw new IllegalArgumentException("Only IN and OUT flags are allowed");
+ }
+ mMode = mode;
+ }
+
@Override
public String[] getTransitionProperties() {
return sTransitionProperties;
@@ -200,6 +230,9 @@ public abstract class Visibility extends Transition {
public Animator onAppear(ViewGroup sceneRoot,
TransitionValues startValues, int startVisibility,
TransitionValues endValues, int endVisibility) {
+ if ((mMode & IN) != IN || endValues == null) {
+ return null;
+ }
return onAppear(sceneRoot, endValues.view, startValues, endValues);
}
@@ -260,6 +293,10 @@ public abstract class Visibility extends Transition {
public Animator onDisappear(ViewGroup sceneRoot,
TransitionValues startValues, int startVisibility,
TransitionValues endValues, int endVisibility) {
+ if ((mMode & OUT) != OUT) {
+ return null;
+ }
+
View startView = (startValues != null) ? startValues.view : null;
View endView = (endValues != null) ? endValues.view : null;
View overlayView = null;