Merge branch 'master' of code.aliyun.com:Doric/doric-Android
This commit is contained in:
commit
f9ff72c2ed
@ -38,6 +38,7 @@ dependencies {
|
|||||||
api 'com.github.pengfeizhou:jsc4a:0.1.0'
|
api 'com.github.pengfeizhou:jsc4a:0.1.0'
|
||||||
implementation 'com.squareup.okhttp3:okhttp:4.2.2'
|
implementation 'com.squareup.okhttp3:okhttp:4.2.2'
|
||||||
implementation 'com.github.penfeizhou.android.animation:glide-plugin:1.3.1'
|
implementation 'com.github.penfeizhou.android.animation:glide-plugin:1.3.1'
|
||||||
|
implementation 'jp.wasabeef:glide-transformations:4.1.0'
|
||||||
implementation 'com.google.code.gson:gson:2.8.6'
|
implementation 'com.google.code.gson:gson:2.8.6'
|
||||||
implementation "com.google.android.material:material:1.0.0"
|
implementation "com.google.android.material:material:1.0.0"
|
||||||
testImplementation 'junit:junit:4.12'
|
testImplementation 'junit:junit:4.12'
|
||||||
|
@ -17,11 +17,7 @@ package pub.doric.shader;
|
|||||||
|
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
import android.graphics.drawable.BitmapDrawable;
|
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Base64;
|
import android.util.Base64;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
@ -30,18 +26,21 @@ import com.bumptech.glide.Glide;
|
|||||||
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;
|
||||||
|
import com.bumptech.glide.request.RequestOptions;
|
||||||
import com.bumptech.glide.request.target.Target;
|
import com.bumptech.glide.request.target.Target;
|
||||||
|
|
||||||
import pub.doric.DoricContext;
|
|
||||||
import pub.doric.extension.bridge.DoricPlugin;
|
|
||||||
import pub.doric.utils.DoricUtils;
|
|
||||||
|
|
||||||
import com.github.pengfeizhou.jscore.JSONBuilder;
|
import com.github.pengfeizhou.jscore.JSONBuilder;
|
||||||
|
import com.github.pengfeizhou.jscore.JSObject;
|
||||||
import com.github.pengfeizhou.jscore.JSValue;
|
import com.github.pengfeizhou.jscore.JSValue;
|
||||||
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import jp.wasabeef.glide.transformations.BlurTransformation;
|
||||||
|
import pub.doric.DoricContext;
|
||||||
|
import pub.doric.extension.bridge.DoricPlugin;
|
||||||
|
import pub.doric.utils.DoricUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description: com.github.penfeizhou.doric.widget
|
* @Description: com.github.penfeizhou.doric.widget
|
||||||
* @Author: pengfei.zhou
|
* @Author: pengfei.zhou
|
||||||
@ -50,6 +49,7 @@ import java.util.regex.Pattern;
|
|||||||
@DoricPlugin(name = "Image")
|
@DoricPlugin(name = "Image")
|
||||||
public class ImageNode extends ViewNode<ImageView> {
|
public class ImageNode extends ViewNode<ImageView> {
|
||||||
private String loadCallbackId = "";
|
private String loadCallbackId = "";
|
||||||
|
private boolean isBlur;
|
||||||
|
|
||||||
public ImageNode(DoricContext doricContext) {
|
public ImageNode(DoricContext doricContext) {
|
||||||
super(doricContext);
|
super(doricContext);
|
||||||
@ -60,11 +60,29 @@ public class ImageNode extends ViewNode<ImageView> {
|
|||||||
return new ImageView(getContext());
|
return new ImageView(getContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void blend(JSObject jsObject) {
|
||||||
|
if(jsObject != null) {
|
||||||
|
JSValue jsValue = jsObject.getProperty("isBlur");
|
||||||
|
if(jsValue.isBoolean()) {
|
||||||
|
isBlur = jsValue.asBoolean().value();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
super.blend(jsObject);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
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;
|
||||||
|
if(isBlur) {
|
||||||
|
options = RequestOptions.bitmapTransform(new BlurTransformation(25, 3));
|
||||||
|
} else {
|
||||||
|
options = new RequestOptions();
|
||||||
|
}
|
||||||
Glide.with(getContext()).load(prop.asString().value())
|
Glide.with(getContext()).load(prop.asString().value())
|
||||||
|
.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) {
|
||||||
|
Reference in New Issue
Block a user