success to callback onClick function
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.github.penfeizhou.doric.shader;
|
||||
|
||||
import android.util.TypedValue;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.github.penfeizhou.doric.DoricContext;
|
||||
@@ -29,6 +30,12 @@ public class TextNode extends ViewNode<TextView> {
|
||||
case "text":
|
||||
view.setText(prop.asString().toString());
|
||||
break;
|
||||
case "textSize":
|
||||
view.setTextSize(TypedValue.COMPLEX_UNIT_DIP, prop.asNumber().toFloat());
|
||||
break;
|
||||
case "textColor":
|
||||
view.setTextColor(prop.asNumber().toInt());
|
||||
break;
|
||||
default:
|
||||
super.blend(view, name, prop);
|
||||
break;
|
||||
|
@@ -78,6 +78,15 @@ public abstract class ViewNode<T extends View> extends DoricComponent {
|
||||
case "bgColor":
|
||||
view.setBackgroundColor(prop.asNumber().toInt());
|
||||
break;
|
||||
case "onClick":
|
||||
final String functionId = prop.asString().value();
|
||||
view.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
callJSResponse(functionId);
|
||||
}
|
||||
});
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -100,7 +109,7 @@ public abstract class ViewNode<T extends View> extends DoricComponent {
|
||||
}
|
||||
}
|
||||
|
||||
public void callJSRespone(String funcId, Object... args) {
|
||||
public void callJSResponse(String funcId, Object... args) {
|
||||
final Object[] nArgs = new Object[args.length + 2];
|
||||
nArgs[0] = ids.toArray(new String[0]);
|
||||
nArgs[1] = funcId;
|
||||
|
@@ -14,6 +14,7 @@ import com.github.pengfeizhou.jscore.JSONBuilder;
|
||||
import com.github.pengfeizhou.jscore.JSValue;
|
||||
import com.github.pengfeizhou.jscore.JavaValue;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -69,6 +70,12 @@ public class DoricUtils {
|
||||
return new JavaValue((Boolean) arg);
|
||||
} else if (arg instanceof JavaValue) {
|
||||
return (JavaValue) arg;
|
||||
} else if (arg instanceof Object[]) {
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
for (Object o : (Object[]) arg) {
|
||||
jsonArray.put(o);
|
||||
}
|
||||
return new JavaValue(jsonArray);
|
||||
} else {
|
||||
return new JavaValue(String.valueOf(arg));
|
||||
}
|
||||
|
Reference in New Issue
Block a user