Only disallow changes if the value actually changed

Differential Revision: D5884661

fbshipit-source-id: 2d9fe28a0ecfc46afc9ca459975455e1fd13d19b
This commit is contained in:
Kevin Doherty 2017-09-26 08:02:45 -07:00 committed by Facebook Github Bot
parent 64ffe4516e
commit 6f6329d5e3
1 changed files with 1 additions and 2 deletions

View File

@ -11,7 +11,6 @@ package com.facebook.react.views.switchview;
import android.content.Context;
import android.support.v7.widget.SwitchCompat;
import android.widget.Switch;
/**
* Switch that has its value controlled by JS. Whenever the value of the switch changes, we do not
@ -29,7 +28,7 @@ import android.widget.Switch;
@Override
public void setChecked(boolean checked) {
if (mAllowChange) {
if (mAllowChange && isChecked() != checked) {
mAllowChange = false;
super.setChecked(checked);
}