Skip to content

Commit

Permalink
fix signature
Browse files Browse the repository at this point in the history
  • Loading branch information
jingpeng authored and penfeizhou committed Nov 10, 2022
1 parent 7899896 commit f175a94
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions doric-android/doric/src/main/java/pub/doric/shader/TextNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import android.util.TypedValue;
import android.view.Gravity;
import android.view.ViewTreeObserver;
import android.widget.TextView;

import androidx.core.content.res.ResourcesCompat;

Expand Down Expand Up @@ -54,13 +55,13 @@
* @CreateDate: 2019-07-20
*/
@DoricPlugin(name = "Text")
public class TextNode extends ViewNode<DoricTextView> {
public class TextNode extends ViewNode<TextView> {
public TextNode(DoricContext doricContext) {
super(doricContext);
}

@Override
protected DoricTextView build() {
protected TextView build() {
DoricTextView tv = new DoricTextView(getContext());
tv.setGravity(Gravity.CENTER);
tv.setMaxLines(1);
Expand All @@ -84,7 +85,7 @@ protected void blendLayoutConfig(JSObject jsObject) {
}

@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) {
case "text":
if (!prop.isString()) {
Expand Down Expand Up @@ -172,7 +173,9 @@ public boolean onPreDraw() {
}
}

mView.setGradient(angle, colors, locations);
if (mView instanceof DoricTextView) {
((DoricTextView) mView).setGradient(angle, colors, locations);
}

return true;
}
Expand Down Expand Up @@ -306,12 +309,16 @@ public void onFinish() {
break;
case "strikethrough":
if (prop.isBoolean()) {
view.setStrikethrough(prop.asBoolean().value());
if (mView instanceof DoricTextView) {
((DoricTextView) view).setStrikethrough(prop.asBoolean().value());
}
}
break;
case "underline":
if (prop.isBoolean()) {
view.setUnderline(prop.asBoolean().value());
if (mView instanceof DoricTextView) {
((DoricTextView) view).setUnderline(prop.asBoolean().value());
}
}
break;
case "htmlText":
Expand Down Expand Up @@ -383,13 +390,15 @@ public void onFinish() {
break;
case "shadow":
if (prop.isObject()) {
mView.setShadow(
prop.asObject().getProperty("opacity").asNumber().toFloat(),
prop.asObject().getProperty("radius").asNumber().toFloat(),
DoricUtils.dp2px(prop.asObject().getProperty("offsetX").asNumber().toFloat()),
DoricUtils.dp2px(prop.asObject().getProperty("offsetY").asNumber().toFloat()),
prop.asObject().getProperty("color").asNumber().toInt()
);
if (mView instanceof DoricTextView) {
((DoricTextView) mView).setShadow(
prop.asObject().getProperty("opacity").asNumber().toFloat(),
prop.asObject().getProperty("radius").asNumber().toFloat(),
DoricUtils.dp2px(prop.asObject().getProperty("offsetX").asNumber().toFloat()),
DoricUtils.dp2px(prop.asObject().getProperty("offsetY").asNumber().toFloat()),
prop.asObject().getProperty("color").asNumber().toInt()
);
}
}
break;
default:
Expand Down

0 comments on commit f175a94

Please sign in to comment.