public void __constructor__(Context context, AttributeSet attributeSet, int defStyle) { if (context == null) throw new NullPointerException("no context"); this.attributeSet = attributeSet; invokeConstructor( View.class, realView, ClassParameter.from(Context.class, context), ClassParameter.from(AttributeSet.class, attributeSet), ClassParameter.from(int.class, defStyle)); }
@Implementation public void onLayout(boolean changed, int left, int top, int right, int bottom) { onLayoutWasCalled = true; directlyOn( realView, View.class, "onLayout", ClassParameter.from(boolean.class, changed), ClassParameter.from(int.class, left), ClassParameter.from(int.class, top), ClassParameter.from(int.class, right), ClassParameter.from(int.class, bottom)); }
@Implementation // todo: this sucks, it's all just so we can detect 9-patches public static Drawable createFromResourceStream( Resources res, TypedValue value, InputStream is, String srcName, BitmapFactory.Options opts) { if (is == null) { return null; } Rect pad = new Rect(); if (opts == null) opts = new BitmapFactory.Options(); opts.inScreenDensity = DisplayMetrics.DENSITY_DEFAULT; Bitmap bm = BitmapFactory.decodeResourceStream(res, value, is, pad, opts); if (bm != null) { boolean isNinePatch = srcName != null && srcName.contains(".9."); if (isNinePatch) { ReflectionHelpers.callInstanceMethod( bm, "setNinePatchChunk", ClassParameter.from(byte[].class, new byte[0])); } byte[] np = bm.getNinePatchChunk(); if (np == null || !NinePatch.isNinePatchChunk(np)) { np = null; pad = null; } if (np != null) { // todo: wrong return new NinePatchDrawable(res, bm, np, pad, srcName); } return new BitmapDrawable(res, bm); } return null; }
public void setMyParent(ViewParent viewParent) { directlyOn( realView, View.class, "assignParent", ClassParameter.from(ViewParent.class, viewParent)); }