Java Code Examples for com.taobao.weex.utils.WXLogUtils#e()
The following examples show how to use
com.taobao.weex.utils.WXLogUtils#e() .
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: WXEmbed.java From ucar-weex-core with Apache License 2.0 | 6 votes |
@Override public void onException(NestedContainer container, String errCode, String msg) { if (TextUtils.equals(errCode, WXRenderErrorCode.WX_NETWORK_ERROR) && container instanceof WXEmbed) { final WXEmbed comp = ((WXEmbed)container); final ImageView imageView = new ImageView(comp.getContext()); imageView.setImageResource(R.drawable.error); FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ERROR_IMG_WIDTH, ERROR_IMG_HEIGHT); layoutParams.gravity = Gravity.CENTER; imageView.setLayoutParams(layoutParams); imageView.setScaleType(ImageView.ScaleType.FIT_XY); imageView.setAdjustViewBounds(true); imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { imageView.setOnClickListener(null); imageView.setEnabled(false); comp.loadContent(); } }); FrameLayout hostView = comp.getHostView(); hostView.removeAllViews(); hostView.addView(imageView); WXLogUtils.e("WXEmbed", "NetWork failure :" + errCode + ",\n error message :" + msg); } }
Example 2
Source File: WXBridge.java From ucar-weex-core with Apache License 2.0 | 6 votes |
/** * JavaScript uses this methods to call Android code * * @param instanceId * @param tasks * @param callback */ public int callRefreshFinish(String instanceId, byte [] tasks, String callback) { long start = System.currentTimeMillis(); WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(instanceId); if(instance != null) { instance.firstScreenCreateInstanceTime(start); } int errorCode = IWXBridge.INSTANCE_RENDERING; try { errorCode = WXBridgeManager.getInstance().callRefreshFinish(instanceId, callback); } catch (Throwable e) { //catch everything during call native. if(WXEnvironment.isApkDebugable()){ WXLogUtils.e(TAG,"callCreateFinish throw exception:" + e.getMessage()); } } if(instance != null) { instance.callNativeTime(System.currentTimeMillis() - start); } return errorCode; }
Example 3
Source File: WXStreamModule.java From ucar-weex-core with Apache License 2.0 | 6 votes |
private void sendRequest(Options options,ResponseCallback callback,JSCallback progressCallback){ WXRequest wxRequest = new WXRequest(); wxRequest.method = options.getMethod(); wxRequest.url = mWXSDKInstance.rewriteUri(Uri.parse(options.getUrl()), URIAdapter.REQUEST).toString(); wxRequest.body = options.getBody(); wxRequest.timeoutMs = options.getTimeout(); if(options.getHeaders()!=null) if (wxRequest.paramMap == null) { wxRequest.paramMap = options.getHeaders(); }else{ wxRequest.paramMap.putAll(options.getHeaders()); } IWXHttpAdapter adapter = ( mAdapter==null && mWXSDKInstance != null) ? mWXSDKInstance.getWXHttpAdapter() : mAdapter; if (adapter != null) { adapter.sendRequest(wxRequest, new StreamHttpListener(callback,progressCallback)); }else{ WXLogUtils.e("WXStreamModule","No HttpAdapter found,request failed."); } }
Example 4
Source File: DefaultLocation.java From analyzer-of-android-for-Apache-Weex with Apache License 2.0 | 6 votes |
/** * get address info */ private Address getAddress(double latitude, double longitude) { if(WXEnvironment.isApkDebugable()) { WXLogUtils.d(TAG, "into--[getAddress] latitude:" + latitude + " longitude:" + longitude); } try { if (mWXSDKInstance == null || mWXSDKInstance.isDestroy()) { return null; } Geocoder gc = new Geocoder(mWXSDKInstance.getContext()); List<Address> list = gc.getFromLocation(latitude, longitude, 1); if (list != null && list.size() > 0) { return list.get(0); } } catch (Exception e) { WXLogUtils.e(TAG, e); } return null; }
Example 5
Source File: WXSlider.java From ucar-weex-core with Apache License 2.0 | 6 votes |
@Deprecated @WXComponentProp(name = Constants.Name.VALUE) public void setValue(String value) { if (value == null || getHostView() == null) { return; } int i; try { i = Integer.parseInt(value); } catch (NumberFormatException e) { WXLogUtils.e("", e); return; } setIndex(i); }
Example 6
Source File: WXBridgeManager.java From ucar-weex-core with Apache License 2.0 | 6 votes |
public Object callNativeModule(String instanceId, String module, String method, JSONArray arguments, Object options) { if (WXEnvironment.isApkDebugable()) { mLodBuilder.append("[WXBridgeManager] callNativeModule >>>> instanceId:").append(instanceId) .append(", module:").append(module).append(", method:").append(method).append(", arguments:").append(arguments); WXLogUtils.d(mLodBuilder.substring(0)); mLodBuilder.setLength(0); } try { if(WXDomModule.WXDOM.equals(module)){ WXDomModule dom = getDomModule(instanceId); return dom.callDomMethod(method,arguments); }else { return callModuleMethod(instanceId, module, method, arguments); } } catch (Exception e) { WXLogUtils.e("[WXBridgeManager] callNative exception: ", e); commitJSBridgeAlarmMonitor(instanceId, WXErrorCode.WX_ERR_INVOKE_NATIVE, "[WXBridgeManager] callNativeModule exception " + e.getCause()); } return null; }
Example 7
Source File: BasicListComponent.java From ucar-weex-core with Apache License 2.0 | 6 votes |
/** * generate viewtype by component * * @param component * @return */ private int generateViewType(WXComponent component) { long id; try { id = Integer.parseInt(component.getDomObject().getRef()); String type = component.getDomObject().getAttrs().getScope(); if (!TextUtils.isEmpty(type)) { if (mRefToViewType == null) { mRefToViewType = new ArrayMap<>(); } if (!mRefToViewType.containsKey(type)) { mRefToViewType.put(type, id); } id = mRefToViewType.get(type); } } catch (RuntimeException e) { WXLogUtils.eTag(TAG, e); id = RecyclerView.NO_ID; WXLogUtils.e(TAG, "getItemViewType: NO ID, this will crash the whole render system of WXListRecyclerView"); } return (int) id; }
Example 8
Source File: WXCirclePageAdapter.java From weex with Apache License 2.0 | 6 votes |
@Override public Object instantiateItem(ViewGroup container, int position) { View pageView = null; try { pageView = views.get(position % getRealCount()); if (WXEnvironment.isApkDebugable()) { WXLogUtils.d("onPageSelected >>>> instantiateItem >>>>> position:" + position + ",position % getRealCount()" + position % getRealCount()); } if (pageView.getParent() == null) { container.addView(pageView); } else { ((ViewGroup) pageView.getParent()).removeView(pageView); container.addView(pageView); } } catch (Exception e) { WXLogUtils.e("[CirclePageAdapter] instantiateItem: " + WXLogUtils.getStackTrace(e)); } return pageView; }
Example 9
Source File: JacocoCodeCoverage.java From incubator-weex-playground with Apache License 2.0 | 6 votes |
public static void dumpCodeCoverage(Context context){ WXLogUtils.d( TAG, "CoverageDataDumper BroadcastReceiver " ); try { Class .forName( "com.vladium.emma.rt.RT" ) .getMethod( "dumpCoverageData", File.class, boolean.class, boolean.class ) .invoke( null, new File(context.getExternalFilesDir( null ) + "/coverage.ec" ), true, // merge false // stopDataCollection ); WXLogUtils.d( TAG, "generateCoverageReport: ok! " + "file in [Android/data/org.apache.weex/files]" ); } catch ( Exception e ) { WXLogUtils.e( TAG, e ); } }
Example 10
Source File: DefaultLocation.java From incubator-weex-playground with Apache License 2.0 | 6 votes |
/** * get address info */ private Address getAddress(double latitude, double longitude) { WXLogUtils.d(TAG, "into--[getAddress] latitude:" + latitude + " longitude:" + longitude); try { if (mContext == null) { return null; } Geocoder gc = new Geocoder(mContext); List<Address> list = gc.getFromLocation(latitude, longitude, 1); if (list != null && list.size() > 0) { return list.get(0); } } catch (Exception e) { WXLogUtils.e(TAG, e); } return null; }
Example 11
Source File: ViewUtils.java From analyzer-of-android-for-Apache-Weex with Apache License 2.0 | 6 votes |
@Nullable public static WXComponent getNestedRootComponent(@NonNull WXEmbed embed) { try { Class embedClazz = embed.getClass(); Field field = embedClazz.getDeclaredField("mNestedInstance"); field.setAccessible(true); WXSDKInstance nestedInstance = (WXSDKInstance) field.get(embed); if(nestedInstance == null) { return null; } return nestedInstance.getRootComponent(); }catch (Exception e) { WXLogUtils.e(e.getMessage()); } return null; }
Example 12
Source File: DefaultWXStorage.java From ucar-weex-core with Apache License 2.0 | 6 votes |
private boolean performRemoveItem(String key) { SQLiteDatabase database = mDatabaseSupplier.getDatabase(); if (database == null) { return false; } int count = 0; try { count = database.delete(WXSQLiteOpenHelper.TABLE_STORAGE, WXSQLiteOpenHelper.COLUMN_KEY + "=?", new String[]{key}); } catch (Exception e) { WXLogUtils.e(WXSQLiteOpenHelper.TAG_STORAGE, "DefaultWXStorage occurred an exception when execute removeItem:" + e.getMessage()); return false; } return count == 1; }
Example 13
Source File: WXComponent.java From weex-uikit with MIT License | 5 votes |
protected void createViewImpl() { if (mContext != null) { mHost = initComponentHostView(mContext); if (mHost == null) { //compatible initView(); } if(mHost != null){ mHost.setId(WXViewUtils.generateViewId()); } onHostViewInitialized(mHost); }else{ WXLogUtils.e("createViewImpl","Context is null"); } }
Example 14
Source File: WXBridgeManager.java From ucar-weex-core with Apache License 2.0 | 5 votes |
public int callUpdateFinish(String instanceId, String callback) { if (WXEnvironment.isApkDebugable()) { mLodBuilder.append("[WXBridgeManager] callUpdateFinish >>>> instanceId:").append(instanceId) .append(", callback:").append(callback); WXLogUtils.d(mLodBuilder.substring(0)); mLodBuilder.setLength(0); } if(mDestroyedInstanceId != null && mDestroyedInstanceId.contains(instanceId)){ return IWXBridge.DESTROY_INSTANCE; } try { if (WXSDKManager.getInstance().getSDKInstance(instanceId) != null) { WXDomModule domModule = getDomModule(instanceId); Action action = Actions.getUpdateFinish(); domModule.postAction((DOMAction)action, false); } } catch (Exception e) { WXLogUtils.e("[WXBridgeManager] callUpdateFinish exception: ", e); commitJSBridgeAlarmMonitor(instanceId, WXErrorCode.WX_ERR_INVOKE_NATIVE,"[WXBridgeManager] callUpdateFinish exception "+e.getCause()); } if (UNDEFINED.equals(callback) || NON_CALLBACK.equals(callback)) { return IWXBridge.INSTANCE_RENDERING_ERROR; } // get next tick getNextTick(instanceId, callback); return IWXBridge.INSTANCE_RENDERING; }
Example 15
Source File: BackgroundColorProperty.java From ucar-weex-core with Apache License 2.0 | 5 votes |
@Override public void set(View object, Integer value) { BorderDrawable borderDrawable; if ((borderDrawable = WXViewUtils.getBorderDrawable(object)) != null) { borderDrawable.setColor(value); } else if (object.getBackground() instanceof ColorDrawable) { ((ColorDrawable) object.getBackground()).setColor(value); } else { WXLogUtils.e(TAG, "Unsupported background type"); } }
Example 16
Source File: DefaultDragHelper.java From ucar-weex-core with Apache License 2.0 | 5 votes |
@Override public boolean isDragExcluded(@NonNull RecyclerView.ViewHolder viewHolder) { if (viewHolder.itemView == null) { if (WXEnvironment.isApkDebugable()) { WXLogUtils.e(TAG, "[error] viewHolder.itemView is null"); } return false; } return viewHolder.itemView.getTag() != null && TAG_EXCLUDED.equals(viewHolder.itemView.getTag()); }
Example 17
Source File: StickyHeaderHelper.java From ucar-weex-core with Apache License 2.0 | 5 votes |
/** * Bring component with bigest pos to Front */ private void showSticky() { if(mCurrentStickyRef==null){ WXLogUtils.e("Current Sticky ref is null."); return; } WXCell headComponent = mHeaderComps.get(mCurrentStickyRef); final View headerView = headComponent.getRealView(); if (headerView == null) { WXLogUtils.e("Sticky header's real view is null."); return; } View header = mHeaderViews.get(headComponent.getRef()); if( header != null){ //already there header.bringToFront(); }else { mHeaderViews.put(headComponent.getRef(), headerView); //record translation, it should not change after transformation final float translationX = headerView.getTranslationX(); final float translationY = headerView.getTranslationY(); headComponent.removeSticky(); ViewGroup existedParent; if ((existedParent = (ViewGroup) headerView.getParent()) != null) { existedParent.removeView(headerView); } mParent.addView(headerView); //recover translation, sometimes it will be changed on fling headerView.setTranslationX(translationX); headerView.setTranslationY(translationY); } if (headComponent.getDomObject().getEvents().contains("sticky")) { headComponent.fireEvent("sticky"); } }
Example 18
Source File: WXGlobalEventReceiver.java From weex-uikit with MIT License | 5 votes |
@Override public void onReceive(Context context, Intent intent) { String eventName = intent.getStringExtra(EVENT_NAME); String params = intent.getStringExtra(EVENT_PARAMS); HashMap<String, Object> maps = null; try { maps = com.alibaba.fastjson.JSON.parseObject(params, HashMap.class); mWXSDKInstance.fireGlobalEventCallback(eventName, maps); } catch (Exception e) { WXLogUtils.e("global-receive",e); } }
Example 19
Source File: AbstractAddElementAction.java From ucar-weex-core with Apache License 2.0 | 4 votes |
/** * Add DOM node. */ protected void addDomInternal(DOMActionContext context, JSONObject dom) { if (context.isDestory()) { return; } WXSDKInstance instance = context.getInstance(); if (instance == null) { return; } WXErrorCode errCode = getErrorCode(); if (dom == null) { instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, errCode); } //only non-root has parent. WXDomObject domObject = WXDomObject.parse(dom, instance); if (domObject == null || context.getDomByRef(domObject.getRef()) != null) { if (WXEnvironment.isApkDebugable()) { WXLogUtils.e("[DOMActionContextImpl] " + getStatementName() + " error,DOM object is null or already registered!!"); } instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, errCode); return; } appendDomToTree(context, domObject); domObject.traverseTree( context.getAddDOMConsumer(), context.getApplyStyleConsumer() ); //Create component in dom thread WXComponent component = createComponent(context, domObject); if (component == null) { instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, errCode); //stop redner, some fatal happened. return; } context.addDomInfo(domObject.getRef(), component); context.postRenderTask(this); addAnimationForDomTree(context, domObject); instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS); }
Example 20
Source File: WXDomObject.java From ucar-weex-core with Apache License 2.0 | 4 votes |
/** * Parse the jsonObject to {@link WXDomObject} recursively * @param json the original JSONObject * @return Dom Object corresponding to the JSONObject. */ public static @Nullable WXDomObject parse(JSONObject json, WXSDKInstance wxsdkInstance){ if (json == null || json.size() <= 0) { return null; } String type = (String) json.get(TYPE); if (wxsdkInstance.isNeedValidate()) { WXValidateProcessor processor = WXSDKManager.getInstance() .getValidateProcessor(); if (processor != null) { WXValidateProcessor.WXComponentValidateResult result = processor .onComponentValidate(wxsdkInstance, type); if (result != null && !result.isSuccess) { type = TextUtils.isEmpty(result.replacedComponent) ? WXBasicComponentType.DIV : result.replacedComponent; json.put(TYPE, type); if(WXEnvironment.isApkDebugable()&&result.validateInfo!=null){ String tag = "[WXDomObject]onComponentValidate failure. >>> "+result.validateInfo.toJSONString(); WXLogUtils.e(tag); } } } } WXDomObject domObject = WXDomObjectFactory.newInstance(type); domObject.setViewPortWidth(wxsdkInstance.getInstanceViewPortWidth()); if(domObject == null){ return null; } domObject.parseFromJson(json); domObject.mDomContext = wxsdkInstance; Object children = json.get(CHILDREN); if (children != null && children instanceof JSONArray) { JSONArray childrenArray = (JSONArray) children; int count = childrenArray.size(); for (int i = 0; i < count; ++i) { domObject.add(parse(childrenArray.getJSONObject(i),wxsdkInstance),-1); } } return domObject; }