visibility="public"
>
</constructor>
-<method name="addTransitionListener"
- return="void"
- abstract="false"
- native="false"
- synchronized="false"
- static="false"
- final="false"
- deprecated="not deprecated"
- visibility="public"
->
-<parameter name="listener" type="android.animation.LayoutTransition.TransitionListener">
-</parameter>
-</method>
-<method name="childAdd"
+<method name="addChild"
return="void"
abstract="false"
native="false"
<parameter name="child" type="android.view.View">
</parameter>
</method>
-<method name="childRemove"
+<method name="addTransitionListener"
return="void"
abstract="false"
native="false"
deprecated="not deprecated"
visibility="public"
>
-<parameter name="parent" type="android.view.ViewGroup">
-</parameter>
-<parameter name="child" type="android.view.View">
+<parameter name="listener" type="android.animation.LayoutTransition.TransitionListener">
</parameter>
</method>
<method name="getAnimator"
visibility="public"
>
</method>
+<method name="hideChild"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="parent" type="android.view.ViewGroup">
+</parameter>
+<parameter name="child" type="android.view.View">
+</parameter>
+</method>
+<method name="removeChild"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="parent" type="android.view.ViewGroup">
+</parameter>
+<parameter name="child" type="android.view.View">
+</parameter>
+</method>
<method name="removeTransitionListener"
return="void"
abstract="false"
<parameter name="delay" type="long">
</parameter>
</method>
+<method name="showChild"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="parent" type="android.view.ViewGroup">
+</parameter>
+<parameter name="child" type="android.view.View">
+</parameter>
+</method>
<field name="APPEARING"
type="int"
transient="false"
type="float"
transient="false"
volatile="false"
- value="0.0010f"
+ value="0.001f"
static="true"
final="true"
deprecated="not deprecated"
mChangingAppearingAnim.clone() :
mChangingDisappearingAnim.clone();
+ // Cache the animation in case we need to cancel it later
+ currentAnimations.put(child, anim);
+
// Set the target object for the animation
anim.setTarget(child);
// Add a listener to track layout changes on this view. If we don't get a callback,
// then there's nothing to animate.
- View.OnLayoutChangeListener listener = new View.OnLayoutChangeListener() {
+ final View.OnLayoutChangeListener listener = new View.OnLayoutChangeListener() {
public void onLayoutChange(View v, int left, int top, int right, int bottom,
int oldLeft, int oldTop, int oldRight, int oldBottom) {
- // Cache the animation in case we need to cancel it later
- currentAnimations.put(child, anim);
-
// Tell the animation to extract end values from the changed object
anim.setupEndValues();
anim.setStartDelay(startDelay);
anim.setDuration(duration);
- // Remove the animation from the cache when it ends
- anim.addListener(new AnimatorListenerAdapter() {
- private boolean canceled = false;
- public void onAnimationCancel(Animator animator) {
- // we remove canceled animations immediately, not here
- canceled = true;
- }
- public void onAnimationEnd(Animator animator) {
- if (!canceled) {
- currentAnimations.remove(child);
- }
- }
- });
if (anim instanceof ObjectAnimator) {
((ObjectAnimator) anim).setCurrentPlayTime(0);
}
layoutChangeListenerMap.remove(child);
}
};
+ // Remove the animation from the cache when it ends
+ anim.addListener(new AnimatorListenerAdapter() {
+ private boolean canceled = false;
+ public void onAnimationCancel(Animator animator) {
+ // we remove canceled animations immediately, not here
+ canceled = true;
+ child.removeOnLayoutChangeListener(listener);
+ layoutChangeListenerMap.remove(child);
+ }
+ public void onAnimationEnd(Animator animator) {
+ if (!canceled) {
+ currentAnimations.remove(child);
+ }
+ }
+ });
+
child.addOnLayoutChangeListener(listener);
// cache the listener for later removal
layoutChangeListenerMap.put(child, listener);
anim.setTarget(child);
if (mListeners != null) {
anim.addListener(new AnimatorListenerAdapter() {
- public void onAnimationEnd() {
+ @Override
+ public void onAnimationEnd(Animator anim) {
for (TransitionListener listener : mListeners) {
listener.endTransition(LayoutTransition.this, parent, child, DISAPPEARING);
}
* @param parent The ViewGroup to which the View is being added.
* @param child The View being added to the ViewGroup.
*/
- public void childAdd(ViewGroup parent, View child) {
+ public void addChild(ViewGroup parent, View child) {
if (mListeners != null) {
for (TransitionListener listener : mListeners) {
listener.startTransition(this, parent, child, APPEARING);
}
/**
+ * This method is called by ViewGroup when a child view is about to be added to the
+ * container. This callback starts the process of a transition; we grab the starting
+ * values, listen for changes to all of the children of the container, and start appropriate
+ * animations.
+ *
+ * @param parent The ViewGroup to which the View is being added.
+ * @param child The View being added to the ViewGroup.
+ */
+ public void showChild(ViewGroup parent, View child) {
+ addChild(parent, child);
+ }
+
+ /**
* This method is called by ViewGroup when a child view is about to be removed from the
* container. This callback starts the process of a transition; we grab the starting
* values, listen for changes to all of the children of the container, and start appropriate
* @param parent The ViewGroup from which the View is being removed.
* @param child The View being removed from the ViewGroup.
*/
- public void childRemove(ViewGroup parent, View child) {
+ public void removeChild(ViewGroup parent, View child) {
if (mListeners != null) {
for (TransitionListener listener : mListeners) {
listener.startTransition(this, parent, child, DISAPPEARING);
}
/**
+ * This method is called by ViewGroup when a child view is about to be removed from the
+ * container. This callback starts the process of a transition; we grab the starting
+ * values, listen for changes to all of the children of the container, and start appropriate
+ * animations.
+ *
+ * @param parent The ViewGroup from which the View is being removed.
+ * @param child The View being removed from the ViewGroup.
+ */
+ public void hideChild(ViewGroup parent, View child) {
+ removeChild(parent, child);
+ }
+
+ /**
* Add a listener that will be called when the bounds of the view change due to
* layout processing.
*
}
if ((changed & VISIBILITY_MASK) != 0) {
+ if (mParent instanceof ViewGroup) {
+ ((ViewGroup)mParent).onChildVisibilityChanged(this, (flags & VISIBILITY_MASK));
+ }
dispatchVisibilityChanged(this, (flags & VISIBILITY_MASK));
}
// being animated.
private ArrayList<View> mTransitioningViews;
+ // List of children changing visibility. This is used to potentially keep rendering
+ // views during a transition when they otherwise would have become gone/invisible
+ private ArrayList<View> mVisibilityChangingChildren;
+
public ViewGroup(Context context) {
super(context);
initViewGroup();
}
/**
+ * @hide
+ * @param child
+ * @param visibility
+ */
+ void onChildVisibilityChanged(View child, int visibility) {
+ if (mTransition != null) {
+ if (visibility == VISIBLE) {
+ mTransition.showChild(this, child);
+ } else {
+ mTransition.hideChild(this, child);
+ }
+ if (visibility != VISIBLE) {
+ // Only track this on disappearing views - appearing views are already visible
+ // and don't need special handling during drawChild()
+ if (mVisibilityChangingChildren == null) {
+ mVisibilityChangingChildren = new ArrayList<View>();
+ }
+ mVisibilityChangingChildren.add(child);
+ if (mTransitioningViews != null && mTransitioningViews.contains(child)) {
+ addDisappearingView(child);
+ }
+ }
+ }
+ }
+
+ /**
* {@inheritDoc}
*/
@Override
}
if (mTransition != null) {
- mTransition.childAdd(this, child);
+ mTransition.addChild(this, child);
}
if (!checkLayoutParams(params)) {
private void removeViewInternal(int index, View view) {
if (mTransition != null) {
- mTransition.childRemove(this, view);
+ mTransition.removeChild(this, view);
}
boolean clearChildFocus = false;
final View view = children[i];
if (mTransition != null) {
- mTransition.childRemove(this, view);
+ mTransition.removeChild(this, view);
}
if (view == focused) {
final View view = children[i];
if (mTransition != null) {
- mTransition.childRemove(this, view);
+ mTransition.removeChild(this, view);
}
if (view == focused) {
*/
protected void removeDetachedView(View child, boolean animate) {
if (mTransition != null) {
- mTransition.childRemove(this, child);
+ mTransition.removeChild(this, child);
}
if (child == mFocused) {
final ArrayList<View> disappearingChildren = mDisappearingChildren;
if (disappearingChildren != null && disappearingChildren.contains(view)) {
disappearingChildren.remove(view);
- if (view.mAttachInfo != null) {
- view.dispatchDetachedFromWindow();
- }
- if (view.mParent != null) {
- view.mParent = null;
+ if (mVisibilityChangingChildren != null &&
+ mVisibilityChangingChildren.contains(view)) {
+ mVisibilityChangingChildren.remove(view);
+ } else {
+ if (view.mAttachInfo != null) {
+ view.dispatchDetachedFromWindow();
+ }
+ if (view.mParent != null) {
+ view.mParent = null;
+ }
}
mGroupFlags |= FLAG_INVALIDATE_REQUIRED;
}
long getItemId(int position);
/**
- * Indicated whether the item ids are stable across changes to the
+ * Indicates whether the item ids are stable across changes to the
* underlying data.
*
* @return True if the same id always refers to the same object.
int mItemCount;
/**
- * The number of items in the adapter before a data changed event occured.
+ * The number of items in the adapter before a data changed event occurred.
*/
int mOldItemCount;
/**
* @return The number of items owned by the Adapter associated with this
* AdapterView. (This is the number of data items, which may be
- * larger than the number of visible view.)
+ * larger than the number of visible views.)
*/
@ViewDebug.CapturedViewProperty
public int getCount() {