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

Commit 138a54cb authored by Xavier Ducrohet's avatar Xavier Ducrohet Committed by Android (Google) Code Review
Browse files

Merge "LayoutLib: Annotate the custom delegate methods."

parents adca6840 9a4fe29c
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.animation;

import com.android.layoutlib.bridge.impl.DelegateManager;
import com.android.tools.layoutlib.annotations.LayoutlibDelegate;

/**
 * Delegate implementing the native methods of android.animation.PropertyValuesHolder
@@ -34,20 +35,24 @@ import com.android.layoutlib.bridge.impl.DelegateManager;
 */
/*package*/ class PropertyValuesHolder_Delegate {

    @LayoutlibDelegate
    /*package*/ static int nGetIntMethod(Class<?> targetClass, String methodName) {
        // return 0 to force PropertyValuesHolder to use Java reflection.
        return 0;
    }

    @LayoutlibDelegate
    /*package*/ static int nGetFloatMethod(Class<?> targetClass, String methodName) {
        // return 0 to force PropertyValuesHolder to use Java reflection.
        return 0;
    }

    @LayoutlibDelegate
    /*package*/ static void nCallIntMethod(Object target, int methodID, int arg) {
        // do nothing
    }

    @LayoutlibDelegate
    /*package*/ static void nCallFloatMethod(Object target, int methodID, float arg) {
        // do nothing
    }
+3 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.app;

import com.android.ide.common.rendering.api.IProjectCallback;
import com.android.tools.layoutlib.annotations.LayoutlibDelegate;

import android.content.Context;
import android.os.Bundle;
@@ -48,6 +49,7 @@ public class Fragment_Delegate {
     * Like {@link #instantiate(Context, String, Bundle)} but with a null
     * argument Bundle.
     */
    @LayoutlibDelegate
    /*package*/ static Fragment instantiate(Context context, String fname) {
        return instantiate(context, fname, null);
    }
@@ -66,6 +68,7 @@ public class Fragment_Delegate {
     * the given fragment class.  This is a runtime exception; it is not
     * normally expected to happen.
     */
    @LayoutlibDelegate
    /*package*/ static Fragment instantiate(Context context, String fname, Bundle args) {
        try {
            if (sProjectCallback != null) {
+5 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.content.res;

import com.android.layoutlib.bridge.impl.RenderSessionImpl;
import com.android.tools.layoutlib.annotations.LayoutlibDelegate;

import android.content.res.Resources.NotFoundException;
import android.content.res.Resources.Theme;
@@ -32,12 +33,14 @@ import android.util.TypedValue;
 */
public class Resources_Theme_Delegate {

    @LayoutlibDelegate
    /*package*/ static TypedArray obtainStyledAttributes(
            Resources thisResources, Theme thisTheme,
            int[] attrs) {
        return RenderSessionImpl.getCurrentContext().obtainStyledAttributes(attrs);
    }

    @LayoutlibDelegate
    /*package*/ static TypedArray obtainStyledAttributes(
            Resources thisResources, Theme thisTheme,
            int resid, int[] attrs)
@@ -45,6 +48,7 @@ public class Resources_Theme_Delegate {
        return RenderSessionImpl.getCurrentContext().obtainStyledAttributes(resid, attrs);
    }

    @LayoutlibDelegate
    /*package*/ static TypedArray obtainStyledAttributes(
            Resources thisResources, Theme thisTheme,
            AttributeSet set, int[] attrs, int defStyleAttr, int defStyleRes) {
@@ -52,6 +56,7 @@ public class Resources_Theme_Delegate {
                set, attrs, defStyleAttr, defStyleRes);
    }

    @LayoutlibDelegate
    /*package*/ static boolean resolveAttribute(
            Resources thisResources, Theme thisTheme,
            int resid, TypedValue outValue,
+2 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.graphics;

import com.android.layoutlib.bridge.impl.DelegateManager;
import com.android.tools.layoutlib.annotations.LayoutlibDelegate;

import java.awt.Composite;

@@ -59,6 +60,7 @@ public class AvoidXfermode_Delegate extends Xfermode_Delegate {

    // ---- native methods ----

    @LayoutlibDelegate
    /*package*/ static int nativeCreate(int opColor, int tolerance, int nativeMode) {
        AvoidXfermode_Delegate newDelegate = new AvoidXfermode_Delegate();
        return sManager.addDelegate(newDelegate);
+9 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import com.android.layoutlib.bridge.android.BridgeResources.NinePatchInputStream
import com.android.layoutlib.bridge.impl.DelegateManager;
import com.android.ninepatch.NinePatchChunk;
import com.android.resources.Density;
import com.android.tools.layoutlib.annotations.LayoutlibDelegate;

import android.graphics.BitmapFactory.Options;

@@ -42,6 +43,7 @@ import java.io.InputStream;

    // ------ Java delegates ------

    @LayoutlibDelegate
    /*package*/ static Bitmap finishDecode(Bitmap bm, Rect outPadding, Options opts) {
        if (bm == null || opts == null) {
            return bm;
@@ -82,10 +84,12 @@ import java.io.InputStream;

    // ------ Native Delegates ------

    @LayoutlibDelegate
    /*package*/ static void nativeSetDefaultConfig(int nativeConfig) {
        // pass
    }

    @LayoutlibDelegate
    /*package*/ static Bitmap nativeDecodeStream(InputStream is, byte[] storage,
            Rect padding, Options opts) {
        Bitmap bm = null;
@@ -129,29 +133,34 @@ import java.io.InputStream;
        return bm;
    }

    @LayoutlibDelegate
    /*package*/ static Bitmap nativeDecodeFileDescriptor(FileDescriptor fd,
            Rect padding, Options opts) {
        opts.inBitmap = null;
        return null;
    }

    @LayoutlibDelegate
    /*package*/ static Bitmap nativeDecodeAsset(int asset, Rect padding, Options opts) {
        opts.inBitmap = null;
        return null;
    }

    @LayoutlibDelegate
    /*package*/ static Bitmap nativeDecodeByteArray(byte[] data, int offset,
            int length, Options opts) {
        opts.inBitmap = null;
        return null;
    }

    @LayoutlibDelegate
    /*package*/ static byte[] nativeScaleNinePatch(byte[] chunk, float scale, Rect pad) {
        // don't scale for now. This should not be called anyway since we re-implement
        // BitmapFactory.finishDecode();
        return chunk;
    }

    @LayoutlibDelegate
    /*package*/ static boolean nativeIsSeekable(FileDescriptor fd) {
        return true;
    }
Loading