android add image node
This commit is contained in:
parent
bb86c3c332
commit
471e87badc
@ -29,4 +29,8 @@ dependencies {
|
|||||||
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
|
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
|
||||||
implementation project(':doric')
|
implementation project(':doric')
|
||||||
implementation 'org.nanohttpd:nanohttpd:2.3.1'
|
implementation 'org.nanohttpd:nanohttpd:2.3.1'
|
||||||
|
implementation 'com.github.bumptech.glide:glide:4.8.0'
|
||||||
|
implementation 'com.github.bumptech.glide:annotations:4.8.0'
|
||||||
|
implementation 'com.github.penfeizhou.android.animation:glide-plugin:1.0.1'
|
||||||
|
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
package com.github.penfeizhou.doricdemo;
|
||||||
|
|
||||||
|
import com.bumptech.glide.annotation.GlideModule;
|
||||||
|
import com.bumptech.glide.module.AppGlideModule;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: com.github.penfeizhou.doricdemo
|
||||||
|
* @Author: pengfei.zhou
|
||||||
|
* @CreateDate: 2019-08-06
|
||||||
|
*/
|
||||||
|
@GlideModule
|
||||||
|
public class MyGlideModule extends AppGlideModule {
|
||||||
|
}
|
@ -45,5 +45,6 @@ dependencies {
|
|||||||
androidTestImplementation 'com.android.support.test:runner:1.0.2'
|
androidTestImplementation 'com.android.support.test:runner:1.0.2'
|
||||||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
|
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
|
||||||
api 'com.github.pengfeizhou:jsc4a:0.1.0'
|
api 'com.github.pengfeizhou:jsc4a:0.1.0'
|
||||||
implementation("com.squareup.okhttp3:okhttp:3.11.0")
|
implementation "com.squareup.okhttp3:okhttp:3.11.0"
|
||||||
|
implementation 'com.github.penfeizhou.android.animation:glide-plugin:1.0.1'
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,19 @@
|
|||||||
package com.github.penfeizhou.doric.shader;
|
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 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.DoricContext;
|
||||||
import com.github.penfeizhou.doric.extension.bridge.DoricPlugin;
|
import com.github.penfeizhou.doric.extension.bridge.DoricPlugin;
|
||||||
import com.github.pengfeizhou.jscore.JSObject;
|
import com.github.pengfeizhou.jscore.JSObject;
|
||||||
|
import com.github.pengfeizhou.jscore.JSValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description: com.github.penfeizhou.doric.widget
|
* @Description: com.github.penfeizhou.doric.widget
|
||||||
@ -19,6 +28,27 @@ public class ImageNode extends ViewNode<ImageView> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ImageView build(JSObject jsObject) {
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
LICENSE
2
LICENSE
@ -186,7 +186,7 @@
|
|||||||
same "printed page" as the copyright notice for easier
|
same "printed page" as the copyright notice for easier
|
||||||
identification within third-party archives.
|
identification within third-party archives.
|
||||||
|
|
||||||
Copyright [yyyy] [name of copyright owner]
|
Copyright [2019] [Zhou Pengfei]
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { HLayout, StackConfig, ViewHolder, VMPanel, View, ViewModel, WRAP_CONTENT, Gravity, Mutable, NativeCall, Text, Color, VLayout, Panel, log, logw, loge, Group, Stack, } from "./index"
|
import { HLayout, Image, ViewHolder, VMPanel, View, ViewModel, WRAP_CONTENT, Gravity, Mutable, NativeCall, Text, Color, VLayout, Panel, log, logw, loge, Group, Stack, } from "./index"
|
||||||
|
|
||||||
|
|
||||||
interface CountModel {
|
interface CountModel {
|
||||||
@ -53,6 +53,11 @@ class CounterView extends ViewHolder {
|
|||||||
// root.bgColor = Color.parse('#00ff00')
|
// root.bgColor = Color.parse('#00ff00')
|
||||||
vlayout.bgColor = Color.parse('#ff00ff')
|
vlayout.bgColor = Color.parse('#ff00ff')
|
||||||
root.addChild(vlayout)
|
root.addChild(vlayout)
|
||||||
|
const iv = new Image
|
||||||
|
// iv.width = iv.height = 100
|
||||||
|
iv.imageUrl = "https://misc.aotu.io/ONE-SUNDAY/SteamEngine.png"
|
||||||
|
//iv.bgColor = Color.parse('#00ff00')
|
||||||
|
root.addChild(iv)
|
||||||
}
|
}
|
||||||
|
|
||||||
setNumber(n: number) {
|
setNumber(n: number) {
|
||||||
|
Reference in New Issue
Block a user