@Test public void testAddEvent() throws Exception { component.addEvent(Constants.Event.CHANGE); }
@Override public void addEvent(String type) { super.addEvent(type); if (type != null && type.equals(Constants.Event.CHANGE) && getHostView() != null) { if (mListener == null) { mListener = new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { Map<String, Object> params = new HashMap<>(2); params.put("value", isChecked); Map<String, Object> domChanges = new HashMap<>(); Map<String, Object> attrsChanges = new HashMap<>(); attrsChanges.put("checked",Boolean.toString(isChecked)); domChanges.put("attrs",attrsChanges); fireEvent(Constants.Event.CHANGE, params,domChanges); } }; } getHostView().setOnCheckedChangeListener(mListener); } }
WXSwitch extends WXComponent<WXSwitchView> { @Override public void addEvent(String type) { super.addEvent(type); if (type != null && type.equals(Constants.Event.CHANGE) && getHostView() != null) { if (mListener == null) { mListener = new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { Map<String, Object> params = new HashMap<>(2); params.put("value", isChecked); Map<String, Object> domChanges = new HashMap<>(); Map<String, Object> attrsChanges = new HashMap<>(); attrsChanges.put("checked",Boolean.toString(isChecked)); domChanges.put("attrs",attrsChanges); fireEvent(Constants.Event.CHANGE, params,domChanges); } }; } getHostView().setOnCheckedChangeListener(mListener); } } }
WXSwitch extends WXComponent<WXSwitchView> { @Override public void addEvent(String type) { super.addEvent(type); if (type != null && type.equals(Constants.Event.CHANGE) && getHostView() != null) { if (mListener == null) { mListener = new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { Map<String, Object> params = new HashMap<>(2); params.put("value", isChecked); Map<String, Object> domChanges = new HashMap<>(); Map<String, Object> attrsChanges = new HashMap<>(); attrsChanges.put("checked",Boolean.toString(isChecked)); domChanges.put("attrs",attrsChanges); fireEvent(Constants.Event.CHANGE, params,domChanges); } }; } getHostView().setOnCheckedChangeListener(mListener); } } @Deprecated  WXSwitch(WXSDKInstance instance, WXDomObject dom, WXVContainer parent, String instanceId, boolean isLazy);  WXSwitch(WXSDKInstance instance, WXDomObject dom, WXVContainer parent, boolean isLazy); }
WXSwitch extends WXComponent<WXSwitchView> { @Override public void addEvent(String type) { super.addEvent(type); if (type != null && type.equals(Constants.Event.CHANGE) && getHostView() != null) { if (mListener == null) { mListener = new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { Map<String, Object> params = new HashMap<>(2); params.put("value", isChecked); Map<String, Object> domChanges = new HashMap<>(); Map<String, Object> attrsChanges = new HashMap<>(); attrsChanges.put("checked",Boolean.toString(isChecked)); domChanges.put("attrs",attrsChanges); fireEvent(Constants.Event.CHANGE, params,domChanges); } }; } getHostView().setOnCheckedChangeListener(mListener); } } @Deprecated  WXSwitch(WXSDKInstance instance, WXDomObject dom, WXVContainer parent, String instanceId, boolean isLazy);  WXSwitch(WXSDKInstance instance, WXDomObject dom, WXVContainer parent, boolean isLazy); @Override void addEvent(String type); @WXComponentProp(name = Constants.Name.CHECKED) void setChecked(boolean checked); }
WXSwitch extends WXComponent<WXSwitchView> { @Override public void addEvent(String type) { super.addEvent(type); if (type != null && type.equals(Constants.Event.CHANGE) && getHostView() != null) { if (mListener == null) { mListener = new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { Map<String, Object> params = new HashMap<>(2); params.put("value", isChecked); Map<String, Object> domChanges = new HashMap<>(); Map<String, Object> attrsChanges = new HashMap<>(); attrsChanges.put("checked",Boolean.toString(isChecked)); domChanges.put("attrs",attrsChanges); fireEvent(Constants.Event.CHANGE, params,domChanges); } }; } getHostView().setOnCheckedChangeListener(mListener); } } @Deprecated  WXSwitch(WXSDKInstance instance, WXDomObject dom, WXVContainer parent, String instanceId, boolean isLazy);  WXSwitch(WXSDKInstance instance, WXDomObject dom, WXVContainer parent, boolean isLazy); @Override void addEvent(String type); @WXComponentProp(name = Constants.Name.CHECKED) void setChecked(boolean checked);  }