private static Bitmap getEmoji( Context context, String emoji, @DimenRes int sizeResId, @DimenRes int insetResId) { if (context == null || TextUtils.isEmpty(emoji)) { return null; } int size = context.getResources().getDimensionPixelSize(sizeResId); int inset = context.getResources().getDimensionPixelSize(insetResId); Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setStyle(Paint.Style.FILL); paint.setTextAlign(Paint.Align.LEFT); paint.setTextSize(size); float baseline = -paint.ascent(); int width = (int) (paint.measureText(emoji) + 0.5f); int height = (int) (baseline + paint.descent() + 0.5f); Bitmap bitmap = Bitmap.createBitmap(width + inset * 2, height + inset * 2, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); canvas.drawText(emoji, inset, baseline + inset, paint); return bitmap; }
public static CharacterDrawable create(Context context, char character, boolean roundAsCircle, @DimenRes int padding) { return new CharacterDrawable.Builder() .setCharacter(character) .setBackgroundRoundAsCircle(roundAsCircle) .setCharacterPadding(context.getResources().getDimensionPixelSize(padding)) .build(); }
public void setShadowsHeightDimens(@DimenRes int left, @DimenRes int top, @DimenRes int right, @DimenRes int bottom) { mShadowLeftHeight = mResources.getDimensionPixelOffset(left); mShadowTopHeight = mResources.getDimensionPixelOffset(top); mShadowRightHeight = mResources.getDimensionPixelOffset(right); mShadowBottomHeight = mResources.getDimensionPixelOffset(bottom); invalidate(); }
@Override public float getDimension(@DimenRes int id) throws NotFoundException { int realId = getCorrespondResId(id); if (realId > 0) { return mSkinResources.getDimension(realId); } return super.getDimension(id); }
@Override public int getDimensionPixelSize(@DimenRes int id) throws NotFoundException { int realId = getCorrespondResId(id); if (realId > 0) { return mSkinResources.getDimensionPixelSize(realId); } return super.getDimensionPixelSize(id); }
public Builder margin(@DimenRes int commonMargin) { margin.add(commonMargin); margin.add(commonMargin); margin.add(commonMargin); margin.add(commonMargin); return this; }
private void setAvatarSize(@DimenRes int res) { LayoutParams params = (LayoutParams) avatar.getLayoutParams(); int size = getResources().getDimensionPixelSize(res); params.height = size; params.width = size; avatar.setLayoutParams(params); }
/** * Set {@code start}, {@code top}, {@code end} and {@code bottom} padding for zooming and scrolling area using dimension. * * @return This Builder object to allow for chaining of calls to set methods */ public Builder setContainerPadding(Context context, @DimenRes int start, @DimenRes int top, @DimenRes int end, @DimenRes int bottom) { setContainerPaddingPx( Math.round(context.getResources().getDimension(start)), Math.round(context.getResources().getDimension(top)), Math.round(context.getResources().getDimension(end)), Math.round(context.getResources().getDimension(bottom)) ); return this; }
public Builder setDialogRadius(@DimenRes int dialogRadiusDimen) { this.dialogRadius = context.getResources().getDimensionPixelSize(dialogRadiusDimen); return this; }
public T sizeResId(@DimenRes int sizeId) { return size(mResources.getDimensionPixelSize(sizeId)); }
public Builder setErrorTextSizeResource(@DimenRes int mErrorTextSizeRes) { return setErrorTextSize(getDimensionPixelSize(mErrorTextSizeRes)); }
public Builder marginResId(@DimenRes int leftMarginId, @DimenRes int rightMarginId) { return margin(mResources.getDimensionPixelSize(leftMarginId), mResources.getDimensionPixelSize(rightMarginId)); }
public Builder marginResId(@DimenRes int topMarginId, @DimenRes int bottomMarginId) { return margin(mResources.getDimensionPixelSize(topMarginId), mResources.getDimensionPixelSize(bottomMarginId)); }
public void setCornerRadiusDimen(@DimenRes int resId) { float radius = getResources().getDimension(resId); setCornerRadius(radius, radius, radius, radius); }
public Builder setNoNetTextSizeResource(@DimenRes int mNoNetTextSizeRes) { return setNoNetTextSize(getDimensionPixelSize(mNoNetTextSizeRes)); }
public Builder marginResId(@DimenRes int verticalMarginId) { return marginResId(verticalMarginId, verticalMarginId); }
public Builder iconPaddingRes(@DimenRes int paddingRes) { return iconPadding(context.getResources().getDimensionPixelSize(paddingRes)); }
public void setLeftShadowDimens(@DimenRes int resource) { mShadowLeftHeight = mResources.getDimensionPixelOffset(resource); invalidate(); }
public int getDimensionPixelOffset(@DimenRes int id) { return getResources().getDimensionPixelOffset(id); }
public void setTopShadowDimens(@DimenRes int resource) { mShadowTopHeight = mResources.getDimensionPixelOffset(resource); invalidate(); }
public void setBorderWidth(@DimenRes int resId) { setBorderWidth(getResources().getDimension(resId)); }
public static BitmapDisplayConfig getDefaultUserAvatarConfigByDpRes(Context context, @DimenRes int dpRes) { int dp2px = context.getResources().getDimensionPixelSize(dpRes); return getDefaultUserAvatarConfig(context, dp2px); }
public ItemOffsetDecoration(@NonNull Context context, @DimenRes int itemOffsetId) { this(context.getResources().getDimensionPixelSize(itemOffsetId)); }
public BlankViewModel(@DimenRes int height) { this.height = height; }
public void setCornerRadiusDimen(int corner, @DimenRes int resId) { setCornerRadius(corner, (float) getResources().getDimensionPixelSize(resId)); }
public HeaderItemViewModel textSize(@DimenRes int testSize) { this.textSize = testSize; return this; }
public static int getDimens(Context context, @DimenRes int resource) { Resources mResources = context.getResources(); return mResources.getDimensionPixelSize(resource); }
public DividerItemDecoration(@NonNull Context context, @DimenRes int dimensionDivider) { this.space = context.getResources().getDimensionPixelSize(dimensionDivider); }
public static int getDimen(@DimenRes int dimenId) { return (int) CoreApp.getInstance().getResources().getDimension(dimenId); }
public Builder setEmptyTextSizeResource(@DimenRes int mEmptyTextSizeRes) { return setEmptyTextSize(getDimensionPixelSize(mEmptyTextSizeRes)); }
/** * Set common padding for zooming and scrolling area using dimension. * * @return This Builder object to allow for chaining of calls to set methods */ public Builder setContainerPadding(Context context, @DimenRes int padding) { int paddingPx = Math.round(context.getResources().getDimension(padding)); setContainerPaddingPx(paddingPx, paddingPx, paddingPx, paddingPx); return this; }
public void setHorizontalPadding(@DimenRes int horizontalPadding) { this.horizontalPadding = mContext.getResources().getDimensionPixelSize(horizontalPadding); }
public Builder setLoadFailTextSizeResource(@DimenRes int mLoadFailTextSizeRes) { return setLoadFailTextSize(getDimensionPixelSize(mLoadFailTextSizeRes)); }
/** * Sets the radius of the "hole" around the cast button. This will override the value * specified in the resource file and is optional. */ public Builder setFocusRadiusId(@DimenRes int radiusId) { mRadius = mContext.getResources().getDimension(radiusId); return this; }
public Builder marginResId(@DimenRes int horizontalMarginId) { return marginResId(horizontalMarginId, horizontalMarginId); }
public PositionAnimExpectation withMarginDimen(@DimenRes int marginRes){ this.marginRes = marginRes; return this; }