com.taobao.weex.utils.WXUtils Java Examples
The following examples show how to use
com.taobao.weex.utils.WXUtils.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BasicListComponent.java From ucar-weex-core with Apache License 2.0 | 6 votes |
private String getTriggerType(@Nullable ImmutableDomObject domObject) { String triggerType = DEFAULT_TRIGGER_TYPE; if (domObject == null) { return triggerType; } triggerType = WXUtils.getString(domObject.getAttrs().get(DRAG_TRIGGER_TYPE), DEFAULT_TRIGGER_TYPE); if (!DragTriggerType.LONG_PRESS.equals(triggerType) && !DragTriggerType.PAN.equals(triggerType)) { triggerType = DEFAULT_TRIGGER_TYPE; } if (WXEnvironment.isApkDebugable()) { WXLogUtils.d(TAG, "trigger type is " + triggerType); } return triggerType; }
Example #2
Source File: WXDomManager.java From weex with Apache License 2.0 | 6 votes |
/** * Remove the specified dom statement. This is called when {@link WXSDKManager} destroy * instances. * @param instanceId {@link com.taobao.weex.WXSDKInstance#mInstanceId} for the instance */ public void removeDomStatement(String instanceId) { if (!WXUtils.isUiThread()) { throw new WXRuntimeException("[WXDomManager] removeDomStatement"); } final WXDomStatement statement = mDomRegistries.remove(instanceId); if (statement != null) { post(new Runnable() { @Override public void run() { statement.destroy(); } }); } }
Example #3
Source File: BasicListComponent.java From ucar-weex-core with Apache License 2.0 | 6 votes |
@Override protected boolean setProperty(String key, Object param) { switch (key) { case LOADMOREOFFSET: return true; case Constants.Name.SCROLLABLE: boolean scrollable = WXUtils.getBoolean(param, true); setScrollable(scrollable); return true; case Constants.Name.OFFSET_ACCURACY: int accuracy = WXUtils.getInteger(param, 10); setOffsetAccuracy(accuracy); return true; case Constants.Name.DRAGGABLE: boolean draggable = WXUtils.getBoolean(param,false); setDraggable(draggable); return true; } return super.setProperty(key, param); }
Example #4
Source File: WXImage.java From weex-uikit with MIT License | 6 votes |
@Override protected boolean setProperty(String key, Object param) { switch (key) { case Constants.Name.RESIZE_MODE: String resize_mode = WXUtils.getString(param, null); if (resize_mode != null) setResizeMode(resize_mode); return true; case Constants.Name.RESIZE: String resize = WXUtils.getString(param, null); if (resize != null) setResize(resize); return true; case Constants.Name.SRC: String src = WXUtils.getString(param, null); if (src != null) setSrc(src); return true; case Constants.Name.IMAGE_QUALITY: return true; case Constants.Name.FILTER: return true; } return super.setProperty(key, param); }
Example #5
Source File: BaseBounceView.java From weex-uikit with MIT License | 6 votes |
/** * * @param loading should be {@link WXRefreshView} */ public void setFooterView(WXComponent loading) { setLoadmoreEnable(true); if (swipeLayout != null) { if (swipeLayout.getFooterView() != null) { swipeLayout.setLoadingHeight((int) loading.getDomObject().getLayoutHeight()); String colorStr = (String) loading.getDomObject().getStyles().get(Constants.Name.BACKGROUND_COLOR); String bgColor = WXUtils.getString(colorStr, null); if (bgColor != null) { if (!TextUtils.isEmpty(bgColor)) { int colorInt = WXResourceUtils.getColor(bgColor); if (!(colorInt == Color.TRANSPARENT)) { swipeLayout.setLoadingBgColor(colorInt); } } } swipeLayout.getFooterView().setRefreshView(loading.getHostView()); } } }
Example #6
Source File: BaseBounceView.java From ucar-weex-core with Apache License 2.0 | 6 votes |
/** * * @param refresh should be {@link WXRefreshView} */ public void setHeaderView(WXComponent refresh) { setRefreshEnable(true); if (swipeLayout != null) { WXRefreshView refreshView = swipeLayout.getHeaderView(); if (refreshView != null) { ImmutableDomObject immutableDomObject = refresh.getDomObject(); if (immutableDomObject != null) { int refreshHeight = (int) immutableDomObject.getLayoutHeight(); swipeLayout.setRefreshHeight(refreshHeight); String colorStr = (String) immutableDomObject.getStyles().get(Constants.Name.BACKGROUND_COLOR); String bgColor = WXUtils.getString(colorStr, null); if (bgColor != null) { if (!TextUtils.isEmpty(bgColor)) { int colorInt = WXResourceUtils.getColor(bgColor); if (!(colorInt == Color.TRANSPARENT)) { swipeLayout.setRefreshBgColor(colorInt); } } } refreshView.setRefreshView(refresh.getHostView()); } } } }
Example #7
Source File: WXSliderNeighbor.java From weex-uikit with MIT License | 6 votes |
@Override protected boolean setProperty(String key, Object param) { String input; switch (key) { case NEIGHBOR_SCALE: input = WXUtils.getString(param, null); if (input != null) { setNeighborScale(input); } return true; case NEIGHBOR_ALPHA: input = WXUtils.getString(param, null); if (input != null) { setNeighborAlpha(input); } return true; case NEIGHBOR_SPACE: input = WXUtils.getString(param, null); if (input != null) { setNeighborSpace(input); } return true; } return super.setProperty(key, param); }
Example #8
Source File: WXWeb.java From ucar-weex-core with Apache License 2.0 | 6 votes |
@Override protected boolean setProperty(String key, Object param) { switch (key) { case Constants.Name.SHOW_LOADING: Boolean result = WXUtils.getBoolean(param,null); if (result != null) setShowLoading(result); return true; case Constants.Name.SRC: String src = WXUtils.getString(param,null); if (src != null) setUrl(src); return true; } return super.setProperty(key,param); }
Example #9
Source File: WXModule.java From ucar-weex-core with Apache License 2.0 | 6 votes |
@JSMethod public void addEventListener(String eventName, String callback, Map<String, Object> options) { if (TextUtils.isEmpty(eventName) || TextUtils.isEmpty(callback)) { return; } boolean isOnce = false; if (options != null && options.size() > 0 && options.containsKey("once")) { Object temp = options.get("once"); if (WXUtils.getBoolean(temp,false)) { isOnce = true; } } mKeepAlives.put(callback, isOnce); if(mEvents.get(eventName)==null){ mEvents.put(eventName,new ArrayList<String>()); } mEvents.get(eventName).add(callback); }
Example #10
Source File: WXVideo.java From ucar-weex-core with Apache License 2.0 | 6 votes |
@Override protected boolean setProperty(String key, Object param) { switch (key) { case Constants.Name.SRC: String src = WXUtils.getString(param, null); if (src != null) { setSrc(src); } return true; case Constants.Name.AUTO_PLAY: Boolean result = WXUtils.getBoolean(param, null); if (result != null) { setAutoPlay(result); } return true; case Constants.Name.PLAY_STATUS: String status = WXUtils.getString(param, null); if (status != null) { setPlaystatus(status); } return true; } return super.setProperty(key, param); }
Example #11
Source File: WXComponent.java From weex-uikit with MIT License | 6 votes |
/******************************** * end hook Activity life cycle callback ********************************************************/ public void destroy() { if (WXEnvironment.isApkDebugable() && !WXUtils.isUiThread()) { throw new WXRuntimeException("[WXComponent] destroy can only be called in main thread"); } if(mHost!= null && mHost.getLayerType()==View.LAYER_TYPE_HARDWARE) { mHost.setLayerType(View.LAYER_TYPE_NONE, null); } removeAllEvent(); removeStickyStyle(); if (mDomObj != null) { mDomObj = null; } }
Example #12
Source File: WXSlider.java From ucar-weex-core with Apache License 2.0 | 6 votes |
@Override protected FrameLayout initComponentHostView(@NonNull Context context) { FrameLayout view = new FrameLayout(context); // init view pager if (getDomObject() != null && getDomObject().getAttrs() != null) { Object obj = getDomObject().getAttrs().get(INFINITE); isInfinite = WXUtils.getBoolean(obj, true); } FrameLayout.LayoutParams pagerParams = new FrameLayout.LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); mViewPager = new WXCircleViewPager(context); mViewPager.setCircle(isInfinite); mViewPager.setLayoutParams(pagerParams); // init adapter mAdapter = new WXCirclePageAdapter(isInfinite); mViewPager.setAdapter(mAdapter); // add to parent view.addView(mViewPager); mViewPager.addOnPageChangeListener(mPageChangeListener); registerActivityStateListener(); return view; }
Example #13
Source File: WXDomManager.java From weex-uikit with MIT License | 6 votes |
/** * Remove the specified dom statement. This is called when {@link WXSDKManager} destroy * instances. * @param instanceId {@link com.taobao.weex.WXSDKInstance#mInstanceId} for the instance */ public void removeDomStatement(String instanceId) { if (!WXUtils.isUiThread()) { throw new WXRuntimeException("[WXDomManager] removeDomStatement"); } final WXDomStatement statement = mDomRegistries.remove(instanceId); if (statement != null) { post(new Runnable() { @Override public void run() { statement.destroy(); } }); } }
Example #14
Source File: WXStyle.java From weex with Apache License 2.0 | 5 votes |
public float getPaddingLeft() { float temp = WXUtils.getFloat(get(WXDomPropConstant.WX_PADDINGLEFT)); if (WXUtils.isUndefined(temp)) { temp = WXUtils.getFloat(get(WXDomPropConstant.WX_PADDING)); } return temp; }
Example #15
Source File: WXStyle.java From ucar-weex-core with Apache License 2.0 | 5 votes |
public float getPaddingTop(int viewport) { float temp = WXUtils.getFloatByViewport(get(Constants.Name.PADDING_TOP), viewport); if (WXUtils.isUndefined(temp)) { temp = WXUtils.getFloatByViewport(get(Constants.Name.PADDING), viewport); } return temp; }
Example #16
Source File: WXSDKManager.java From weex with Apache License 2.0 | 5 votes |
void destroyInstance(String instanceId) { if (TextUtils.isEmpty(instanceId)) { return; } if (!WXUtils.isUiThread()) { throw new WXRuntimeException("[WXSDKManager] destroyInstance error"); } mWXRenderManager.removeRenderStatement(instanceId); mWXDomManager.removeDomStatement(instanceId); mBridgeManager.destroyInstance(instanceId); WXModuleManager.destroyInstanceModules(instanceId); }
Example #17
Source File: WXEmbed.java From weex-uikit with MIT License | 5 votes |
@Override protected boolean setProperty(String key, Object param) { switch (key) { case Constants.Name.SRC: String src = WXUtils.getString(param,null); if (src != null) setSrc(src); return true; } return super.setProperty(key, param); }
Example #18
Source File: WXStyle.java From weex-uikit with MIT License | 5 votes |
public float getBorderRadius() { float temp = WXUtils.getFloat(get(Constants.Name.BORDER_RADIUS)); if (WXUtils.isUndefined(temp)) { return Float.NaN; } return temp; }
Example #19
Source File: WXAnimationBean.java From weex-uikit with MIT License | 5 votes |
private static float parsePercentOrPx(String raw, int unit,int viewportW) { final int precision = 1; int suffix; if ((suffix = raw.lastIndexOf(WXUtils.PERCENT)) != -1) { return parsePercent(raw.substring(0, suffix), unit, precision); } else if ((suffix = raw.lastIndexOf(PX)) != -1) { return WXViewUtils.getRealPxByWidth(WXUtils.fastGetFloat(raw.substring(0, suffix), precision),viewportW); } return WXViewUtils.getRealPxByWidth(WXUtils.fastGetFloat(raw, precision),viewportW); }
Example #20
Source File: WXScroller.java From weex-uikit with MIT License | 5 votes |
@Override protected boolean setProperty(String key, Object param) { switch (key) { case Constants.Name.SHOW_SCROLLBAR: Boolean result = WXUtils.getBoolean(param,null); if (result != null) setShowScrollbar(result); return true; case Constants.Name.SCROLLABLE: boolean scrollable = WXUtils.getBoolean(param, true); setScrollable(scrollable); return true; } return super.setProperty(key, param); }
Example #21
Source File: WXRefresh.java From ucar-weex-core with Apache License 2.0 | 5 votes |
@Override protected boolean setProperty(String key, Object param) { switch (key) { case Constants.Name.DISPLAY: String display = WXUtils.getString(param,null); if (display != null) setDisplay(display); return true; } return super.setProperty(key,param); }
Example #22
Source File: WXStyle.java From ucar-weex-core with Apache License 2.0 | 5 votes |
public float getPaddingBottom(int viewport) { float temp = WXUtils.getFloatByViewport(get(Constants.Name.PADDING_BOTTOM), viewport); if (WXUtils.isUndefined(temp)) { temp = WXUtils.getFloatByViewport(get(Constants.Name.PADDING), viewport); } return temp; }
Example #23
Source File: WXStyle.java From weex with Apache License 2.0 | 5 votes |
public float getPaddingBottom() { float temp = WXUtils.getFloat(get(WXDomPropConstant.WX_PADDINGBOTTOM)); if (WXUtils.isUndefined(temp)) { temp = WXUtils.getFloat(get(WXDomPropConstant.WX_PADDING)); } return temp; }
Example #24
Source File: WXStyle.java From weex with Apache License 2.0 | 5 votes |
public static int getFontSize(Map<String, Object> style) { if (style == null) { return (int) WXViewUtils.getRealPxByWidth(WXText.sDEFAULT_SIZE); } int fontSize = WXUtils.getInt(style.get(WXDomPropConstant.WX_FONTSIZE)); if (fontSize <= 0) { fontSize = WXText.sDEFAULT_SIZE; } return (int) WXViewUtils.getRealPxByWidth(fontSize); }
Example #25
Source File: WXStyle.java From weex-uikit with MIT License | 5 votes |
public static int getFontSize(Map<String, Object> style,int viewPortW) { if (style == null) { return (int) WXViewUtils.getRealPxByWidth(WXText.sDEFAULT_SIZE,viewPortW); } int fontSize = WXUtils.getInt(style.get(Constants.Name.FONT_SIZE)); if (fontSize <= 0) { fontSize = WXText.sDEFAULT_SIZE; } return (int) WXViewUtils.getRealPxByWidth(fontSize,viewPortW); }
Example #26
Source File: WXStyle.java From ucar-weex-core with Apache License 2.0 | 5 votes |
public float getPaddingBottom() { float temp = WXUtils.getFloat(get(Constants.Name.PADDING_BOTTOM)); if (WXUtils.isUndefined(temp)) { temp = WXUtils.getFloat(get(Constants.Name.PADDING)); } return temp; }
Example #27
Source File: WXStyle.java From weex with Apache License 2.0 | 5 votes |
public float getPaddingRight() { float temp = WXUtils.getFloat(get(WXDomPropConstant.WX_PADDINGRIGHT)); if (WXUtils.isUndefined(temp)) { temp = WXUtils.getFloat(get(WXDomPropConstant.WX_PADDING)); } return temp; }
Example #28
Source File: WXEnvironment.java From weex-uikit with MIT License | 5 votes |
/** * Tell whether Weex can run on current hardware. * @return true if weex can run on current hardware, otherwise false. */ public static boolean isHardwareSupport() { boolean excludeX86 = "true".equals(options.get(SETTING_EXCLUDE_X86SUPPORT)); boolean isX86AndExcluded = WXSoInstallMgrSdk.isX86() && excludeX86; boolean isCPUSupport = WXSoInstallMgrSdk.isCPUSupport() && !isX86AndExcluded; if (WXEnvironment.isApkDebugable()) { WXLogUtils.d("WXEnvironment.sSupport:" + isCPUSupport + "isX86AndExclueded: "+ isX86AndExcluded + " !WXUtils.isTabletDevice():" + !WXUtils.isTabletDevice()); } return isCPUSupport && !WXUtils.isTabletDevice(); }
Example #29
Source File: WXStyle.java From weex-uikit with MIT License | 5 votes |
private float getBorderWidth(String key) { float temp = WXUtils.getFloat(get(key)); if (WXUtils.isUndefined(temp)) { return getBorderWidth(); } return temp; }
Example #30
Source File: WXStyle.java From ucar-weex-core with Apache License 2.0 | 5 votes |
public float getMarginTop(int viewport) { float temp = WXUtils.getFloatByViewport(get(Constants.Name.MARGIN_TOP), viewport); if (WXUtils.isUndefined(temp)) { temp = WXUtils.getFloatByViewport(get(Constants.Name.MARGIN), viewport); } return temp; }