diff options
author | Adam Powell <adamp@google.com> | 2009-12-09 15:10:07 -0800 |
---|---|---|
committer | Adam Powell <adamp@google.com> | 2009-12-10 14:49:14 -0800 |
commit | 326d808b858359464b2ffeb84f2e0a8e0c79b600 (patch) | |
tree | 11974c82f0aa6398a0a7eb122b97c2a4c95a46f1 /core/java | |
parent | f2f68760eb10b52bd53d6a266f9b5e2b06037d9f (diff) | |
download | frameworks_base-326d808b858359464b2ffeb84f2e0a8e0c79b600.zip frameworks_base-326d808b858359464b2ffeb84f2e0a8e0c79b600.tar.gz frameworks_base-326d808b858359464b2ffeb84f2e0a8e0c79b600.tar.bz2 |
Added View#dispatchViewVisibilityChanged and View#onDispatchVisibilityChanged; updated api; tests
Reverted a change to InstrumentationTestCase that would have allowed @UiThreadTest on setUp() methods of tests.
Diffstat (limited to 'core/java')
-rw-r--r-- | core/java/android/test/InstrumentationTestCase.java | 36 | ||||
-rw-r--r-- | core/java/android/view/View.java | 24 | ||||
-rw-r--r-- | core/java/android/view/ViewGroup.java | 13 |
3 files changed, 37 insertions, 36 deletions
diff --git a/core/java/android/test/InstrumentationTestCase.java b/core/java/android/test/InstrumentationTestCase.java index 3290c96..22d95d1 100644 --- a/core/java/android/test/InstrumentationTestCase.java +++ b/core/java/android/test/InstrumentationTestCase.java @@ -147,42 +147,6 @@ public class InstrumentationTestCase extends TestCase { } } - @Override - public void runBare() throws Throwable { - runMethod("setUp"); - - try { - runTest(); - } finally { - runMethod("tearDown"); - } - } - - private Throwable[] runMethod(String name) throws Throwable { - final Throwable[] exceptions = new Throwable[1]; - final Method m = getClass().getMethod(name, (Class[]) null); - - if (m.isAnnotationPresent(UiThreadTest.class)) { - getInstrumentation().runOnMainSync(new Runnable() { - public void run() { - try { - m.invoke(InstrumentationTestCase.this); - } catch (Throwable throwable) { - exceptions[0] = throwable; - } - } - }); - if (exceptions[0] != null) { - throw exceptions[0]; - } - exceptions[0] = null; - } else { - m.invoke(this); - } - - return exceptions; - } - /** * Runs the current unit test. If the unit test is annotated with * {@link android.test.UiThreadTest}, the test is run on the UI thread. diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index d3f46b8..7f5d254 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -3771,6 +3771,26 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility } /** + * Dispatch a view visibility change down the view hierarchy. + * ViewGroups should override to route to their children. + * @param changedView The view whose visibility changed. Could be 'this' or + * an ancestor view. + * @param visibility The new visibility of changedView. + */ + protected void dispatchVisibilityChanged(View changedView, int visibility) { + onVisibilityChanged(changedView, visibility); + } + + /** + * Called when the visibility of the view or an ancestor of the view is changed. + * @param changedView The view whose visibility changed. Could be 'this' or + * an ancestor view. + * @param visibility The new visibility of changedView. + */ + protected void onVisibilityChanged(View changedView, int visibility) { + } + + /** * Dispatch a window visibility change down the view hierarchy. * ViewGroups should override to route to their children. * @@ -4349,6 +4369,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility } } + if ((changed & VISIBILITY_MASK) != 0) { + dispatchVisibilityChanged(this, (flags & VISIBILITY_MASK)); + } + if ((changed & WILL_NOT_CACHE_DRAWING) != 0) { destroyDrawingCache(); } diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java index e2f15c7..6646136 100644 --- a/core/java/android/view/ViewGroup.java +++ b/core/java/android/view/ViewGroup.java @@ -684,6 +684,19 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager * {@inheritDoc} */ @Override + protected void dispatchVisibilityChanged(View changedView, int visibility) { + super.dispatchVisibilityChanged(changedView, visibility); + final int count = mChildrenCount; + final View[] children = mChildren; + for (int i = 0; i < count; i++) { + children[i].dispatchVisibilityChanged(changedView, visibility); + } + } + + /** + * {@inheritDoc} + */ + @Override public void dispatchWindowVisibilityChanged(int visibility) { super.dispatchWindowVisibilityChanged(visibility); final int count = mChildrenCount; |