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

Commit acc3944d authored by Romain Guy's avatar Romain Guy Committed by Android (Google) Code Review
Browse files

Merge "Add an API to force Views to render their layer."

parents 5a39c95c f1ae1064
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -220707,6 +220707,17 @@
<parameter name="autoScale" type="boolean">
</parameter>
</method>
<method name="buildLayer"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="cancelLongPress"
 return="void"
 abstract="false"
+31 −0
Original line number Diff line number Diff line
@@ -8488,6 +8488,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
     *         {@link #LAYER_TYPE_HARDWARE}
     *
     * @see #setLayerType(int, android.graphics.Paint)
     * @see #buildLayer() 
     * @see #LAYER_TYPE_NONE
     * @see #LAYER_TYPE_SOFTWARE
     * @see #LAYER_TYPE_HARDWARE
@@ -8496,6 +8497,36 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
        return mLayerType;
    }

    /**
     * Forces this view's layer to be created and this view to be rendered
     * into its layer. If this view's layer type is set to {@link #LAYER_TYPE_NONE},
     * invoking this method will have no effect.
     * 
     * This method can for instance be used to render a view into its layer before
     * starting an animation. If this view is complex, rendering into the layer
     * before starting the animation will avoid skipping frames.
     * 
     * @throws IllegalStateException If this view is not attached to a window
     * 
     * @see #setLayerType(int, android.graphics.Paint) 
     */
    public void buildLayer() {
        if (mLayerType == LAYER_TYPE_NONE) return;

        if (mAttachInfo == null) {
            throw new IllegalStateException("This view must be attached to a window first");
        }

        switch (mLayerType) {
            case LAYER_TYPE_HARDWARE:
                getHardwareLayer();
                break;
            case LAYER_TYPE_SOFTWARE:
                buildDrawingCache(true);
                break;
        }
    }

    /**
     * <p>Returns a hardware layer that can be used to draw this view again
     * without executing its draw method.</p>