Search in sources :

Example 41 with TargetApi

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);
}
Also used : View(android.view.View) TargetApi(android.annotation.TargetApi)

Example 42 with TargetApi

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);
    }
}
Also used : Bitmap(android.graphics.Bitmap) PackageManager(android.content.pm.PackageManager) Drawable(android.graphics.drawable.Drawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) TargetApi(android.annotation.TargetApi)

Example 43 with TargetApi

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;
}
Also used : RenderScript(android.renderscript.RenderScript) Allocation(android.renderscript.Allocation) ScriptIntrinsicBlur(android.renderscript.ScriptIntrinsicBlur) TargetApi(android.annotation.TargetApi)

Example 44 with TargetApi

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);
}
Also used : StatFs(android.os.StatFs) TargetApi(android.annotation.TargetApi)

Example 45 with TargetApi

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);
    }
}
Also used : StateListDrawable(android.graphics.drawable.StateListDrawable) RippleDrawable(android.graphics.drawable.RippleDrawable) TargetApi(android.annotation.TargetApi)

Aggregations

TargetApi (android.annotation.TargetApi)1367 Intent (android.content.Intent)153 View (android.view.View)148 Test (org.junit.Test)119 SuppressLint (android.annotation.SuppressLint)115 Uri (android.net.Uri)70 ArrayList (java.util.ArrayList)68 Animator (android.animation.Animator)67 Point (android.graphics.Point)64 Window (android.view.Window)56 TextView (android.widget.TextView)56 IOException (java.io.IOException)56 ViewGroup (android.view.ViewGroup)54 Matchers.anyString (org.mockito.Matchers.anyString)53 SharedPreferences (android.content.SharedPreferences)44 File (java.io.File)44 Field (java.lang.reflect.Field)44 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)43 Bitmap (android.graphics.Bitmap)43 ImageView (android.widget.ImageView)40