Merge "Supress layout requests while a LayoutTransition is running." into honeycomb
This commit is contained in:
38038
api/11.xml
38038
api/11.xml
File diff suppressed because it is too large
Load Diff
@@ -20511,6 +20511,28 @@
|
|||||||
<parameter name="child" type="android.view.View">
|
<parameter name="child" type="android.view.View">
|
||||||
</parameter>
|
</parameter>
|
||||||
</method>
|
</method>
|
||||||
|
<method name="isChangingLayout"
|
||||||
|
return="boolean"
|
||||||
|
abstract="false"
|
||||||
|
native="false"
|
||||||
|
synchronized="false"
|
||||||
|
static="false"
|
||||||
|
final="false"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</method>
|
||||||
|
<method name="isRunning"
|
||||||
|
return="boolean"
|
||||||
|
abstract="false"
|
||||||
|
native="false"
|
||||||
|
synchronized="false"
|
||||||
|
static="false"
|
||||||
|
final="false"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</method>
|
||||||
<method name="removeChild"
|
<method name="removeChild"
|
||||||
return="void"
|
return="void"
|
||||||
abstract="false"
|
abstract="false"
|
||||||
@@ -216454,7 +216476,7 @@
|
|||||||
native="false"
|
native="false"
|
||||||
synchronized="false"
|
synchronized="false"
|
||||||
static="false"
|
static="false"
|
||||||
final="true"
|
final="false"
|
||||||
deprecated="not deprecated"
|
deprecated="not deprecated"
|
||||||
visibility="public"
|
visibility="public"
|
||||||
>
|
>
|
||||||
@@ -221085,6 +221107,25 @@
|
|||||||
visibility="public"
|
visibility="public"
|
||||||
>
|
>
|
||||||
</method>
|
</method>
|
||||||
|
<method name="layout"
|
||||||
|
return="void"
|
||||||
|
abstract="false"
|
||||||
|
native="false"
|
||||||
|
synchronized="false"
|
||||||
|
static="false"
|
||||||
|
final="true"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
<parameter name="l" type="int">
|
||||||
|
</parameter>
|
||||||
|
<parameter name="t" type="int">
|
||||||
|
</parameter>
|
||||||
|
<parameter name="r" type="int">
|
||||||
|
</parameter>
|
||||||
|
<parameter name="b" type="int">
|
||||||
|
</parameter>
|
||||||
|
</method>
|
||||||
<method name="measureChild"
|
<method name="measureChild"
|
||||||
return="void"
|
return="void"
|
||||||
abstract="false"
|
abstract="false"
|
||||||
|
|||||||
@@ -553,9 +553,6 @@ public class LayoutTransition {
|
|||||||
// Make a copy of the appropriate animation
|
// Make a copy of the appropriate animation
|
||||||
final Animator anim = baseAnimator.clone();
|
final Animator anim = baseAnimator.clone();
|
||||||
|
|
||||||
// Cache the animation in case we need to cancel it later
|
|
||||||
currentChangingAnimations.put(child, anim);
|
|
||||||
|
|
||||||
// Set the target object for the animation
|
// Set the target object for the animation
|
||||||
anim.setTarget(child);
|
anim.setTarget(child);
|
||||||
|
|
||||||
@@ -586,6 +583,9 @@ public class LayoutTransition {
|
|||||||
anim.setStartDelay(startDelay);
|
anim.setStartDelay(startDelay);
|
||||||
anim.setDuration(duration);
|
anim.setDuration(duration);
|
||||||
|
|
||||||
|
// Cache the animation in case we need to cancel it later
|
||||||
|
currentChangingAnimations.put(child, anim);
|
||||||
|
|
||||||
if (anim instanceof ObjectAnimator) {
|
if (anim instanceof ObjectAnimator) {
|
||||||
((ObjectAnimator) anim).setCurrentPlayTime(0);
|
((ObjectAnimator) anim).setCurrentPlayTime(0);
|
||||||
}
|
}
|
||||||
@@ -657,6 +657,27 @@ public class LayoutTransition {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if animations are running which animate layout-related properties. This
|
||||||
|
* essentially means that either CHANGE_APPEARING or CHANGE_DISAPPEARING animations
|
||||||
|
* are running, since these animations operate on layout-related properties.
|
||||||
|
*
|
||||||
|
* @return true if CHANGE_APPEARING or CHANGE_DISAPPEARING animations are currently
|
||||||
|
* running.
|
||||||
|
*/
|
||||||
|
public boolean isChangingLayout() {
|
||||||
|
return (currentChangingAnimations.size() > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if any of the animations in this transition are currently running.
|
||||||
|
*
|
||||||
|
* @return true if any animations in the transition are running.
|
||||||
|
*/
|
||||||
|
public boolean isRunning() {
|
||||||
|
return (currentChangingAnimations.size() > 0 || currentVisibilityAnimations.size() > 0);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method runs the animation that makes an added item appear.
|
* This method runs the animation that makes an added item appear.
|
||||||
*
|
*
|
||||||
@@ -842,28 +863,31 @@ public class LayoutTransition {
|
|||||||
public interface TransitionListener {
|
public interface TransitionListener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This event is sent to listeners when an APPEARING or DISAPPEARING transition
|
* This event is sent to listeners when any type of transition animation begins.
|
||||||
* begins.
|
|
||||||
*
|
*
|
||||||
* @param transition The LayoutTransition sending out the event.
|
* @param transition The LayoutTransition sending out the event.
|
||||||
* @param container The ViewGroup on which the transition is playing.
|
* @param container The ViewGroup on which the transition is playing.
|
||||||
* @param view The View object being added or removed from its parent.
|
* @param view The View object being affected by the transition animation.
|
||||||
* @param transitionType The type of transition that is beginning, either
|
* @param transitionType The type of transition that is beginning,
|
||||||
* {@link android.animation.LayoutTransition#APPEARING} or
|
* {@link android.animation.LayoutTransition#APPEARING},
|
||||||
* {@link android.animation.LayoutTransition#DISAPPEARING}.
|
* {@link android.animation.LayoutTransition#DISAPPEARING},
|
||||||
|
* {@link android.animation.LayoutTransition#CHANGE_APPEARING}, or
|
||||||
|
* {@link android.animation.LayoutTransition#CHANGE_DISAPPEARING}.
|
||||||
*/
|
*/
|
||||||
public void startTransition(LayoutTransition transition, ViewGroup container,
|
public void startTransition(LayoutTransition transition, ViewGroup container,
|
||||||
View view, int transitionType);
|
View view, int transitionType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This event is sent to listeners when an APPEARING or DISAPPEARING transition ends.
|
* This event is sent to listeners when any type of transition animation ends.
|
||||||
*
|
*
|
||||||
* @param transition The LayoutTransition sending out the event.
|
* @param transition The LayoutTransition sending out the event.
|
||||||
* @param container The ViewGroup on which the transition is playing.
|
* @param container The ViewGroup on which the transition is playing.
|
||||||
* @param view The View object being added or removed from its parent.
|
* @param view The View object being affected by the transition animation.
|
||||||
* @param transitionType The type of transition that is ending, either
|
* @param transitionType The type of transition that is ending,
|
||||||
* {@link android.animation.LayoutTransition#APPEARING} or
|
* {@link android.animation.LayoutTransition#APPEARING},
|
||||||
* {@link android.animation.LayoutTransition#DISAPPEARING}.
|
* {@link android.animation.LayoutTransition#DISAPPEARING},
|
||||||
|
* {@link android.animation.LayoutTransition#CHANGE_APPEARING}, or
|
||||||
|
* {@link android.animation.LayoutTransition#CHANGE_DISAPPEARING}.
|
||||||
*/
|
*/
|
||||||
public void endTransition(LayoutTransition transition, ViewGroup container,
|
public void endTransition(LayoutTransition transition, ViewGroup container,
|
||||||
View view, int transitionType);
|
View view, int transitionType);
|
||||||
|
|||||||
@@ -8883,11 +8883,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
|
|||||||
* (The first is measuring). In this phase, each parent calls
|
* (The first is measuring). In this phase, each parent calls
|
||||||
* layout on all of its children to position them.
|
* layout on all of its children to position them.
|
||||||
* This is typically done using the child measurements
|
* This is typically done using the child measurements
|
||||||
* that were stored in the measure pass().
|
* that were stored in the measure pass().</p>
|
||||||
*
|
*
|
||||||
|
* <p>Derived classes should not override this method.
|
||||||
* Derived classes with children should override
|
* Derived classes with children should override
|
||||||
* onLayout. In that method, they should
|
* onLayout. In that method, they should
|
||||||
* call layout on each of their children.
|
* call layout on each of their children.</p>
|
||||||
*
|
*
|
||||||
* @param l Left position, relative to parent
|
* @param l Left position, relative to parent
|
||||||
* @param t Top position, relative to parent
|
* @param t Top position, relative to parent
|
||||||
@@ -8895,7 +8896,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
|
|||||||
* @param b Bottom position, relative to parent
|
* @param b Bottom position, relative to parent
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"unchecked"})
|
@SuppressWarnings({"unchecked"})
|
||||||
public final void layout(int l, int t, int r, int b) {
|
public void layout(int l, int t, int r, int b) {
|
||||||
int oldL = mLeft;
|
int oldL = mLeft;
|
||||||
int oldT = mTop;
|
int oldT = mTop;
|
||||||
int oldB = mBottom;
|
int oldB = mBottom;
|
||||||
|
|||||||
@@ -318,6 +318,9 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
|
|||||||
private View[] mChildren;
|
private View[] mChildren;
|
||||||
// Number of valid children in the mChildren array, the rest should be null or not
|
// Number of valid children in the mChildren array, the rest should be null or not
|
||||||
// considered as children
|
// considered as children
|
||||||
|
|
||||||
|
private boolean mLayoutSuppressed = false;
|
||||||
|
|
||||||
private int mChildrenCount;
|
private int mChildrenCount;
|
||||||
|
|
||||||
private static final int ARRAY_INITIAL_CAPACITY = 12;
|
private static final int ARRAY_INITIAL_CAPACITY = 12;
|
||||||
@@ -1828,6 +1831,9 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
|
|||||||
// first send it an ACTION_CANCEL motion event.
|
// first send it an ACTION_CANCEL motion event.
|
||||||
cancelAndClearTouchTargets(null);
|
cancelAndClearTouchTargets(null);
|
||||||
|
|
||||||
|
// In case view is detached while transition is running
|
||||||
|
mLayoutSuppressed = false;
|
||||||
|
|
||||||
final int count = mChildrenCount;
|
final int count = mChildrenCount;
|
||||||
final View[] children = mChildren;
|
final View[] children = mChildren;
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
@@ -3618,6 +3624,19 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
|
|||||||
(mParent == null || mParent.getChildVisibleRect(this, r, offset));
|
(mParent == null || mParent.getChildVisibleRect(this, r, offset));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public final void layout(int l, int t, int r, int b) {
|
||||||
|
if (mTransition == null || !mTransition.isChangingLayout()) {
|
||||||
|
super.layout(l, t, r, b);
|
||||||
|
} else {
|
||||||
|
// record the fact that we noop'd it; request layout when transition finishes
|
||||||
|
mLayoutSuppressed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@@ -4306,6 +4325,10 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
|
|||||||
@Override
|
@Override
|
||||||
public void endTransition(LayoutTransition transition, ViewGroup container,
|
public void endTransition(LayoutTransition transition, ViewGroup container,
|
||||||
View view, int transitionType) {
|
View view, int transitionType) {
|
||||||
|
if (mLayoutSuppressed && !transition.isChangingLayout()) {
|
||||||
|
requestLayout();
|
||||||
|
mLayoutSuppressed = false;
|
||||||
|
}
|
||||||
if (transitionType == LayoutTransition.DISAPPEARING && mTransitioningViews != null) {
|
if (transitionType == LayoutTransition.DISAPPEARING && mTransitioningViews != null) {
|
||||||
endViewTransition(view);
|
endViewTransition(view);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user