Java 类android.graphics.drawable.NinePatchDrawable 实例源码

项目:Android-UtilCode    文件:ImageUtils.java   
/**
 * drawable转bitmap
 *
 * @param drawable drawable对象
 * @return bitmap
 */
public static Bitmap drawable2Bitmap(Drawable drawable) {
    if (drawable instanceof BitmapDrawable) {
        return ((BitmapDrawable) drawable).getBitmap();
    } else if (drawable instanceof NinePatchDrawable) {
        Bitmap bitmap = Bitmap.createBitmap(
                drawable.getIntrinsicWidth(),
                drawable.getIntrinsicHeight(),
                drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565);
        Canvas canvas = new Canvas(bitmap);
        drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
        drawable.draw(canvas);
        return bitmap;
    } else {
        return null;
    }
}
项目:Depth    文件:DepthRelativeLayoutContainer.java   
void setup() {
    setLayerType(LAYER_TYPE_HARDWARE, null);

    getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
        @Override
        public boolean onPreDraw() {
            for (int i = 0; i < getChildCount(); i++) {
                View child = getChildAt(i);
                if (child instanceof DepthRelativeLayout) {
                    boolean hasChangedBounds = ((DepthRelativeLayout) child).calculateBounds();
                    if (hasChangedBounds)
                        invalidate();
                }
            }
            return true;
        }
    });

    shadowPaint.setColor(Color.BLACK);
    shadowPaint.setAntiAlias(true);
    softShadow = (NinePatchDrawable) getResources().getDrawable(R.drawable.shadow, null);
    roundSoftShadow = getResources().getDrawable(R.drawable.round_soft_shadow, null);
}
项目:Mix    文件:ThemeUtils.java   
public static boolean containsNinePatch(Drawable drawable) {
    drawable = getWrapperDrawable(drawable);
    if (drawable instanceof NinePatchDrawable
            || drawable instanceof InsetDrawable
            || drawable instanceof LayerDrawable) {
        return true;
    } else if (drawable instanceof StateListDrawable) {
        final DrawableContainer.DrawableContainerState containerState = ((DrawableContainer.DrawableContainerState) drawable.getConstantState());
        //can't getBaseApplication containState from drawable which is containing DrawableWrapperDonut
        //https://code.google.com/p/android/issues/detail?id=169920
        if (containerState == null) {
            return true;
        }
        for (Drawable dr : containerState.getChildren()) {
            dr = getWrapperDrawable(dr);
            if (dr instanceof NinePatchDrawable
                    || dr instanceof InsetDrawable
                    || dr instanceof LayerDrawable) {
                return true;
            }
        }
    }
    return false;
}
项目:jackknife    文件:ImageUtils.java   
public static Bitmap drawable2Bitmap(Drawable drawable) {
    if (drawable instanceof BitmapDrawable) {
        return ((BitmapDrawable) drawable).getBitmap();
    } else if (drawable instanceof NinePatchDrawable) {
        Bitmap bitmap = Bitmap
                .createBitmap(
                        drawable.getIntrinsicWidth(),
                        drawable.getIntrinsicHeight(),
                        drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888
                                : Bitmap.Config.RGB_565);
        Canvas canvas = new Canvas(bitmap);
        drawable.setBounds(0, 0, drawable.getIntrinsicWidth(),
                drawable.getIntrinsicHeight());
        drawable.draw(canvas);
        return bitmap;
    } else {
        return null;
    }
}
项目:LJFramework    文件:ImageUtils.java   
/**
 * drawable转bitmap
 *
 * @param drawable drawable对象
 * @return bitmap
 */
public static Bitmap drawable2Bitmap(Drawable drawable) {
    if (drawable instanceof BitmapDrawable) {
        return ((BitmapDrawable) drawable).getBitmap();
    } else if (drawable instanceof NinePatchDrawable) {
        Bitmap bitmap = Bitmap
                .createBitmap(drawable.getIntrinsicWidth(), drawable
                                .getIntrinsicHeight(),
                        drawable.getOpacity() != PixelFormat.OPAQUE
                        ? Bitmap.Config.ARGB_8888
                        : Bitmap.Config.RGB_565);
        Canvas canvas = new Canvas(bitmap);
        drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable
                .getIntrinsicHeight());
        drawable.draw(canvas);
        return bitmap;
    } else {
        return null;
    }
}
项目:Android-DFU-App    文件:ForegroundRelativeLayout.java   
public ForegroundRelativeLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ForegroundRelativeLayout,
            defStyle, 0);

    final Drawable d = a.getDrawable(R.styleable.ForegroundRelativeLayout_foreground);
    if (d != null) {
        setForeground(d);
    }

    a.recycle();

    if (this.getBackground() instanceof NinePatchDrawable) {
        final NinePatchDrawable npd = (NinePatchDrawable) this.getBackground();
        mRectPadding = new Rect();
        if (npd.getPadding(mRectPadding)) {
         mUseBackgroundPadding = true;
        }
    }
}
项目:Android-DFU-App    文件:ForegroundLinearLayout.java   
public ForegroundLinearLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ForegroundRelativeLayout,
            defStyle, 0);

    final Drawable d = a.getDrawable(R.styleable.ForegroundRelativeLayout_foreground);
    if (d != null) {
        setForeground(d);
    }

    a.recycle();

    if (this.getBackground() instanceof NinePatchDrawable) {
        final NinePatchDrawable npd = (NinePatchDrawable) this.getBackground();
        mRectPadding = new Rect();
        if (npd.getPadding(mRectPadding)) {
         mUseBackgroundPadding = true;
        }
    }
}
项目:iosched-reader    文件:DrawShadowFrameLayout.java   
public DrawShadowFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    final TypedArray a = context.obtainStyledAttributes(attrs,
            R.styleable.DrawShadowFrameLayout, 0, 0);

    mShadowDrawable = a.getDrawable(R.styleable.DrawShadowFrameLayout_shadowDrawable);
    if (mShadowDrawable != null) {
        mShadowDrawable.setCallback(this);
        if (mShadowDrawable instanceof NinePatchDrawable) {
            mShadowNinePatchDrawable = (NinePatchDrawable) mShadowDrawable;
        }
    }

    mShadowVisible = a.getBoolean(R.styleable.DrawShadowFrameLayout_shadowVisible, true);
    setWillNotDraw(!mShadowVisible || mShadowDrawable == null);

    a.recycle();
}
项目:FloatingApps    文件:PopupMenu.java   
public void showAtLocation(final View v, int x, int y) {
    final PopupMenu that = this;
    this.window.setOnDismissListener(new PopupWindow.OnDismissListener() {
        public void onDismiss() {
            that.main_layout.removeAllViews();
        }
    });

    this.main_layout = new LinearLayout(this.ctx);
    LayerDrawable layerDrawable = new LayerDrawable(new Drawable[] { (NinePatchDrawable)this.ctx.getResources().getDrawable(android.R.drawable.dialog_frame), new ColorDrawable(Color.WHITE) });
    layerDrawable.setLayerInset(0, Utils.dip2px(this.ctx, 5), Utils.dip2px(this.ctx, 5) + 3, Utils.dip2px(this.ctx, 5), Utils.dip2px(this.ctx, 5));
    this.main_layout.setBackgroundDrawable(layerDrawable);
    this.main_layout.addView(this.contentViewLayout);
    this.window.setContentView(this.main_layout);
    this.window.setWidth(this.width);
    this.window.setHeight(this.height);
    this.window.showAsDropDown(v, x, y);
}
项目:StarchWindow    文件:PopupMenu.java   
public void showAtLocation(final View v, int x, int y) {
     final PopupMenu that = this;
     this.window.setOnDismissListener(new PopupWindow.OnDismissListener() {
    public void onDismiss() {
        that.main_layout.removeAllViews();
    }
});

     this.main_layout = new LinearLayout(this.ctx);
     LayerDrawable layerDrawable = new LayerDrawable(new Drawable[] { (NinePatchDrawable)this.ctx.getResources().getDrawable(android.R.drawable.dialog_frame), new ColorDrawable(Color.WHITE) });
     layerDrawable.setLayerInset(0, Utils.dip2px(this.ctx, 5), Utils.dip2px(this.ctx, 5) + 3, Utils.dip2px(this.ctx, 5), Utils.dip2px(this.ctx, 5));
     this.main_layout.setBackgroundDrawable(layerDrawable);
     this.main_layout.addView(this.contentViewLayout);
     this.window.setContentView(this.main_layout);
     this.window.setWidth(this.width);
     this.window.setHeight(this.height);
     this.window.showAsDropDown(v, x, y);
 }
项目:MagicaSakura    文件:ThemeUtils.java   
public static boolean containsNinePatch(Drawable drawable) {
    drawable = getWrapperDrawable(drawable);
    if (drawable instanceof NinePatchDrawable
            || drawable instanceof InsetDrawable
            || drawable instanceof LayerDrawable) {
        return true;
    } else if (drawable instanceof StateListDrawable) {
        final DrawableContainer.DrawableContainerState containerState = ((DrawableContainer.DrawableContainerState) drawable.getConstantState());
        //can't get containState from drawable which is containing DrawableWrapperDonut
        //https://code.google.com/p/android/issues/detail?id=169920
        if (containerState == null) {
            return true;
        }
        for (Drawable dr : containerState.getChildren()) {
            dr = getWrapperDrawable(dr);
            if (dr instanceof NinePatchDrawable
                    || dr instanceof InsetDrawable
                    || dr instanceof LayerDrawable) {
                return true;
            }
        }
    }
    return false;
}
项目:Android-Yet-Another-Refresh    文件:CircularImageView.java   
@Override
protected void onDraw(Canvas canvas) {
    final Drawable drawable = getDrawable();
    if (null == drawable)
        return;

    if (drawable instanceof NinePatchDrawable)
        return;

    final int width = getWidth();
    final int height = getHeight();
    final int layer = canvas.saveLayer(0, 0, width, height, this.nonePaint,
            Canvas.ALL_SAVE_FLAG);

    drawable.setBounds(0, 0, width, height);
    drawable.draw(canvas);

    if ((null == this.mask) || (this.mask.isRecycled())) {
        this.mask = createOvalBitmap(width, height);
    }

    canvas.drawBitmap(this.mask, 0, 0, this.maskPaint);
    canvas.restoreToCount(layer);
    drawBorder(canvas, width, height);
}
项目:Android-Application-ZJB    文件:BitmapUtil.java   
public static Bitmap drawable2Bitmap(Drawable drawable) {
    if (drawable instanceof BitmapDrawable) {
        return ((BitmapDrawable) drawable).getBitmap();
    } else if (drawable instanceof NinePatchDrawable) {
        Bitmap bitmap = Bitmap
                .createBitmap(
                        drawable.getIntrinsicWidth(),
                        drawable.getIntrinsicHeight(),
                        drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888
                                : Bitmap.Config.RGB_565);
        Canvas canvas = new Canvas(bitmap);
        drawable.setBounds(0, 0, drawable.getIntrinsicWidth(),
                drawable.getIntrinsicHeight());
        drawable.draw(canvas);
        return bitmap;
    } else {
        return null;
    }
}
项目:smconf-android    文件:DrawShadowFrameLayout.java   
public DrawShadowFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    final TypedArray a = context.obtainStyledAttributes(attrs,
            R.styleable.DrawShadowFrameLayout, 0, 0);

    mShadowDrawable = a.getDrawable(R.styleable.DrawShadowFrameLayout_shadowDrawable);
    if (mShadowDrawable != null) {
        mShadowDrawable.setCallback(this);
        if (mShadowDrawable instanceof NinePatchDrawable) {
            mShadowNinePatchDrawable = (NinePatchDrawable) mShadowDrawable;
        }
    }

    mShadowVisible = a.getBoolean(R.styleable.DrawShadowFrameLayout_shadowVisible, true);
    setWillNotDraw(!mShadowVisible || mShadowDrawable == null);

    a.recycle();
}
项目:ScribaNotesApp    文件:ForegroundRelativeLayout.java   
public ForegroundRelativeLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ForegroundRelativeLayout,
            defStyle, 0);

    final Drawable d = a.getDrawable(R.styleable.ForegroundRelativeLayout_foreground);
    if (d != null) {
        setForeground(d);
    }

    a.recycle();

    if (this.getBackground() instanceof NinePatchDrawable) {
        final NinePatchDrawable npd = (NinePatchDrawable) this.getBackground();
        mRectPadding = new Rect();
        if (npd.getPadding(mRectPadding)) {
         mUseBackgroundPadding = true;
        }
    }
}
项目:CanPhotos    文件:CanViewPagerActivity.java   
/**
 * Drawable 转 bitmap
 *
 * @param drawable
 * @return
 */
public Bitmap drawable2Bitmap(Drawable drawable) {
    if (drawable instanceof BitmapDrawable) {
        return ((BitmapDrawable) drawable).getBitmap();
    } else if (drawable instanceof NinePatchDrawable) {
        Bitmap bitmap = Bitmap
                .createBitmap(
                        drawable.getIntrinsicWidth(),
                        drawable.getIntrinsicHeight(),
                        drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888
                                : Bitmap.Config.RGB_565);
        Canvas canvas = new Canvas(bitmap);
        drawable.setBounds(0, 0, drawable.getIntrinsicWidth(),
                drawable.getIntrinsicHeight());
        drawable.draw(canvas);
        return bitmap;
    } else {
        return null;
    }
}
项目:HaiNaBaiChuan    文件:DepthRendrer.java   
void setup() {
    getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
        @Override
        public boolean onPreDraw() {
            for (int i = 0; i < getChildCount(); i++) {
                View child = getChildAt(i);
                if (child instanceof DepthLayout) {
                    boolean hasChangedBounds = ((DepthLayout) child).calculateBounds();
                    if (hasChangedBounds)
                        invalidate();
                }
            }
            return true;
        }
    });

    shadowPaint.setColor(Color.BLACK);
    shadowPaint.setAntiAlias(true);
    softShadow = (NinePatchDrawable) getResources().getDrawable(R.drawable.shadow, null);
    roundSoftShadow = getResources().getDrawable(R.drawable.round_soft_shadow, null);
}
项目:LLApp    文件:DanMuHelper.java   
/**
 * Drawable转换成Bitmap
 *
 * @param drawable
 * @return
 */
public Bitmap drawable2Bitmap(Drawable drawable) {
    if (drawable instanceof BitmapDrawable) {
        // 转换成Bitmap
        return ((BitmapDrawable) drawable).getBitmap();
    } else if (drawable instanceof NinePatchDrawable) {
        // .9图片转换成Bitmap
        Bitmap bitmap = Bitmap.createBitmap(
                drawable.getIntrinsicWidth(),
                drawable.getIntrinsicHeight(),
                drawable.getOpacity() != PixelFormat.OPAQUE ?
                        Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565);
        Canvas canvas = new Canvas(bitmap);
        drawable.setBounds(0, 0, drawable.getIntrinsicWidth(),
                drawable.getIntrinsicHeight());
        drawable.draw(canvas);
        return bitmap;
    } else {
        return null;
    }
}
项目:gank    文件:DrawShadowFrameLayout.java   
public DrawShadowFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    final TypedArray a = context.obtainStyledAttributes(attrs,
            R.styleable.DrawShadowFrameLayout, 0, 0);

    mShadowDrawable = a.getDrawable(R.styleable.DrawShadowFrameLayout_shadowDrawable);
    if (mShadowDrawable != null) {
        mShadowDrawable.setCallback(this);
        if (mShadowDrawable instanceof NinePatchDrawable) {
            mShadowNinePatchDrawable = (NinePatchDrawable) mShadowDrawable;
        }
    }

    mShadowVisible = a.getBoolean(R.styleable.DrawShadowFrameLayout_shadowVisible, true);
    setWillNotDraw(!mShadowVisible || mShadowDrawable == null);

    a.recycle();
}
项目:RetailStore    文件:DrawShadowFrameLayout.java   
public DrawShadowFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    final TypedArray a = context.obtainStyledAttributes(attrs,
            R.styleable.DrawShadowFrameLayout, 0, 0);

    mShadowDrawable = a.getDrawable(R.styleable.DrawShadowFrameLayout_shadowDrawable);
    if (mShadowDrawable != null) {
        mShadowDrawable.setCallback(this);
        if (mShadowDrawable instanceof NinePatchDrawable) {
            mShadowNinePatchDrawable = (NinePatchDrawable) mShadowDrawable;
        }
    }

    mShadowVisible = a.getBoolean(R.styleable.DrawShadowFrameLayout_shadowVisible, true);
    setWillNotDraw(!mShadowVisible || mShadowDrawable == null);

    a.recycle();
}
项目:expandable-recyclerview-with-gridlayout    文件:DraggingItemDecorator.java   
private Bitmap createDraggingItemImage(View v, NinePatchDrawable shadow) {
    int width = v.getWidth() + mShadowPadding.left + mShadowPadding.right;
    int height = v.getHeight() + mShadowPadding.top + mShadowPadding.bottom;

    final Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);

    final Canvas canvas = new Canvas(bitmap);

    if (shadow != null) {
        shadow.setBounds(0, 0, width, height);
        shadow.draw(canvas);
    }

    final int savedCount = canvas.save(Canvas.CLIP_SAVE_FLAG | Canvas.MATRIX_SAVE_FLAG);
    // NOTE: Explicitly set clipping rect. This is required on Gingerbread.
    canvas.clipRect(mShadowPadding.left, mShadowPadding.top, width - mShadowPadding.right, height - mShadowPadding.bottom);
    canvas.translate(mShadowPadding.left, mShadowPadding.top);
    v.draw(canvas);
    canvas.restoreToCount(savedCount);

    return bitmap;
}
项目:2015-Google-I-O-app    文件:DrawShadowFrameLayout.java   
public DrawShadowFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    final TypedArray a = context.obtainStyledAttributes(attrs,
            R.styleable.DrawShadowFrameLayout, 0, 0);

    mShadowDrawable = a.getDrawable(R.styleable.DrawShadowFrameLayout_shadowDrawable);
    if (mShadowDrawable != null) {
        mShadowDrawable.setCallback(this);
        if (mShadowDrawable instanceof NinePatchDrawable) {
            mShadowNinePatchDrawable = (NinePatchDrawable) mShadowDrawable;
        }
    }

    mShadowVisible = a.getBoolean(R.styleable.DrawShadowFrameLayout_shadowVisible, true);
    setWillNotDraw(!mShadowVisible || mShadowDrawable == null);

    a.recycle();
}
项目:Practice    文件:BitmapUtils.java   
public static Bitmap drawable2Bitmap(Drawable drawable) {
    if (drawable instanceof BitmapDrawable) {
        return ((BitmapDrawable) drawable).getBitmap();
    } else if (drawable instanceof NinePatchDrawable) {
        Bitmap bitmap = Bitmap
                .createBitmap(
                        drawable.getIntrinsicWidth(),
                        drawable.getIntrinsicHeight(),
                        drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888
                                : Bitmap.Config.RGB_565);
        Canvas canvas = new Canvas(bitmap);
        drawable.setBounds(0, 0, drawable.getIntrinsicWidth(),
                drawable.getIntrinsicHeight());
        drawable.draw(canvas);
        return bitmap;
    } else {
        return null;
    }
}
项目:Practice    文件:BitmapUtils.java   
public static Bitmap drawable2Bitmap(Drawable drawable) {
    if (drawable instanceof BitmapDrawable) {
        return ((BitmapDrawable) drawable).getBitmap();
    } else if (drawable instanceof NinePatchDrawable) {
        Bitmap bitmap = Bitmap
                .createBitmap(
                        drawable.getIntrinsicWidth(),
                        drawable.getIntrinsicHeight(),
                        drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888
                                : Bitmap.Config.RGB_565);
        Canvas canvas = new Canvas(bitmap);
        drawable.setBounds(0, 0, drawable.getIntrinsicWidth(),
                drawable.getIntrinsicHeight());
        drawable.draw(canvas);
        return bitmap;
    } else {
        return null;
    }
}
项目:Practice    文件:BitmapUtils.java   
public static Bitmap drawable2Bitmap(Drawable drawable) {
    if (drawable instanceof BitmapDrawable) {
        return ((BitmapDrawable) drawable).getBitmap();
    } else if (drawable instanceof NinePatchDrawable) {
        Bitmap bitmap = Bitmap
                .createBitmap(
                        drawable.getIntrinsicWidth(),
                        drawable.getIntrinsicHeight(),
                        drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888
                                : Bitmap.Config.RGB_565);
        Canvas canvas = new Canvas(bitmap);
        drawable.setBounds(0, 0, drawable.getIntrinsicWidth(),
                drawable.getIntrinsicHeight());
        drawable.draw(canvas);
        return bitmap;
    } else {
        return null;
    }
}
项目:android-myutils    文件:Image.java   
public static Bitmap drawable2Bitmap(Drawable drawable) {
    if (drawable instanceof BitmapDrawable) {
        return ((BitmapDrawable) drawable).getBitmap();
    } else if (drawable instanceof NinePatchDrawable) {
        Bitmap bitmap = Bitmap.createBitmap(
                drawable.getIntrinsicWidth(),
                drawable.getIntrinsicHeight(),
                drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565);
        Canvas canvas = new Canvas(bitmap);
        drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
        drawable.draw(canvas);
        return bitmap;
    } else {
        return null;
    }
}
项目:retrofit2_rxJava_MVP_download_example    文件:FileUtils.java   
public static Bitmap drawable2Bitmap(Drawable drawable) {
    if (drawable instanceof BitmapDrawable) {
        return ((BitmapDrawable) drawable).getBitmap();
    } else if (drawable instanceof NinePatchDrawable) {
        Bitmap bitmap = Bitmap
                .createBitmap(
                        drawable.getIntrinsicWidth(),
                        drawable.getIntrinsicHeight(),
                        drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888
                                : Bitmap.Config.RGB_565);
        Canvas canvas = new Canvas(bitmap);
        drawable.setBounds(0, 0, drawable.getIntrinsicWidth(),
                drawable.getIntrinsicHeight());
        drawable.draw(canvas);
        return bitmap;
    } else {
        return null;
    }
}
项目:FMTech    文件:dvl.java   
public dvl(Context paramContext, AttributeSet paramAttributeSet, int paramInt)
{
  super(paramContext, paramAttributeSet, paramInt);
  if (!j)
  {
    j = true;
    Resources localResources = paramContext.getResources();
    k = (NinePatchDrawable)localResources.getDrawable(efj.ov);
    l = localResources.getDrawable(efj.qM);
    a = (int)localResources.getDimension(efj.kU);
    b = (int)localResources.getDimension(efj.kV);
    c = (int)localResources.getDimension(efj.kW);
    d = (int)localResources.getDimension(efj.kT);
    int i1 = (int)localResources.getDimension(efj.Zp);
    m = i1;
    n = i1 << 1;
    int i2 = (int)localResources.getDimension(efj.Zq);
    e = i2;
    o = i2 << 1;
    new Rect();
  }
  this.h = new Rect();
  setClickable(true);
  setFocusable(true);
}
项目:FMTech    文件:DrawShadowFrameLayout.java   
public DrawShadowFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    final TypedArray a = context.obtainStyledAttributes(attrs,
            R.styleable.DrawShadowFrameLayout, 0, 0);

    mShadowDrawable = a.getDrawable(R.styleable.DrawShadowFrameLayout_shadowDrawable);
    if (mShadowDrawable != null) {
        mShadowDrawable.setCallback(this);
        if (mShadowDrawable instanceof NinePatchDrawable) {
            mShadowNinePatchDrawable = (NinePatchDrawable) mShadowDrawable;
        }
    }

    mShadowVisible = a.getBoolean(R.styleable.DrawShadowFrameLayout_shadowVisible, true);
    setWillNotDraw(!mShadowVisible || mShadowDrawable == null);

    a.recycle();
}
项目:OpenCVTour    文件:DraggingItemDecorator.java   
private Bitmap createDraggingItemImage(View v, NinePatchDrawable shadow) {
    int width = v.getWidth() + mShadowPadding.left + mShadowPadding.right;
    int height = v.getHeight() + mShadowPadding.top + mShadowPadding.bottom;

    final Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);

    final Canvas canvas = new Canvas(bitmap);

    if (shadow != null) {
        shadow.setBounds(0, 0, width, height);
        shadow.draw(canvas);
    }

    final int savedCount = canvas.save(Canvas.CLIP_SAVE_FLAG | Canvas.MATRIX_SAVE_FLAG);
    // NOTE: Explicitly set clipping rect. This is required on Gingerbread.
    canvas.clipRect(mShadowPadding.left, mShadowPadding.top, width - mShadowPadding.right, height - mShadowPadding.bottom);
    canvas.translate(mShadowPadding.left, mShadowPadding.top);
    v.draw(canvas);
    canvas.restoreToCount(savedCount);

    return bitmap;
}
项目:FastAccess    文件:FloatingDrawerView.java   
@SuppressLint("InflateParams")
@Override public void onShow(@NonNull WindowManager windowManager, @NonNull View view, @NonNull FolderModel folder) {
    this.windowManager = windowManager;
    Context context = view.getContext();
    drawerHolder = new AppDrawerHolder(LayoutInflater.from(view.getContext()).inflate(R.layout.floating_folder_layout, null, false), this);
    adapter = new FloatingFolderAppsAdapter(new ArrayList<AppsModel>(), getPresenter(), false);
    drawerHolder.recycler.setAdapter(adapter);
    drawerHolder.emptyText.setText(R.string.no_apps);
    drawerHolder.recycler.setEmptyView(drawerHolder.emptyText);
    drawerHolder.folderName.setText(folder.getFolderName());
    NinePatchDrawable drawable = (NinePatchDrawable) drawerHolder.appDrawer.getBackground();
    drawable.setColorFilter(new PorterDuffColorFilter(folder.getColor(),
            PorterDuff.Mode.MULTIPLY));
    setupParams(windowManager);
    appsLoader = new SelectedAppsLoader(context, folder.getId());
    appsLoader.registerListener(folder.hashCode(), getPresenter());
    appsLoader.startLoading();
}
项目:soulissapp    文件:LineView.java   
/**
 * @param canvas The canvas you need to draw on.
 * @param point  The Point consists of the x y coordinates from left bottom to right top.
 *               Like is
 *               <p/>
 *               3
 *               2
 *               1
 *               0 1 2 3 4 5
 */
private void drawPopup(Canvas canvas, String num, Point point, int PopupColor) {
    boolean singularNum = (num.length() == 1);
    int sidePadding = ChartUtils.dip2px(getContext(), singularNum ? 8 : 5);
    int x = point.x;
    int y = point.y - ChartUtils.dip2px(getContext(), 5);
    Rect popupTextRect = new Rect();
    popupTextPaint.getTextBounds(num, 0, num.length(), popupTextRect);
    Rect r = new Rect(x - popupTextRect.width() / 2 - sidePadding,
            y - popupTextRect.height() - bottomTriangleHeight - popupTopPadding * 2 - popupBottomMargin,
            x + popupTextRect.width() / 2 + sidePadding,
            y + popupTopPadding - popupBottomMargin);

    NinePatchDrawable popup = (NinePatchDrawable) getResources().getDrawable(PopupColor);
    popup.setBounds(r);
    popup.draw(canvas);
    canvas.drawText(num, x, y - bottomTriangleHeight - popupBottomMargin, popupTextPaint);
}
项目:sonarflow-android    文件:BubbleRessources.java   
public BubbleRessources(Context context) {
    backgroundColor = Color.argb(255, 0, 0, 0);
    textPaint = new Paint(Paint.LINEAR_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
    textPaint.setColor(Color.WHITE);
    final int LABEL_TEXT_SIZE_DP = 13; // DP
    textPaint.setTextSize(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
            LABEL_TEXT_SIZE_DP, context.getResources().getDisplayMetrics()));
    textPaint.setShadowLayer(2, 1, 1, Color.BLACK);
    labelBackground = (NinePatchDrawable) context.getResources().getDrawable(R.drawable.bubble_text_background);
    labelPadding = new Rect();
    labelBackground.getPadding(labelPadding);
    bubbleGlow = context.getResources().getDrawable(R.drawable.bubble_glow_256);
    bubbleImages = new Drawable[4];
    bubbleImages[0] = context.getResources().getDrawable(R.drawable.bubble_32);
    bubbleImages[1] = context.getResources().getDrawable(R.drawable.bubble_64);
    bubbleImages[2] = context.getResources().getDrawable(R.drawable.bubble_128);
    bubbleImages[3] = context.getResources().getDrawable(R.drawable.bubble_256);
    discoveryBubble = context.getResources().getDrawable(R.drawable.similar_bubble);
    colorFilters = new ColorFilters(Mode.MULTIPLY);
}
项目:nexus-gallery    文件:ImageShow.java   
private void setupImageShow(Context context) {
    Resources res = context.getResources();
    mTextSize = res.getDimensionPixelSize(R.dimen.photoeditor_text_size);
    mTextPadding = res.getDimensionPixelSize(R.dimen.photoeditor_text_padding);
    mOriginalTextMargin = res.getDimensionPixelSize(R.dimen.photoeditor_original_text_margin);
    mOriginalTextSize = res.getDimensionPixelSize(R.dimen.photoeditor_original_text_size);
    mBackgroundColor = res.getColor(R.color.background_screen);
    mOriginalText = res.getString(R.string.original_picture_text);
    mShadow = (NinePatchDrawable) res.getDrawable(R.drawable.geometry_shadow);
    setupGestureDetector(context);
    mActivity = (FilterShowActivity) context;
    if (sMask == null) {
        Bitmap mask = BitmapFactory.decodeResource(res, R.drawable.spot_mask);
        sMask = convertToAlphaMask(mask);
    }
    mEdgeEffect = new EdgeEffectCompat(context);
    mEdgeSize = res.getDimensionPixelSize(R.dimen.edge_glow_size);
}
项目:nexus-gallery    文件:ImageDraw.java   
private void setupConstants(Context context){
    Resources res = context.getResources();
    mDisplayRound = res.getDimensionPixelSize(R.dimen.draw_rect_round);
    mDisplayBorder = res.getDimensionPixelSize(R.dimen.draw_rect_border);
    mBorderShadowSize = res.getDimensionPixelSize(R.dimen.draw_rect_shadow);
    float edge = res.getDimensionPixelSize(R.dimen.draw_rect_border_edge);

    mBorderColor = res.getColor(R.color.draw_rect_border);
    mBorderPaint.setColor(mBorderColor);
    mBorderPaint.setStyle(Paint.Style.STROKE);
    mBorderPaint.setStrokeWidth(edge);
    mShadowPaint.setStyle(Paint.Style.FILL);
    mShadowPaint.setColor(Color.BLACK);
    mShadowPaint.setShadowLayer(mBorderShadowSize,mBorderShadowSize,
            mBorderShadowSize,Color.BLACK);
    mShadow = (NinePatchDrawable) res.getDrawable(R.drawable.geometry_shadow);
}
项目:Android-SmartChart    文件:DrawUtils.java   
/**
 * Drawable ת bitmap
 * 
 * @param drawable
 * @return
 */
public static Bitmap drawable2Bitmap(Drawable drawable)
{
    if (drawable instanceof BitmapDrawable)
    {
        return ((BitmapDrawable) drawable).getBitmap();
    }
    else if (drawable instanceof NinePatchDrawable)
    {
        Bitmap bitmap =
                    Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), drawable
                                .getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888
                                : Bitmap.Config.RGB_565);
        Canvas canvas = new Canvas(bitmap);
        drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
        drawable.draw(canvas);
        return bitmap;
    }
    else
    {
        return null;
    }
}
项目:Lollipop-AppCompat-Widgets-Skeleton    文件:DrawShadowFrameLayout.java   
public DrawShadowFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    final TypedArray a = context.obtainStyledAttributes(attrs,
            R.styleable.DrawShadowFrameLayout, 0, 0);

    mShadowDrawable = a.getDrawable(R.styleable.DrawShadowFrameLayout_shadowDrawable);
    if (mShadowDrawable != null) {
        mShadowDrawable.setCallback(this);
        if (mShadowDrawable instanceof NinePatchDrawable) {
            mShadowNinePatchDrawable = (NinePatchDrawable) mShadowDrawable;
        }
    }

    mShadowVisible = a.getBoolean(R.styleable.DrawShadowFrameLayout_shadowVisible, true);
    setWillNotDraw(!mShadowVisible || mShadowDrawable == null);

    a.recycle();
}
项目:actor-platform    文件:ImageDrawing.java   
/**
 * Drawing src bitmap to dest bitmap with applied mask.
 *
 * @param src        source bitmap
 * @param mask       bitmap mask
 * @param dest       destination bitmap
 * @param clearColor clear color
 */
public static void drawMasked(Bitmap src, Drawable mask, Bitmap dest, int clearColor) {
    clearBitmap(dest, clearColor);
    Canvas canvas = new Canvas(dest);

    canvas.drawBitmap(src,
            new Rect(0, 0, src.getWidth(), src.getHeight()),
            new Rect(0, 0, dest.getWidth(), dest.getHeight()),
            new Paint(Paint.FILTER_BITMAP_FLAG));

    if (mask instanceof BitmapDrawable) {
        ((BitmapDrawable) mask).getPaint().setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
    } else if (mask instanceof NinePatchDrawable) {
        ((NinePatchDrawable) mask).getPaint().setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
    } else {
        throw new RuntimeException("Supported only BitmapDrawable or NinePatchDrawable");
    }
    mask.setBounds(0, 0, mask.getIntrinsicWidth(), mask.getIntrinsicHeight());
    mask.draw(canvas);
    canvas.setBitmap(null);
}
项目:Android-nRF-Toolbox    文件:ForegroundRelativeLayout.java   
public ForegroundRelativeLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ForegroundRelativeLayout,
            defStyle, 0);

    final Drawable d = a.getDrawable(R.styleable.ForegroundRelativeLayout_foreground);
    if (d != null) {
        setForeground(d);
    }

    a.recycle();

    if (this.getBackground() instanceof NinePatchDrawable) {
        final NinePatchDrawable npd = (NinePatchDrawable) this.getBackground();
        mRectPadding = new Rect();
        if (npd.getPadding(mRectPadding)) {
         mUseBackgroundPadding = true;
        }
    }
}
项目:Android-nRF-Toolbox    文件:ForegroundLinearLayout.java   
public ForegroundLinearLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ForegroundLinearLayout,
            defStyle, 0);

    final Drawable d = a.getDrawable(R.styleable.ForegroundRelativeLayout_foreground);
    if (d != null) {
        setForeground(d);
    }

    a.recycle();

    if (this.getBackground() instanceof NinePatchDrawable) {
        final NinePatchDrawable npd = (NinePatchDrawable) this.getBackground();
        mRectPadding = new Rect();
        if (npd.getPadding(mRectPadding)) {
         mUseBackgroundPadding = true;
        }
    }
}