Search in sources :

Example 31 with LayoutlibDelegate

use of com.android.tools.layoutlib.annotations.LayoutlibDelegate in project platform_frameworks_base by android.

the class VectorDrawable_Delegate method nGetFullPathProperties.

@LayoutlibDelegate
static boolean nGetFullPathProperties(long pathPtr, byte[] propertiesData, int length) {
    VFullPath_Delegate path = VNativeObject.getDelegate(pathPtr);
    ByteBuffer properties = ByteBuffer.wrap(propertiesData);
    properties.order(ByteOrder.nativeOrder());
    properties.putFloat(VFullPath_Delegate.STROKE_WIDTH_INDEX * 4, path.getStrokeWidth());
    properties.putInt(VFullPath_Delegate.STROKE_COLOR_INDEX * 4, path.getStrokeColor());
    properties.putFloat(VFullPath_Delegate.STROKE_ALPHA_INDEX * 4, path.getStrokeAlpha());
    properties.putInt(VFullPath_Delegate.FILL_COLOR_INDEX * 4, path.getFillColor());
    properties.putFloat(VFullPath_Delegate.FILL_ALPHA_INDEX * 4, path.getStrokeAlpha());
    properties.putFloat(VFullPath_Delegate.TRIM_PATH_START_INDEX * 4, path.getTrimPathStart());
    properties.putFloat(VFullPath_Delegate.TRIM_PATH_END_INDEX * 4, path.getTrimPathEnd());
    properties.putFloat(VFullPath_Delegate.TRIM_PATH_OFFSET_INDEX * 4, path.getTrimPathOffset());
    properties.putInt(VFullPath_Delegate.STROKE_LINE_CAP_INDEX * 4, path.getStrokeLineCap());
    properties.putInt(VFullPath_Delegate.STROKE_LINE_JOIN_INDEX * 4, path.getStrokeLineJoin());
    properties.putFloat(VFullPath_Delegate.STROKE_MITER_LIMIT_INDEX * 4, path.getStrokeMiterlimit());
    properties.putInt(VFullPath_Delegate.FILL_TYPE_INDEX * 4, path.getFillType());
    return true;
}
Also used : ByteBuffer(java.nio.ByteBuffer) LayoutlibDelegate(com.android.tools.layoutlib.annotations.LayoutlibDelegate)

Example 32 with LayoutlibDelegate

use of com.android.tools.layoutlib.annotations.LayoutlibDelegate in project platform_frameworks_base by android.

the class Preference_Delegate method getView.

@LayoutlibDelegate
static /*package*/
View getView(Preference pref, View convertView, ViewGroup parent) {
    Context context = pref.getContext();
    BridgeContext bc = context instanceof BridgeContext ? ((BridgeContext) context) : null;
    convertView = pref.getView_Original(convertView, parent);
    if (bc != null) {
        Object cookie = bc.getCookie(pref);
        if (cookie != null) {
            bc.addViewKey(convertView, cookie);
        }
    }
    return convertView;
}
Also used : Context(android.content.Context) BridgeContext(com.android.layoutlib.bridge.android.BridgeContext) BridgeContext(com.android.layoutlib.bridge.android.BridgeContext) LayoutlibDelegate(com.android.tools.layoutlib.annotations.LayoutlibDelegate)

Example 33 with LayoutlibDelegate

use of com.android.tools.layoutlib.annotations.LayoutlibDelegate in project platform_frameworks_base by android.

the class InputMethodManager_Delegate method getInstance.

// ---- Overridden methods ----
@LayoutlibDelegate
static /*package*/
InputMethodManager getInstance() {
    synchronized (InputMethodManager.class) {
        InputMethodManager imm = InputMethodManager.peekInstance();
        if (imm == null) {
            imm = new InputMethodManager(new BridgeIInputMethodManager(), Looper.getMainLooper());
            InputMethodManager.sInstance = imm;
        }
        return imm;
    }
}
Also used : BridgeIInputMethodManager(com.android.layoutlib.bridge.android.BridgeIInputMethodManager) BridgeIInputMethodManager(com.android.layoutlib.bridge.android.BridgeIInputMethodManager) LayoutlibDelegate(com.android.tools.layoutlib.annotations.LayoutlibDelegate)

Example 34 with LayoutlibDelegate

use of com.android.tools.layoutlib.annotations.LayoutlibDelegate in project android_frameworks_base by ParanoidAndroid.

the class BitmapFactory_Delegate method nativeDecodeStream.

@LayoutlibDelegate
static /*package*/
Bitmap nativeDecodeStream(InputStream is, byte[] storage, Rect padding, Options opts, boolean applyScale, float scale) {
    Bitmap bm = null;
    //TODO support rescaling
    Density density = Density.MEDIUM;
    if (opts != null) {
        density = Density.getEnum(opts.inDensity);
    }
    try {
        if (is instanceof NinePatchInputStream) {
            NinePatchInputStream npis = (NinePatchInputStream) is;
            npis.disableFakeMarkSupport();
            // load the bitmap as a nine patch
            com.android.ninepatch.NinePatch ninePatch = com.android.ninepatch.NinePatch.load(npis, true, /*is9Patch*/
            false);
            // get the bitmap and chunk objects.
            bm = Bitmap_Delegate.createBitmap(ninePatch.getImage(), true, /*isMutable*/
            density);
            NinePatchChunk chunk = ninePatch.getChunk();
            // put the chunk in the bitmap
            bm.setNinePatchChunk(NinePatch_Delegate.serialize(chunk));
            // read the padding
            int[] paddingarray = chunk.getPadding();
            padding.left = paddingarray[0];
            padding.top = paddingarray[1];
            padding.right = paddingarray[2];
            padding.bottom = paddingarray[3];
        } else {
            // load the bitmap directly.
            bm = Bitmap_Delegate.createBitmap(is, true, density);
        }
    } catch (IOException e) {
        Bridge.getLog().error(null, "Failed to load image", e, null);
    }
    return bm;
}
Also used : NinePatchInputStream(android.content.res.BridgeResources.NinePatchInputStream) NinePatchChunk(com.android.ninepatch.NinePatchChunk) IOException(java.io.IOException) Density(com.android.resources.Density) LayoutlibDelegate(com.android.tools.layoutlib.annotations.LayoutlibDelegate)

Example 35 with LayoutlibDelegate

use of com.android.tools.layoutlib.annotations.LayoutlibDelegate in project android_frameworks_base by ParanoidAndroid.

the class Bitmap_Delegate method nativeCreate.

// ---- native methods ----
@LayoutlibDelegate
static /*package*/
Bitmap nativeCreate(int[] colors, int offset, int stride, int width, int height, int nativeConfig, boolean mutable) {
    int imageType = getBufferedImageType(nativeConfig);
    // create the image
    BufferedImage image = new BufferedImage(width, height, imageType);
    if (colors != null) {
        image.setRGB(0, 0, width, height, colors, offset, stride);
    }
    // create a delegate with the content of the stream.
    Bitmap_Delegate delegate = new Bitmap_Delegate(image, Config.nativeToConfig(nativeConfig));
    return createBitmap(delegate, mutable, Bitmap.getDefaultDensity());
}
Also used : BufferedImage(java.awt.image.BufferedImage) LayoutlibDelegate(com.android.tools.layoutlib.annotations.LayoutlibDelegate)

Aggregations

LayoutlibDelegate (com.android.tools.layoutlib.annotations.LayoutlibDelegate)334 ArrayResourceValue (com.android.ide.common.rendering.api.ArrayResourceValue)56 DensityBasedResourceValue (com.android.ide.common.rendering.api.DensityBasedResourceValue)56 ResourceValue (com.android.ide.common.rendering.api.ResourceValue)56 BufferedImage (java.awt.image.BufferedImage)46 AffineTransform (java.awt.geom.AffineTransform)42 Area (java.awt.geom.Area)42 File (java.io.File)30 GcSnapshot (com.android.layoutlib.bridge.impl.GcSnapshot)29 FileNotFoundException (java.io.FileNotFoundException)24 Graphics2D (java.awt.Graphics2D)19 TypedValue (android.util.TypedValue)17 NotFoundException (android.content.res.Resources.NotFoundException)16 BridgeContext (com.android.layoutlib.bridge.android.BridgeContext)16 BridgeXmlBlockParser (com.android.layoutlib.bridge.android.BridgeXmlBlockParser)16 ArrayList (java.util.ArrayList)16 XmlPullParser (org.xmlpull.v1.XmlPullParser)16 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)16 IOException (java.io.IOException)14 NinePatchInputStream (com.android.layoutlib.bridge.util.NinePatchInputStream)12