mirror of
https://github.com/wasabeef/glide-transformations.git
synced 2025-06-28 20:35:54 +08:00
refactor support rs (#142)
This commit is contained in:
parent
3aa8e53c6a
commit
2e2846d354
@ -6,6 +6,9 @@ android {
|
|||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion MIN_SDK_VERSION as int
|
minSdkVersion MIN_SDK_VERSION as int
|
||||||
targetSdkVersion TARGET_SDK_VERSION as int
|
targetSdkVersion TARGET_SDK_VERSION as int
|
||||||
|
|
||||||
|
renderscriptTargetApi TARGET_SDK_VERSION as int
|
||||||
|
renderscriptSupportModeEnabled true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,6 @@ import android.graphics.Bitmap;
|
|||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.renderscript.RSRuntimeException;
|
|
||||||
|
|
||||||
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
||||||
|
|
||||||
@ -29,6 +28,7 @@ import java.security.MessageDigest;
|
|||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import jp.wasabeef.glide.transformations.internal.FastBlur;
|
import jp.wasabeef.glide.transformations.internal.FastBlur;
|
||||||
|
import jp.wasabeef.glide.transformations.internal.RSBlur;
|
||||||
import jp.wasabeef.glide.transformations.internal.SupportRSBlur;
|
import jp.wasabeef.glide.transformations.internal.SupportRSBlur;
|
||||||
|
|
||||||
public class SupportRSBlurTransformation extends BitmapTransformation {
|
public class SupportRSBlurTransformation extends BitmapTransformation {
|
||||||
@ -76,7 +76,9 @@ public class SupportRSBlurTransformation extends BitmapTransformation {
|
|||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
|
||||||
try {
|
try {
|
||||||
bitmap = SupportRSBlur.blur(context, bitmap, radius);
|
bitmap = SupportRSBlur.blur(context, bitmap, radius);
|
||||||
} catch (RSRuntimeException e) {
|
} catch (NoClassDefFoundError e) {
|
||||||
|
bitmap = RSBlur.blur(context, bitmap, radius);
|
||||||
|
} catch (RuntimeException e) {
|
||||||
bitmap = FastBlur.blur(bitmap, radius, true);
|
bitmap = FastBlur.blur(bitmap, radius, true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -26,7 +26,6 @@ import android.renderscript.ScriptIntrinsicBlur;
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public class RSBlur {
|
public class RSBlur {
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
|
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
|
||||||
|
@ -4,11 +4,12 @@ import android.annotation.TargetApi;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.renderscript.Allocation;
|
|
||||||
import android.renderscript.Element;
|
import androidx.renderscript.Allocation;
|
||||||
import android.renderscript.RSRuntimeException;
|
import androidx.renderscript.Element;
|
||||||
import android.renderscript.RenderScript;
|
import androidx.renderscript.RSRuntimeException;
|
||||||
import android.renderscript.ScriptIntrinsicBlur;
|
import androidx.renderscript.RenderScript;
|
||||||
|
import androidx.renderscript.ScriptIntrinsicBlur;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copyright (C) 2018 Wasabeef
|
* Copyright (C) 2018 Wasabeef
|
||||||
|
Loading…
x
Reference in New Issue
Block a user