Skip to content
Browse files

fix checkbox casting crash in old android versions (#23281)

fixes casting on older android versions reported in #22885

[Android] [Fixed] - fix casting crash in android checkbox
Pull Request resolved: #23281

Differential Revision: D13941776

Pulled By: cpojer

fbshipit-source-id: ff3695f64d3399790a03b02d5b1363cacc655336
  • Loading branch information...
vonovak authored and facebook-github-bot committed Feb 4, 2019
1 parent 9ccde37 commit 58437cd10a667bbcbc16781df855fd7c3d73bf49
@@ -6,14 +6,15 @@
package com.facebook.react.views.checkbox;

import android.content.Context;
import android.widget.CompoundButton;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.uimanager.SimpleViewManager;
import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.ViewProps;
import com.facebook.react.uimanager.annotations.ReactProp;

/** View manager for {@link ReactCheckBox} components. */
public class ReactCheckBoxManager extends SimpleViewManager<ReactCheckBox> {
@@ -24,11 +25,22 @@
new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
ReactContext reactContext = (ReactContext) buttonView.getContext();
ReactContext reactContext = getReactContext(buttonView);
.dispatchEvent(new ReactCheckBoxEvent(buttonView.getId(), isChecked));

private ReactContext getReactContext(CompoundButton buttonView) {
ReactContext reactContext;
Context ctx = buttonView.getContext();
if (ctx instanceof TintContextWrapper) {
reactContext = (ReactContext) ((TintContextWrapper) ctx).getBaseContext();
} else {
reactContext = (ReactContext) buttonView.getContext();
return reactContext;


0 comments on commit 58437cd

Please sign in to comment.
You can’t perform that action at this time.