android:avoid crash while compating different glide version

This commit is contained in:
pengfei.zhou 2020-03-03 11:25:54 +08:00 committed by osborn
parent b6eba02496
commit a3148ef065

View File

@ -23,6 +23,7 @@ import android.util.Base64;
import android.widget.ImageView; import android.widget.ImageView;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestBuilder;
import com.bumptech.glide.load.DataSource; import com.bumptech.glide.load.DataSource;
import com.bumptech.glide.load.engine.GlideException; import com.bumptech.glide.load.engine.GlideException;
import com.bumptech.glide.request.RequestListener; import com.bumptech.glide.request.RequestListener;
@ -36,6 +37,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import jp.wasabeef.glide.transformations.BlurTransformation; import jp.wasabeef.glide.transformations.BlurTransformation;
import pub.doric.DoricContext; import pub.doric.DoricContext;
import pub.doric.extension.bridge.DoricPlugin; import pub.doric.extension.bridge.DoricPlugin;
@ -75,14 +77,14 @@ public class ImageNode extends ViewNode<ImageView> {
protected void blend(ImageView view, String name, JSValue prop) { protected void blend(ImageView view, String name, JSValue prop) {
switch (name) { switch (name) {
case "imageUrl": case "imageUrl":
RequestOptions options;
RequestBuilder<Drawable> requestBuilder = Glide.with(getContext()).load(prop.asString().value());
if (isBlur) { if (isBlur) {
options = RequestOptions.bitmapTransform(new BlurTransformation(25, 3)); requestBuilder = requestBuilder
} else { .apply(RequestOptions
options = new RequestOptions(); .bitmapTransform(new BlurTransformation(25, 3)));
} }
Glide.with(getContext()).load(prop.asString().value()) requestBuilder
.apply(options)
.listener(new RequestListener<Drawable>() { .listener(new RequestListener<Drawable>() {
@Override @Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) { public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {