Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 326d808b authored by Adam Powell's avatar Adam Powell
Browse files

Added View#dispatchViewVisibilityChanged and View#onDispatchVisibilityChanged; updated api; tests

Reverted a change to InstrumentationTestCase that would have allowed @UiThreadTest on setUp() methods of tests.
parent f2f68760
Loading
Loading
Loading
Loading
+49 −19
Original line number Diff line number Diff line
@@ -93901,7 +93901,7 @@
<method name="glPointSizePointerOES"
 return="void"
 abstract="false"
 native="true"
 native="false"
 synchronized="false"
 static="true"
 final="false"
@@ -96924,7 +96924,7 @@
<method name="glMatrixIndexPointerOES"
 return="void"
 abstract="false"
 native="true"
 native="false"
 synchronized="false"
 static="true"
 final="false"
@@ -97482,7 +97482,7 @@
<method name="glWeightPointerOES"
 return="void"
 abstract="false"
 native="true"
 native="false"
 synchronized="false"
 static="true"
 final="false"
@@ -166662,6 +166662,21 @@
<parameter name="direction" type="int">
</parameter>
</method>
<method name="dispatchVisibilityChanged"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="protected"
>
<parameter name="changedView" type="android.view.View">
</parameter>
<parameter name="visibility" type="int">
</parameter>
</method>
<method name="dispatchWindowFocusChanged"
 return="void"
 abstract="false"
@@ -168522,6 +168537,21 @@
<parameter name="event" type="android.view.MotionEvent">
</parameter>
</method>
<method name="onVisibilityChanged"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="protected"
>
<parameter name="changedView" type="android.view.View">
</parameter>
<parameter name="visibility" type="int">
</parameter>
</method>
<method name="onWindowFocusChanged"
 return="void"
 abstract="false"
@@ -286854,7 +286884,7 @@
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="array" type="short[]">
<parameter name="array" type="java.lang.Object[]">
</parameter>
</method>
<method name="sort"
@@ -286867,7 +286897,7 @@
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="array" type="short[]">
<parameter name="array" type="java.lang.Object[]">
</parameter>
<parameter name="start" type="int">
</parameter>
@@ -286884,7 +286914,13 @@
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="array" type="java.lang.Object[]">
<parameter name="array" type="T[]">
</parameter>
<parameter name="start" type="int">
</parameter>
<parameter name="end" type="int">
</parameter>
<parameter name="comparator" type="java.util.Comparator&lt;? super T&gt;">
</parameter>
</method>
<method name="sort"
@@ -286897,11 +286933,9 @@
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="array" type="java.lang.Object[]">
</parameter>
<parameter name="start" type="int">
<parameter name="array" type="T[]">
</parameter>
<parameter name="end" type="int">
<parameter name="comparator" type="java.util.Comparator&lt;? super T&gt;">
</parameter>
</method>
<method name="sort"
@@ -286914,13 +286948,7 @@
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="array" type="T[]">
</parameter>
<parameter name="start" type="int">
</parameter>
<parameter name="end" type="int">
</parameter>
<parameter name="comparator" type="java.util.Comparator&lt;? super T&gt;">
<parameter name="array" type="short[]">
</parameter>
</method>
<method name="sort"
@@ -286933,9 +286961,11 @@
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="array" type="T[]">
<parameter name="array" type="short[]">
</parameter>
<parameter name="comparator" type="java.util.Comparator&lt;? super T&gt;">
<parameter name="start" type="int">
</parameter>
<parameter name="end" type="int">
</parameter>
</method>
<method name="toString"
+0 −36
Original line number Diff line number Diff line
@@ -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.
+24 −0
Original line number Diff line number Diff line
@@ -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();
        }
+13 −0
Original line number Diff line number Diff line
@@ -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}
     */
+7 −0
Original line number Diff line number Diff line
@@ -377,6 +377,13 @@
            </intent-filter>
        </activity>

        <activity android:name=".view.VisibilityCallback" android:label="VisibilityCallback">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
            </intent-filter>
        </activity>

        <activity android:name=".view.BigCache" android:label="BigCache">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
Loading