am 6cab6005: Merge "Make detachViewFromParent more robust" into jb-mr1-dev
* commit '6cab6005a8746bdf86fd98a2a004f08d9473a445': Make detachViewFromParent more robust
This commit is contained in:
@@ -25,9 +25,12 @@ import java.util.ArrayList;
|
|||||||
* An implementation of display list for OpenGL ES 2.0.
|
* An implementation of display list for OpenGL ES 2.0.
|
||||||
*/
|
*/
|
||||||
class GLES20DisplayList extends DisplayList {
|
class GLES20DisplayList extends DisplayList {
|
||||||
// These lists ensure that any Bitmaps recorded by a DisplayList are kept alive as long
|
// These lists ensure that any Bitmaps and DisplayLists recorded by a DisplayList are kept
|
||||||
// as the DisplayList is alive. The Bitmaps are populated by the GLES20RecordingCanvas.
|
// alive as long as the DisplayList is alive. The Bitmap and DisplayList lists
|
||||||
|
// are populated by the GLES20RecordingCanvas during appropriate drawing calls and are
|
||||||
|
// cleared at the start of a new drawing frame or when the view is detached from the window.
|
||||||
final ArrayList<Bitmap> mBitmaps = new ArrayList<Bitmap>(5);
|
final ArrayList<Bitmap> mBitmaps = new ArrayList<Bitmap>(5);
|
||||||
|
final ArrayList<DisplayList> mChildDisplayLists = new ArrayList<DisplayList>();
|
||||||
|
|
||||||
private GLES20RecordingCanvas mCanvas;
|
private GLES20RecordingCanvas mCanvas;
|
||||||
private boolean mValid;
|
private boolean mValid;
|
||||||
@@ -79,6 +82,7 @@ class GLES20DisplayList extends DisplayList {
|
|||||||
public void clear() {
|
public void clear() {
|
||||||
if (!mValid) {
|
if (!mValid) {
|
||||||
mBitmaps.clear();
|
mBitmaps.clear();
|
||||||
|
mChildDisplayLists.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ class GLES20RecordingCanvas extends GLES20Canvas implements Poolable<GLES20Recor
|
|||||||
|
|
||||||
void start() {
|
void start() {
|
||||||
mDisplayList.mBitmaps.clear();
|
mDisplayList.mBitmaps.clear();
|
||||||
|
mDisplayList.mChildDisplayLists.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
int end(int nativeDisplayList) {
|
int end(int nativeDisplayList) {
|
||||||
@@ -155,6 +156,13 @@ class GLES20RecordingCanvas extends GLES20Canvas implements Poolable<GLES20Recor
|
|||||||
recordShaderBitmap(paint);
|
recordShaderBitmap(paint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int drawDisplayList(DisplayList displayList, Rect dirty, int flags) {
|
||||||
|
int status = super.drawDisplayList(displayList, dirty, flags);
|
||||||
|
mDisplayList.mChildDisplayLists.add(displayList);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawLine(float startX, float startY, float stopX, float stopY, Paint paint) {
|
public void drawLine(float startX, float startY, float stopX, float stopY, Paint paint) {
|
||||||
super.drawLine(startX, startY, stopX, stopY, paint);
|
super.drawLine(startX, startY, stopX, stopY, paint);
|
||||||
|
|||||||
@@ -3806,6 +3806,13 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
|
|||||||
/**
|
/**
|
||||||
* Finishes the removal of a detached view. This method will dispatch the detached from
|
* Finishes the removal of a detached view. This method will dispatch the detached from
|
||||||
* window event and notify the hierarchy change listener.
|
* window event and notify the hierarchy change listener.
|
||||||
|
* <p>
|
||||||
|
* This method is intended to be lightweight and makes no assumptions about whether the
|
||||||
|
* parent or child should be redrawn. Proper use of this method will include also making
|
||||||
|
* any appropriate {@link #requestLayout()} or {@link #invalidate()} calls.
|
||||||
|
* For example, callers can {@link #post(Runnable) post} a {@link Runnable}
|
||||||
|
* which performs a {@link #requestLayout()} on the next frame, after all detach/remove
|
||||||
|
* calls are finished, causing layout to be run prior to redrawing the view hierarchy.
|
||||||
*
|
*
|
||||||
* @param child the child to be definitely removed from the view hierarchy
|
* @param child the child to be definitely removed from the view hierarchy
|
||||||
* @param animate if true and the view has an animation, the view is placed in the
|
* @param animate if true and the view has an animation, the view is placed in the
|
||||||
@@ -3846,10 +3853,17 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Attaches a view to this view group. Attaching a view assigns this group as the parent,
|
* Attaches a view to this view group. Attaching a view assigns this group as the parent,
|
||||||
* sets the layout parameters and puts the view in the list of children so it can be retrieved
|
* sets the layout parameters and puts the view in the list of children so that
|
||||||
* by calling {@link #getChildAt(int)}.
|
* it can be retrieved by calling {@link #getChildAt(int)}.
|
||||||
*
|
* <p>
|
||||||
* This method should be called only for view which were detached from their parent.
|
* This method is intended to be lightweight and makes no assumptions about whether the
|
||||||
|
* parent or child should be redrawn. Proper use of this method will include also making
|
||||||
|
* any appropriate {@link #requestLayout()} or {@link #invalidate()} calls.
|
||||||
|
* For example, callers can {@link #post(Runnable) post} a {@link Runnable}
|
||||||
|
* which performs a {@link #requestLayout()} on the next frame, after all detach/attach
|
||||||
|
* calls are finished, causing layout to be run prior to redrawing the view hierarchy.
|
||||||
|
* <p>
|
||||||
|
* This method should be called only for views which were detached from their parent.
|
||||||
*
|
*
|
||||||
* @param child the child to attach
|
* @param child the child to attach
|
||||||
* @param index the index at which the child should be attached
|
* @param index the index at which the child should be attached
|
||||||
@@ -3881,10 +3895,13 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Detaches a view from its parent. Detaching a view should be temporary and followed
|
* Detaches a view from its parent. Detaching a view should be followed
|
||||||
* either by a call to {@link #attachViewToParent(View, int, android.view.ViewGroup.LayoutParams)}
|
* either by a call to
|
||||||
* or a call to {@link #removeDetachedView(View, boolean)}. When a view is detached,
|
* {@link #attachViewToParent(View, int, android.view.ViewGroup.LayoutParams)}
|
||||||
* its parent is null and cannot be retrieved by a call to {@link #getChildAt(int)}.
|
* or a call to {@link #removeDetachedView(View, boolean)}. Detachment should only be
|
||||||
|
* temporary; reattachment or removal should happen within the same drawing cycle as
|
||||||
|
* detachment. When a view is detached, its parent is null and cannot be retrieved by a
|
||||||
|
* call to {@link #getChildAt(int)}.
|
||||||
*
|
*
|
||||||
* @param child the child to detach
|
* @param child the child to detach
|
||||||
*
|
*
|
||||||
@@ -3899,10 +3916,13 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Detaches a view from its parent. Detaching a view should be temporary and followed
|
* Detaches a view from its parent. Detaching a view should be followed
|
||||||
* either by a call to {@link #attachViewToParent(View, int, android.view.ViewGroup.LayoutParams)}
|
* either by a call to
|
||||||
* or a call to {@link #removeDetachedView(View, boolean)}. When a view is detached,
|
* {@link #attachViewToParent(View, int, android.view.ViewGroup.LayoutParams)}
|
||||||
* its parent is null and cannot be retrieved by a call to {@link #getChildAt(int)}.
|
* or a call to {@link #removeDetachedView(View, boolean)}. Detachment should only be
|
||||||
|
* temporary; reattachment or removal should happen within the same drawing cycle as
|
||||||
|
* detachment. When a view is detached, its parent is null and cannot be retrieved by a
|
||||||
|
* call to {@link #getChildAt(int)}.
|
||||||
*
|
*
|
||||||
* @param index the index of the child to detach
|
* @param index the index of the child to detach
|
||||||
*
|
*
|
||||||
@@ -3917,10 +3937,13 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Detaches a range of view from their parent. Detaching a view should be temporary and followed
|
* Detaches a range of views from their parents. Detaching a view should be followed
|
||||||
* either by a call to {@link #attachViewToParent(View, int, android.view.ViewGroup.LayoutParams)}
|
* either by a call to
|
||||||
* or a call to {@link #removeDetachedView(View, boolean)}. When a view is detached, its
|
* {@link #attachViewToParent(View, int, android.view.ViewGroup.LayoutParams)}
|
||||||
* parent is null and cannot be retrieved by a call to {@link #getChildAt(int)}.
|
* or a call to {@link #removeDetachedView(View, boolean)}. Detachment should only be
|
||||||
|
* temporary; reattachment or removal should happen within the same drawing cycle as
|
||||||
|
* detachment. When a view is detached, its parent is null and cannot be retrieved by a
|
||||||
|
* call to {@link #getChildAt(int)}.
|
||||||
*
|
*
|
||||||
* @param start the first index of the childrend range to detach
|
* @param start the first index of the childrend range to detach
|
||||||
* @param count the number of children to detach
|
* @param count the number of children to detach
|
||||||
@@ -3936,10 +3959,13 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Detaches all views from the parent. Detaching a view should be temporary and followed
|
* Detaches all views from the parent. Detaching a view should be followed
|
||||||
* either by a call to {@link #attachViewToParent(View, int, android.view.ViewGroup.LayoutParams)}
|
* either by a call to
|
||||||
* or a call to {@link #removeDetachedView(View, boolean)}. When a view is detached,
|
* {@link #attachViewToParent(View, int, android.view.ViewGroup.LayoutParams)}
|
||||||
* its parent is null and cannot be retrieved by a call to {@link #getChildAt(int)}.
|
* or a call to {@link #removeDetachedView(View, boolean)}. Detachment should only be
|
||||||
|
* temporary; reattachment or removal should happen within the same drawing cycle as
|
||||||
|
* detachment. When a view is detached, its parent is null and cannot be retrieved by a
|
||||||
|
* call to {@link #getChildAt(int)}.
|
||||||
*
|
*
|
||||||
* @see #detachViewFromParent(View)
|
* @see #detachViewFromParent(View)
|
||||||
* @see #detachViewFromParent(int)
|
* @see #detachViewFromParent(int)
|
||||||
|
|||||||
Reference in New Issue
Block a user