6
6
*/
7
7
package com .facebook .react .views .checkbox ;
8
8
9
+ import android .content .Context ;
10
+ import android .support .v7 .widget .TintContextWrapper ;
9
11
import android .widget .CompoundButton ;
10
12
import com .facebook .react .bridge .ReactContext ;
11
13
import com .facebook .react .uimanager .SimpleViewManager ;
12
14
import com .facebook .react .uimanager .ThemedReactContext ;
13
15
import com .facebook .react .uimanager .UIManagerModule ;
14
16
import com .facebook .react .uimanager .ViewProps ;
15
17
import com .facebook .react .uimanager .annotations .ReactProp ;
16
- import com .facebook .react .uimanager .events .EventDispatcher ;
17
18
18
19
/** View manager for {@link ReactCheckBox} components. */
19
20
public class ReactCheckBoxManager extends SimpleViewManager <ReactCheckBox > {
@@ -24,11 +25,22 @@ public class ReactCheckBoxManager extends SimpleViewManager<ReactCheckBox> {
24
25
new CompoundButton .OnCheckedChangeListener () {
25
26
@ Override
26
27
public void onCheckedChanged (CompoundButton buttonView , boolean isChecked ) {
27
- ReactContext reactContext = ( ReactContext ) buttonView . getContext ( );
28
+ ReactContext reactContext = getReactContext ( buttonView );
28
29
reactContext
29
30
.getNativeModule (UIManagerModule .class ).getEventDispatcher ()
30
31
.dispatchEvent (new ReactCheckBoxEvent (buttonView .getId (), isChecked ));
31
32
}
33
+
34
+ private ReactContext getReactContext (CompoundButton buttonView ) {
35
+ ReactContext reactContext ;
36
+ Context ctx = buttonView .getContext ();
37
+ if (ctx instanceof TintContextWrapper ) {
38
+ reactContext = (ReactContext ) ((TintContextWrapper ) ctx ).getBaseContext ();
39
+ } else {
40
+ reactContext = (ReactContext ) buttonView .getContext ();
41
+ }
42
+ return reactContext ;
43
+ }
32
44
};
33
45
34
46
@ Override
0 commit comments