Android: on switch not called when toggle by js code
This commit is contained in:
parent
9c166da915
commit
2d5d24ac40
@ -39,6 +39,8 @@ public class SwitchNode extends ViewNode<SwitchCompat> {
|
|||||||
private int onTintColor = 0xff52d769;
|
private int onTintColor = 0xff52d769;
|
||||||
private int thumbTintColor = Color.WHITE;
|
private int thumbTintColor = Color.WHITE;
|
||||||
|
|
||||||
|
private boolean checkByCodeToggle = false;
|
||||||
|
|
||||||
public SwitchNode(DoricContext doricContext) {
|
public SwitchNode(DoricContext doricContext) {
|
||||||
super(doricContext);
|
super(doricContext);
|
||||||
}
|
}
|
||||||
@ -55,7 +57,9 @@ public class SwitchNode extends ViewNode<SwitchCompat> {
|
|||||||
if (!prop.isBoolean()) {
|
if (!prop.isBoolean()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
checkByCodeToggle = true;
|
||||||
view.setChecked(prop.asBoolean().value());
|
view.setChecked(prop.asBoolean().value());
|
||||||
|
checkByCodeToggle = false;
|
||||||
break;
|
break;
|
||||||
case "onSwitch":
|
case "onSwitch":
|
||||||
if (!prop.isString()) {
|
if (!prop.isString()) {
|
||||||
@ -65,6 +69,7 @@ public class SwitchNode extends ViewNode<SwitchCompat> {
|
|||||||
view.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
view.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
|
if (checkByCodeToggle) return;
|
||||||
callJSResponse(callbackId, isChecked);
|
callJSResponse(callbackId, isChecked);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user