WXComponent implements IWXObject, IWXActivityStateListener { public void addEvent(String type) { if (TextUtils.isEmpty(type)) { return; } mDomObj.addEvent(type); if (type.equals(Constants.Event.CLICK) && getRealView() != null) { addClickListener(mClickEventListener); } else if ((type.equals( Constants.Event.FOCUS) || type.equals( Constants.Event.BLUR)) ) { addFocusChangeListener(new OnFocusChangeListener() { public void onFocusChange(boolean hasFocus) { Map<String, Object> params = new HashMap<>(); params.put("timeStamp", System.currentTimeMillis()); getInstance().fireEvent(mCurrentRef, hasFocus ? Constants.Event.FOCUS : Constants.Event.BLUR, params); } }); } else if (getRealView() != null && needGestureDetector(type)) { if (getRealView() instanceof WXGestureObservable) { if (wxGesture == null) { wxGesture = new WXGesture(this, mContext); } mGestureType.add(type); ((WXGestureObservable) getRealView()).registerGestureListener(wxGesture); } else { WXLogUtils.e(getRealView().getClass().getSimpleName() + " don't implement " + "WXGestureObservable, so no gesture is supported."); } } else { Scrollable scroller = getParentScroller(); if (type.equals(Constants.Event.APPEAR) && scroller != null) { scroller.bindAppearEvent(this); } if (type.equals(Constants.Event.DISAPPEAR) && scroller != null) { scroller.bindDisappearEvent(this); } } } @Deprecated  WXComponent(WXSDKInstance instance, WXDomObject dom, WXVContainer parent, String instanceId, boolean isLazy);  WXComponent(WXSDKInstance instance, WXDomObject dom, WXVContainer parent, boolean isLazy); String getInstanceId(); void bindHolder(IFComponentHolder holder); WXSDKInstance getInstance(); Context getContext(); boolean isLazy(); void lazy(boolean lazy); void applyLayoutAndEvent(WXComponent component); void bindData(WXComponent component); void refreshData(WXComponent component); final void setLayout(WXDomObject domObject); void setPadding(Spacing padding, Spacing border); void updateExtra(Object extra); WXDomObject getDomObject(); void updateProperties(Map<String, Object> props); void addEvent(String type); View getRealView(); Scrollable getParentScroller(); WXVContainer getParent(); String getRef(); final void createView(WXVContainer parent, int index); T getHostView(); @Deprecated View getView(); int getAbsoluteY(); int getAbsoluteX(); void updateDom(WXDomObject dom); final void removeEvent(String type); final void removeAllEvent(); final void removeStickyStyle(); boolean isSticky(); void setDisabled(boolean disabled); void setSticky(String sticky); void setBackgroundColor(String color); void setOpacity(float opacity); void setBorderRadius(String key, float borderRadius); void setBorderWidth(String key, float borderWidth); void setBorderStyle(String key, String borderStyle); void setBorderColor(String key, String borderColor); @Nullable String getVisibility(); void setVisibility(String visibility); void registerActivityStateListener(); @Override void onActivityCreate(); @Override void onActivityStart(); @Override void onActivityPause(); @Override void onActivityResume(); @Override void onActivityStop(); @Override void onActivityDestroy(); @Override boolean onActivityBack(); void destroy(); View detachViewAndClearPreInfo(); void computeVisiblePointInViewCoordinate(PointF pointF); boolean containsGesture(WXGestureType WXGestureType); void notifyAppearStateChange(String wxEventType,String direction); boolean isUsing(); void setUsing(boolean using); boolean hasScrollParent(WXComponent component); static int mComponentNum; public T mHost; @Deprecated
  volatile WXVContainer mParent; @Deprecated
  volatile WXDomObject mDomObj; @Deprecated
  final String mInstanceId; }
@Test public void testAddEvent() throws Exception { component.addEvent(Constants.Event.FOCUS); }