use of android.annotation.TargetApi in project UltimateAndroid by cymcsg.
the class FancyCoverFlowItemWrapper method dispatchDraw.
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
protected void dispatchDraw(Canvas canvas) {
View childView = getChildAt(0);
if (childView != null) {
// If on honeycomb or newer, cache the view.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
if (childView.isDirty()) {
childView.draw(this.wrappedViewDrawingCanvas);
if (this.isReflectionEnabled) {
this.createReflectedImages();
}
}
} else {
childView.draw(this.wrappedViewDrawingCanvas);
}
}
canvas.drawBitmap(this.wrappedViewBitmap, (this.getWidth() - childView.getWidth()) / 2, 0, paint);
}
use of android.annotation.TargetApi in project DroidPlugin by DroidPluginTeam.
the class PluginInstrumentation method fixTaskDescription.
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void fixTaskDescription(Activity activity, ActivityInfo targetInfo) {
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
PackageManager pm = mHostContext.getPackageManager();
String lablel = String.valueOf(targetInfo.loadLabel(pm));
Drawable icon = targetInfo.loadIcon(pm);
Bitmap bitmap = null;
if (icon instanceof BitmapDrawable) {
bitmap = ((BitmapDrawable) icon).getBitmap();
}
if (bitmap != null) {
activity.setTaskDescription(new android.app.ActivityManager.TaskDescription(lablel, bitmap));
} else {
activity.setTaskDescription(new android.app.ActivityManager.TaskDescription(lablel));
}
}
} catch (Throwable e) {
Log.w(TAG, "fixTaskDescription fail", e);
}
}
use of android.annotation.TargetApi in project AndroidUtilCode by Blankj.
the class ImageUtils method renderScriptBlur.
/**
* renderScript模糊图片
* <p>API大于17</p>
*
* @param context 上下文
* @param src 源图片
* @param radius 模糊半径(0...25)
* @return 模糊后的图片
*/
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public static Bitmap renderScriptBlur(Context context, Bitmap src, @FloatRange(from = 0, to = 25, fromInclusive = false) float radius) {
if (isEmptyBitmap(src))
return null;
RenderScript rs = null;
try {
rs = RenderScript.create(context);
rs.setMessageHandler(new RenderScript.RSMessageHandler());
Allocation input = Allocation.createFromBitmap(rs, src, Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);
Allocation output = Allocation.createTyped(rs, input.getType());
ScriptIntrinsicBlur blurScript = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
blurScript.setInput(input);
blurScript.setRadius(radius);
blurScript.forEach(output);
output.copyTo(src);
} finally {
if (rs != null) {
rs.destroy();
}
}
return src;
}
use of android.annotation.TargetApi in project AndroidUtilCode by Blankj.
the class SDCardUtils method getFreeSpace.
/**
* 获取SD卡剩余空间
*
* @return SD卡剩余空间
*/
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
public static String getFreeSpace() {
if (!isSDCardEnable())
return null;
StatFs stat = new StatFs(getSDCardPath());
long blockSize, availableBlocks;
availableBlocks = stat.getAvailableBlocksLong();
blockSize = stat.getBlockSizeLong();
return ConvertUtils.byte2FitMemorySize(availableBlocks * blockSize);
}
use of android.annotation.TargetApi in project FloatingActionButton by Clans.
the class FloatingActionButton method onActionDown.
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
void onActionDown() {
if (mBackgroundDrawable instanceof StateListDrawable) {
StateListDrawable drawable = (StateListDrawable) mBackgroundDrawable;
drawable.setState(new int[] { android.R.attr.state_enabled, android.R.attr.state_pressed });
} else if (Util.hasLollipop()) {
RippleDrawable ripple = (RippleDrawable) mBackgroundDrawable;
ripple.setState(new int[] { android.R.attr.state_enabled, android.R.attr.state_pressed });
ripple.setHotspot(calculateCenterX(), calculateCenterY());
ripple.setVisible(true, true);
}
}
Aggregations