am 326d808b: Added View#dispatchViewVisibilityChanged and View#onDispatchVisibilityChanged; updated api; tests
Merge commit '326d808b858359464b2ffeb84f2e0a8e0c79b600' into eclair-mr2-plus-aosp * commit '326d808b858359464b2ffeb84f2e0a8e0c79b600': Added View#dispatchViewVisibilityChanged and View#onDispatchVisibilityChanged; updated api; tests
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -3770,6 +3770,26 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
|
||||
return mAttachInfo != null && mAttachInfo.mHasWindowFocus;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
|
||||
@@ -680,6 +680,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}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user