fix signature

This commit is contained in:
王劲鹏 2022-11-10 11:44:05 +08:00 committed by osborn
parent 7899896b80
commit f175a94b28

View File

@ -24,6 +24,7 @@ import android.text.TextUtils;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.Gravity; import android.view.Gravity;
import android.view.ViewTreeObserver; import android.view.ViewTreeObserver;
import android.widget.TextView;
import androidx.core.content.res.ResourcesCompat; import androidx.core.content.res.ResourcesCompat;
@ -54,13 +55,13 @@ import pub.doric.utils.ThreadMode;
* @CreateDate: 2019-07-20 * @CreateDate: 2019-07-20
*/ */
@DoricPlugin(name = "Text") @DoricPlugin(name = "Text")
public class TextNode extends ViewNode<DoricTextView> { public class TextNode extends ViewNode<TextView> {
public TextNode(DoricContext doricContext) { public TextNode(DoricContext doricContext) {
super(doricContext); super(doricContext);
} }
@Override @Override
protected DoricTextView build() { protected TextView build() {
DoricTextView tv = new DoricTextView(getContext()); DoricTextView tv = new DoricTextView(getContext());
tv.setGravity(Gravity.CENTER); tv.setGravity(Gravity.CENTER);
tv.setMaxLines(1); tv.setMaxLines(1);
@ -84,7 +85,7 @@ public class TextNode extends ViewNode<DoricTextView> {
} }
@Override @Override
protected void blend(final DoricTextView view, final String name, final JSValue prop) { protected void blend(final TextView view, final String name, final JSValue prop) {
switch (name) { switch (name) {
case "text": case "text":
if (!prop.isString()) { if (!prop.isString()) {
@ -172,7 +173,9 @@ public class TextNode extends ViewNode<DoricTextView> {
} }
} }
mView.setGradient(angle, colors, locations); if (mView instanceof DoricTextView) {
((DoricTextView) mView).setGradient(angle, colors, locations);
}
return true; return true;
} }
@ -306,12 +309,16 @@ public class TextNode extends ViewNode<DoricTextView> {
break; break;
case "strikethrough": case "strikethrough":
if (prop.isBoolean()) { if (prop.isBoolean()) {
view.setStrikethrough(prop.asBoolean().value()); if (mView instanceof DoricTextView) {
((DoricTextView) view).setStrikethrough(prop.asBoolean().value());
}
} }
break; break;
case "underline": case "underline":
if (prop.isBoolean()) { if (prop.isBoolean()) {
view.setUnderline(prop.asBoolean().value()); if (mView instanceof DoricTextView) {
((DoricTextView) view).setUnderline(prop.asBoolean().value());
}
} }
break; break;
case "htmlText": case "htmlText":
@ -383,13 +390,15 @@ public class TextNode extends ViewNode<DoricTextView> {
break; break;
case "shadow": case "shadow":
if (prop.isObject()) { if (prop.isObject()) {
mView.setShadow( if (mView instanceof DoricTextView) {
prop.asObject().getProperty("opacity").asNumber().toFloat(), ((DoricTextView) mView).setShadow(
prop.asObject().getProperty("radius").asNumber().toFloat(), prop.asObject().getProperty("opacity").asNumber().toFloat(),
DoricUtils.dp2px(prop.asObject().getProperty("offsetX").asNumber().toFloat()), prop.asObject().getProperty("radius").asNumber().toFloat(),
DoricUtils.dp2px(prop.asObject().getProperty("offsetY").asNumber().toFloat()), DoricUtils.dp2px(prop.asObject().getProperty("offsetX").asNumber().toFloat()),
prop.asObject().getProperty("color").asNumber().toInt() DoricUtils.dp2px(prop.asObject().getProperty("offsetY").asNumber().toFloat()),
); prop.asObject().getProperty("color").asNumber().toInt()
);
}
} }
break; break;
default: default: