diff options
author | Philip Milne <pmilne@google.com> | 2011-07-19 10:03:43 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-07-19 10:03:43 -0700 |
commit | 2e29de7cab35e4cf7c8f177b546cc95b101ed5c8 (patch) | |
tree | 304a04b5336db8b998bb8fd1c9adfe4dae5c394e | |
parent | d6df906052e6743a2419be3b779222fc84436c92 (diff) | |
parent | f51d91c3ab232154b6c00d7f71377ff2421f79bf (diff) | |
download | frameworks_base-2e29de7cab35e4cf7c8f177b546cc95b101ed5c8.zip frameworks_base-2e29de7cab35e4cf7c8f177b546cc95b101ed5c8.tar.gz frameworks_base-2e29de7cab35e4cf7c8f177b546cc95b101ed5c8.tar.bz2 |
Merge "Gather View's hierarchy notifications into methods that can easily be overidden."
-rw-r--r-- | core/java/android/view/ViewGroup.java | 42 | ||||
-rw-r--r-- | core/java/android/widget/GridLayout.java | 51 |
2 files changed, 27 insertions, 66 deletions
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java index 5f7673a..a6c158d 100644 --- a/core/java/android/view/ViewGroup.java +++ b/core/java/android/view/ViewGroup.java @@ -3183,6 +3183,24 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager } /** + * @hide + */ + protected void onViewAdded(View child) { + if (mOnHierarchyChangeListener != null) { + mOnHierarchyChangeListener.onChildViewAdded(this, child); + } + } + + /** + * @hide + */ + protected void onViewRemoved(View child) { + if (mOnHierarchyChangeListener != null) { + mOnHierarchyChangeListener.onChildViewRemoved(this, child); + } + } + + /** * Adds a view during layout. This is useful if in your onLayout() method, * you need to add more views (as does the list view for example). * @@ -3283,9 +3301,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager ai.mKeepScreenOn = lastKeepOn; } - if (mOnHierarchyChangeListener != null) { - mOnHierarchyChangeListener.onChildViewAdded(this, child); - } + onViewAdded(child); if ((child.mViewFlags & DUPLICATE_PARENT_STATE) == DUPLICATE_PARENT_STATE) { mGroupFlags |= FLAG_NOTIFY_CHILDREN_ON_DRAWABLE_STATE_CHANGE; @@ -3486,9 +3502,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager view.dispatchDetachedFromWindow(); } - if (mOnHierarchyChangeListener != null) { - mOnHierarchyChangeListener.onChildViewRemoved(this, view); - } + onViewRemoved(view); needGlobalAttributesUpdate(false); @@ -3533,8 +3547,6 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager } private void removeViewsInternal(int start, int count) { - final OnHierarchyChangeListener onHierarchyChangeListener = mOnHierarchyChangeListener; - final boolean notifyListener = onHierarchyChangeListener != null; final View focused = mFocused; final boolean detach = mAttachInfo != null; View clearChildFocus = null; @@ -3563,9 +3575,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager needGlobalAttributesUpdate(false); - if (notifyListener) { - onHierarchyChangeListener.onChildViewRemoved(this, view); - } + onViewRemoved(view); } removeFromArray(start, count); @@ -3603,8 +3613,6 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager final View[] children = mChildren; mChildrenCount = 0; - final OnHierarchyChangeListener listener = mOnHierarchyChangeListener; - final boolean notify = listener != null; final View focused = mFocused; final boolean detach = mAttachInfo != null; View clearChildFocus = null; @@ -3630,9 +3638,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager view.dispatchDetachedFromWindow(); } - if (notify) { - listener.onChildViewRemoved(this, view); - } + onViewRemoved(view); view.mParent = null; children[i] = null; @@ -3672,9 +3678,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager child.dispatchDetachedFromWindow(); } - if (mOnHierarchyChangeListener != null) { - mOnHierarchyChangeListener.onChildViewRemoved(this, child); - } + onViewRemoved(child); } /** diff --git a/core/java/android/widget/GridLayout.java b/core/java/android/widget/GridLayout.java index f82c61a..6df8efb 100644 --- a/core/java/android/widget/GridLayout.java +++ b/core/java/android/widget/GridLayout.java @@ -758,38 +758,14 @@ public class GridLayout extends ViewGroup { // Add/remove @Override - public void addView(View child, int index, ViewGroup.LayoutParams params) { - super.addView(child, index, params); + protected void onViewAdded(View child) { + super.onViewAdded(child); invalidateStructure(); } @Override - public void removeView(View view) { - super.removeView(view); - invalidateStructure(); - } - - @Override - public void removeViewInLayout(View view) { - super.removeViewInLayout(view); - invalidateStructure(); - } - - @Override - public void removeViewsInLayout(int start, int count) { - super.removeViewsInLayout(start, count); - invalidateStructure(); - } - - @Override - public void removeViewAt(int index) { - super.removeViewAt(index); - invalidateStructure(); - } - - @Override - public void removeAllViews() { - super.removeAllViews(); + protected void onViewRemoved(View child) { + super.onViewRemoved(child); invalidateStructure(); } @@ -2301,25 +2277,6 @@ public class GridLayout extends ViewGroup { } /** - * Temporary backward compatibility class for Launcher - to avoid - * dependent multi-project commit. This class will be deleted after - * AppsCustomizePagedView is updated to new API. - * - * @hide - */ - @Deprecated - public static class Group extends Spec { - /** - * @deprecated Please replace with {@link #spec(int, int, Alignment)} - * @hide - */ - @Deprecated - public Group(int start, int size, Alignment alignment) { - super(start, size, alignment, UNDEFINED_FLEXIBILITY); - } - } - - /** * Return a Spec, {@code spec}, where: * <ul> * <li> {@code spec.span = [start, start + size]} </li> |