@Test public void testAddEvent() throws Exception { component.addEvent(Constants.Event.FOCUS); }
public void addEvent(final String type) { if (mAppendEvents == null) { mAppendEvents = new HashSet<>(); } if (TextUtils.isEmpty(type) || mAppendEvents.contains(type)) { return; } final View view = getRealView(); if (type.equals(Constants.Event.LAYEROVERFLOW)) addLayerOverFlowListener(getRef()); if (type.equals(Constants.Event.CLICK)) { if (view == null) { return; } if(mClickEventListener == null){ mClickEventListener = new OnClickListenerImp(); } addClickListener(mClickEventListener); } else if ((type.equals(Constants.Event.FOCUS) || type.equals(Constants.Event.BLUR))) { addFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(boolean hasFocus) { Map<String, Object> params = new HashMap<>(); params.put("timeStamp", System.currentTimeMillis()); fireEvent(hasFocus ? Constants.Event.FOCUS : Constants.Event.BLUR, params); } }); } else if (needGestureDetector(type)) { if (null == view) { return; } if (view instanceof WXGestureObservable) { if (mGesture == null) { mGesture = new WXGesture(this, mContext); boolean isPreventMove = WXUtils.getBoolean(getAttrs().get(Constants.Name.PREVENT_MOVE_EVENT), false); mGesture.setPreventMoveEvent(isPreventMove); } if (mGestureType == null) { mGestureType = new HashSet<>(); } mGestureType.add(type); ((WXGestureObservable)view).registerGestureListener(mGesture); } else { WXLogUtils.e(view.getClass().getSimpleName() + " don't implement " + "WXGestureObservable, so no gesture is supported."); } } else { final Scrollable scroller = getParentScroller(); if (scroller == null) { return; } if (type.equals(Constants.Event.APPEAR)) { scroller.bindAppearEvent(this); } else if (type.equals(Constants.Event.DISAPPEAR)) { scroller.bindDisappearEvent(this); } } mAppendEvents.add(type); }
WXComponent extends WXBasicComponent implements IWXObject, IWXActivityStateListener, OnActivePseudoListner { public void addEvent(final String type) { if (mAppendEvents == null) { mAppendEvents = new HashSet<>(); } if (TextUtils.isEmpty(type) || mAppendEvents.contains(type)) { return; } final View view = getRealView(); if (type.equals(Constants.Event.LAYEROVERFLOW)) addLayerOverFlowListener(getRef()); if (type.equals(Constants.Event.CLICK)) { if (view == null) { return; } if(mClickEventListener == null){ mClickEventListener = new OnClickListenerImp(); } addClickListener(mClickEventListener); } else if ((type.equals(Constants.Event.FOCUS) || type.equals(Constants.Event.BLUR))) { addFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(boolean hasFocus) { Map<String, Object> params = new HashMap<>(); params.put("timeStamp", System.currentTimeMillis()); fireEvent(hasFocus ? Constants.Event.FOCUS : Constants.Event.BLUR, params); } }); } else if (needGestureDetector(type)) { if (null == view) { return; } if (view instanceof WXGestureObservable) { if (mGesture == null) { mGesture = new WXGesture(this, mContext); boolean isPreventMove = WXUtils.getBoolean(getAttrs().get(Constants.Name.PREVENT_MOVE_EVENT), false); mGesture.setPreventMoveEvent(isPreventMove); } if (mGestureType == null) { mGestureType = new HashSet<>(); } mGestureType.add(type); ((WXGestureObservable)view).registerGestureListener(mGesture); } else { WXLogUtils.e(view.getClass().getSimpleName() + " don't implement " + "WXGestureObservable, so no gesture is supported."); } } else { final Scrollable scroller = getParentScroller(); if (scroller == null) { return; } if (type.equals(Constants.Event.APPEAR)) { scroller.bindAppearEvent(this); } else if (type.equals(Constants.Event.DISAPPEAR)) { scroller.bindDisappearEvent(this); } } mAppendEvents.add(type); } }
WXComponent extends WXBasicComponent implements IWXObject, IWXActivityStateListener, OnActivePseudoListner { public void addEvent(final String type) { if (mAppendEvents == null) { mAppendEvents = new HashSet<>(); } if (TextUtils.isEmpty(type) || mAppendEvents.contains(type)) { return; } final View view = getRealView(); if (type.equals(Constants.Event.LAYEROVERFLOW)) addLayerOverFlowListener(getRef()); if (type.equals(Constants.Event.CLICK)) { if (view == null) { return; } if(mClickEventListener == null){ mClickEventListener = new OnClickListenerImp(); } addClickListener(mClickEventListener); } else if ((type.equals(Constants.Event.FOCUS) || type.equals(Constants.Event.BLUR))) { addFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(boolean hasFocus) { Map<String, Object> params = new HashMap<>(); params.put("timeStamp", System.currentTimeMillis()); fireEvent(hasFocus ? Constants.Event.FOCUS : Constants.Event.BLUR, params); } }); } else if (needGestureDetector(type)) { if (null == view) { return; } if (view instanceof WXGestureObservable) { if (mGesture == null) { mGesture = new WXGesture(this, mContext); boolean isPreventMove = WXUtils.getBoolean(getAttrs().get(Constants.Name.PREVENT_MOVE_EVENT), false); mGesture.setPreventMoveEvent(isPreventMove); } if (mGestureType == null) { mGestureType = new HashSet<>(); } mGestureType.add(type); ((WXGestureObservable)view).registerGestureListener(mGesture); } else { WXLogUtils.e(view.getClass().getSimpleName() + " don't implement " + "WXGestureObservable, so no gesture is supported."); } } else { final Scrollable scroller = getParentScroller(); if (scroller == null) { return; } if (type.equals(Constants.Event.APPEAR)) { scroller.bindAppearEvent(this); } else if (type.equals(Constants.Event.DISAPPEAR)) { scroller.bindDisappearEvent(this); } } mAppendEvents.add(type); } @Deprecated  WXComponent(WXSDKInstance instance, WXVContainer parent, String instanceId, boolean isLazy, BasicComponentData basicComponentData); @Deprecated  WXComponent(WXSDKInstance instance, WXVContainer parent, boolean isLazy, BasicComponentData basicComponentData);  WXComponent(WXSDKInstance instance, WXVContainer parent, BasicComponentData basicComponentData);  WXComponent(WXSDKInstance instance, WXVContainer parent, int type, BasicComponentData basicComponentData); }
WXComponent extends WXBasicComponent implements IWXObject, IWXActivityStateListener, OnActivePseudoListner { public void addEvent(final String type) { if (mAppendEvents == null) { mAppendEvents = new HashSet<>(); } if (TextUtils.isEmpty(type) || mAppendEvents.contains(type)) { return; } final View view = getRealView(); if (type.equals(Constants.Event.LAYEROVERFLOW)) addLayerOverFlowListener(getRef()); if (type.equals(Constants.Event.CLICK)) { if (view == null) { return; } if(mClickEventListener == null){ mClickEventListener = new OnClickListenerImp(); } addClickListener(mClickEventListener); } else if ((type.equals(Constants.Event.FOCUS) || type.equals(Constants.Event.BLUR))) { addFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(boolean hasFocus) { Map<String, Object> params = new HashMap<>(); params.put("timeStamp", System.currentTimeMillis()); fireEvent(hasFocus ? Constants.Event.FOCUS : Constants.Event.BLUR, params); } }); } else if (needGestureDetector(type)) { if (null == view) { return; } if (view instanceof WXGestureObservable) { if (mGesture == null) { mGesture = new WXGesture(this, mContext); boolean isPreventMove = WXUtils.getBoolean(getAttrs().get(Constants.Name.PREVENT_MOVE_EVENT), false); mGesture.setPreventMoveEvent(isPreventMove); } if (mGestureType == null) { mGestureType = new HashSet<>(); } mGestureType.add(type); ((WXGestureObservable)view).registerGestureListener(mGesture); } else { WXLogUtils.e(view.getClass().getSimpleName() + " don't implement " + "WXGestureObservable, so no gesture is supported."); } } else { final Scrollable scroller = getParentScroller(); if (scroller == null) { return; } if (type.equals(Constants.Event.APPEAR)) { scroller.bindAppearEvent(this); } else if (type.equals(Constants.Event.DISAPPEAR)) { scroller.bindDisappearEvent(this); } } mAppendEvents.add(type); } @Deprecated  WXComponent(WXSDKInstance instance, WXVContainer parent, String instanceId, boolean isLazy, BasicComponentData basicComponentData); @Deprecated  WXComponent(WXSDKInstance instance, WXVContainer parent, boolean isLazy, BasicComponentData basicComponentData);  WXComponent(WXSDKInstance instance, WXVContainer parent, BasicComponentData basicComponentData);  WXComponent(WXSDKInstance instance, WXVContainer parent, int type, BasicComponentData basicComponentData); void updateStyles(WXComponent component); void updateStyles(Map<String, Object> styles); void updateAttrs(WXComponent component); void updateAttrs(Map<String, Object> attrs); void setPadding(CSSShorthand padding, CSSShorthand border); void addEvent(final String type); void bindHolder(IFComponentHolder holder); WXSDKInstance getInstance(); Context getContext(); String getAttrByKey(String key); void postAnimation(WXAnimationModule.AnimationHolder holder); @RestrictTo(RestrictTo.Scope.LIBRARY) boolean isFlatUIEnabled(); String getInstanceId(); Rect getComponentSize(); final void invoke(String method, JSONArray args); final void fireEvent(String type); final void fireEvent(String type, Map<String, Object> params); final EventResult fireEventWait(String type, Map<String, Object> params); Object findTypeParent(WXComponent component, Class type); boolean isLazy(); void bindData(WXComponent component); void applyLayoutAndEvent(WXComponent component); void setDemission(GraphicSize size, GraphicPosition position); void updateDemission(float top, float bottom, float left, float right, float height, float width); void applyLayoutOnly(); void refreshData(WXComponent component); @Deprecated void updateProperties(Map<String, Object> props); final void setLayout(WXComponent component); int getLayoutTopOffsetForSibling(); View getRealView(); Scrollable getParentScroller(); @Nullable Scrollable getFirstScroller(); WXVContainer getParent(); final void createView(); T getHostView(); @Deprecated View getView(); int getAbsoluteY(); int getAbsoluteX(); void removeEvent(String type); void removeAllEvent(); final void removeStickyStyle(); boolean isSticky(); boolean isFixed(); void setDisabled(boolean disabled); boolean isDisabled(); void setSticky(String sticky); void setBackgroundColor(String color); void setBackgroundImage(@NonNull String bgImage); 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); @Deprecated void registerActivityStateListener(); void onActivityCreate(); void onActivityStart(); void onActivityPause(); void onActivityResume(); void onActivityStop(); void onActivityDestroy(); boolean onActivityBack(); void onActivityResult(int requestCode, int resultCode, Intent data); boolean onCreateOptionsMenu(Menu menu); void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults); void recycled(); void destroy(); boolean isDestoryed(); View detachViewAndClearPreInfo(); void clearPreLayout(); void computeVisiblePointInViewCoordinate(PointF pointF); boolean containsGesture(WXGestureType WXGestureType); boolean containsEvent(String event); void notifyAppearStateChange(String wxEventType, String direction); boolean isUsing(); void setUsing(boolean using); void readyToRender(); boolean isVirtualComponent(); void removeVirtualComponent(); int getType(); boolean hasScrollParent(WXComponent component); @Override void updateActivePseudo(boolean isSet); int getStickyOffset(); boolean canRecycled(); void setStickyOffset(int stickyOffset); boolean isLayerTypeEnabled(); void setNeedLayoutOnAnimation(boolean need); void notifyNativeSizeChanged(int w, int h); @CallSuper void onRenderFinish(@RenderState int state); boolean isWaste(); void setWaste(boolean waste); String getViewTreeKey(); WXTransition getTransition(); void setTransition(WXTransition transition); void addAnimationForElement(Map<String, Object> animMap); void lazy(boolean lazy); long getRenderObjectPtr(); void updateNativeAttr(String key, Object value); void nativeUpdateAttrs(Map<String, Object> dynamic); void updateNativeStyle(String key, Object value); void updateNativeStyles(Map<String, Object> dynamic); void addLayerOverFlowListener(String ref); void removeLayerOverFlowListener(String ref); }
WXComponent extends WXBasicComponent implements IWXObject, IWXActivityStateListener, OnActivePseudoListner { public void addEvent(final String type) { if (mAppendEvents == null) { mAppendEvents = new HashSet<>(); } if (TextUtils.isEmpty(type) || mAppendEvents.contains(type)) { return; } final View view = getRealView(); if (type.equals(Constants.Event.LAYEROVERFLOW)) addLayerOverFlowListener(getRef()); if (type.equals(Constants.Event.CLICK)) { if (view == null) { return; } if(mClickEventListener == null){ mClickEventListener = new OnClickListenerImp(); } addClickListener(mClickEventListener); } else if ((type.equals(Constants.Event.FOCUS) || type.equals(Constants.Event.BLUR))) { addFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(boolean hasFocus) { Map<String, Object> params = new HashMap<>(); params.put("timeStamp", System.currentTimeMillis()); fireEvent(hasFocus ? Constants.Event.FOCUS : Constants.Event.BLUR, params); } }); } else if (needGestureDetector(type)) { if (null == view) { return; } if (view instanceof WXGestureObservable) { if (mGesture == null) { mGesture = new WXGesture(this, mContext); boolean isPreventMove = WXUtils.getBoolean(getAttrs().get(Constants.Name.PREVENT_MOVE_EVENT), false); mGesture.setPreventMoveEvent(isPreventMove); } if (mGestureType == null) { mGestureType = new HashSet<>(); } mGestureType.add(type); ((WXGestureObservable)view).registerGestureListener(mGesture); } else { WXLogUtils.e(view.getClass().getSimpleName() + " don't implement " + "WXGestureObservable, so no gesture is supported."); } } else { final Scrollable scroller = getParentScroller(); if (scroller == null) { return; } if (type.equals(Constants.Event.APPEAR)) { scroller.bindAppearEvent(this); } else if (type.equals(Constants.Event.DISAPPEAR)) { scroller.bindDisappearEvent(this); } } mAppendEvents.add(type); } @Deprecated  WXComponent(WXSDKInstance instance, WXVContainer parent, String instanceId, boolean isLazy, BasicComponentData basicComponentData); @Deprecated  WXComponent(WXSDKInstance instance, WXVContainer parent, boolean isLazy, BasicComponentData basicComponentData);  WXComponent(WXSDKInstance instance, WXVContainer parent, BasicComponentData basicComponentData);  WXComponent(WXSDKInstance instance, WXVContainer parent, int type, BasicComponentData basicComponentData); void updateStyles(WXComponent component); void updateStyles(Map<String, Object> styles); void updateAttrs(WXComponent component); void updateAttrs(Map<String, Object> attrs); void setPadding(CSSShorthand padding, CSSShorthand border); void addEvent(final String type); void bindHolder(IFComponentHolder holder); WXSDKInstance getInstance(); Context getContext(); String getAttrByKey(String key); void postAnimation(WXAnimationModule.AnimationHolder holder); @RestrictTo(RestrictTo.Scope.LIBRARY) boolean isFlatUIEnabled(); String getInstanceId(); Rect getComponentSize(); final void invoke(String method, JSONArray args); final void fireEvent(String type); final void fireEvent(String type, Map<String, Object> params); final EventResult fireEventWait(String type, Map<String, Object> params); Object findTypeParent(WXComponent component, Class type); boolean isLazy(); void bindData(WXComponent component); void applyLayoutAndEvent(WXComponent component); void setDemission(GraphicSize size, GraphicPosition position); void updateDemission(float top, float bottom, float left, float right, float height, float width); void applyLayoutOnly(); void refreshData(WXComponent component); @Deprecated void updateProperties(Map<String, Object> props); final void setLayout(WXComponent component); int getLayoutTopOffsetForSibling(); View getRealView(); Scrollable getParentScroller(); @Nullable Scrollable getFirstScroller(); WXVContainer getParent(); final void createView(); T getHostView(); @Deprecated View getView(); int getAbsoluteY(); int getAbsoluteX(); void removeEvent(String type); void removeAllEvent(); final void removeStickyStyle(); boolean isSticky(); boolean isFixed(); void setDisabled(boolean disabled); boolean isDisabled(); void setSticky(String sticky); void setBackgroundColor(String color); void setBackgroundImage(@NonNull String bgImage); 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); @Deprecated void registerActivityStateListener(); void onActivityCreate(); void onActivityStart(); void onActivityPause(); void onActivityResume(); void onActivityStop(); void onActivityDestroy(); boolean onActivityBack(); void onActivityResult(int requestCode, int resultCode, Intent data); boolean onCreateOptionsMenu(Menu menu); void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults); void recycled(); void destroy(); boolean isDestoryed(); View detachViewAndClearPreInfo(); void clearPreLayout(); void computeVisiblePointInViewCoordinate(PointF pointF); boolean containsGesture(WXGestureType WXGestureType); boolean containsEvent(String event); void notifyAppearStateChange(String wxEventType, String direction); boolean isUsing(); void setUsing(boolean using); void readyToRender(); boolean isVirtualComponent(); void removeVirtualComponent(); int getType(); boolean hasScrollParent(WXComponent component); @Override void updateActivePseudo(boolean isSet); int getStickyOffset(); boolean canRecycled(); void setStickyOffset(int stickyOffset); boolean isLayerTypeEnabled(); void setNeedLayoutOnAnimation(boolean need); void notifyNativeSizeChanged(int w, int h); @CallSuper void onRenderFinish(@RenderState int state); boolean isWaste(); void setWaste(boolean waste); String getViewTreeKey(); WXTransition getTransition(); void setTransition(WXTransition transition); void addAnimationForElement(Map<String, Object> animMap); void lazy(boolean lazy); long getRenderObjectPtr(); void updateNativeAttr(String key, Object value); void nativeUpdateAttrs(Map<String, Object> dynamic); void updateNativeStyle(String key, Object value); void updateNativeStyles(Map<String, Object> dynamic); void addLayerOverFlowListener(String ref); void removeLayerOverFlowListener(String ref); static final String PROP_FIXED_SIZE; static final String PROP_FS_MATCH_PARENT; static final String PROP_FS_WRAP_CONTENT; static final String TYPE; static final String ROOT; public WXTracing.TraceInfo mTraceInfo; static final int TYPE_COMMON; static final int TYPE_VIRTUAL; static final int STATE_DOM_FINISH; static final int STATE_UI_FINISH; static final int STATE_ALL_FINISH; }