android add image node
This commit is contained in:
@@ -1,10 +1,19 @@
|
||||
package com.github.penfeizhou.doric.shader;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.load.DataSource;
|
||||
import com.bumptech.glide.load.engine.GlideException;
|
||||
import com.bumptech.glide.request.RequestListener;
|
||||
import com.bumptech.glide.request.target.Target;
|
||||
import com.github.penfeizhou.doric.DoricContext;
|
||||
import com.github.penfeizhou.doric.extension.bridge.DoricPlugin;
|
||||
import com.github.pengfeizhou.jscore.JSObject;
|
||||
import com.github.pengfeizhou.jscore.JSValue;
|
||||
|
||||
/**
|
||||
* @Description: com.github.penfeizhou.doric.widget
|
||||
@@ -19,6 +28,27 @@ public class ImageNode extends ViewNode<ImageView> {
|
||||
|
||||
@Override
|
||||
protected ImageView build(JSObject jsObject) {
|
||||
return null;
|
||||
return new ImageView(getContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void blend(ImageView view, ViewGroup.LayoutParams layoutParams, String name, JSValue prop) {
|
||||
if ("imageUrl".equals(name)) {
|
||||
Glide.with(getContext()).load(prop.asString().value())
|
||||
.listener(new RequestListener<Drawable>() {
|
||||
@Override
|
||||
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.into(view);
|
||||
} else {
|
||||
super.blend(view, layoutParams, name, prop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user