com.taobao.weex.WXEnvironment Java Examples

The following examples show how to use com.taobao.weex.WXEnvironment. 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: WXBridgeManager.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
/**
 * Report JavaScript Exception
 */
public void reportJSException(String instanceId, String function,
                              String exception) {
  if (WXEnvironment.isApkDebugable()) {
    WXLogUtils.e("reportJSException >>>> instanceId:" + instanceId
                 + ", exception function:" + function + ", exception:"
                 + exception);
  }
  WXSDKInstance instance;
  if (instanceId != null && (instance = WXSDKManager.getInstance().getSDKInstance(instanceId)) != null) {
    instance.onJSException(WXErrorCode.WX_ERR_JS_EXECUTE.getErrorCode(), function, exception);

    String err = "function:" + function + "#exception:" + exception;
    commitJSBridgeAlarmMonitor(instanceId, WXErrorCode.WX_ERR_JS_EXECUTE, err);

    IWXJSExceptionAdapter adapter = WXSDKManager.getInstance().getIWXJSExceptionAdapter();
    if (adapter != null) {
      WXJSExceptionInfo jsException = new WXJSExceptionInfo(instanceId, instance.getBundleUrl(), WXErrorCode.WX_ERR_JS_EXECUTE.getErrorCode(), function, exception, null);
      adapter.onJSException(jsException);
      if (WXEnvironment.isApkDebugable()) {
        WXLogUtils.d(jsException.toString());
      }
    }
  }
}
 
Example #2
Source File: WXViewUtils.java    From weex-uikit with MIT License 6 votes vote down vote up
public static int getScreenWidth(Context ctx) {
  if(ctx!=null){
    Resources res = ctx.getResources();
    mScreenWidth = res.getDisplayMetrics().widthPixels;

    if(WXEnvironment.SETTING_FORCE_VERTICAL_SCREEN){
      mScreenHeight = res
              .getDisplayMetrics()
              .heightPixels;
      mScreenWidth = mScreenHeight > mScreenWidth ? mScreenWidth : mScreenHeight;
    }
  } else if(WXEnvironment.isApkDebugable()){
    throw new WXRuntimeException("Error Context is null When getScreenHeight");
  }
  return mScreenWidth;
}
 
Example #3
Source File: WXBridge.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
public int callCreateBody(String instanceId, String 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().callCreateBody(instanceId, tasks, callback);
  }catch (Throwable e){
    //catch everything during call native.
    if(WXEnvironment.isApkDebugable()){
      WXLogUtils.e(TAG,"callCreateBody throw exception:"+e.getMessage());
    }
  }
  if(instance != null) {
    instance.callNativeTime(System.currentTimeMillis() - start);
  }
  return errorCode;
}
 
Example #4
Source File: WXBridge.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
public int callNative(String instanceId, String 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().callNative(instanceId, tasks, callback);
  }catch (Throwable e){
    //catch everything during call native.
    if(WXEnvironment.isApkDebugable()){
      WXLogUtils.e(TAG,"callNative throw exception:"+e.getMessage());
    }
  }

  if(instance != null) {
    instance.callNativeTime(System.currentTimeMillis() - start);
  }
  if(WXEnvironment.isApkDebugable()){
    if(errorCode == IWXBridge.DESTROY_INSTANCE){
      WXLogUtils.w("destroyInstance :"+instanceId+" JSF must stop callNative");
    }
  }
  return errorCode;
}
 
Example #5
Source File: WXViewUtils.java    From weex with Apache License 2.0 6 votes vote down vote up
@Deprecated
public static int getScreenWidth( ) {
  if(WXEnvironment.sApplication!=null) {
    int width = WXEnvironment.sApplication.getResources().getDisplayMetrics().widthPixels;

    if(WXEnvironment.SETTING_FORCE_VERTICAL_SCREEN){
      int height = WXEnvironment.sApplication.getResources()
              .getDisplayMetrics()
              .heightPixels;
      width = height > width ?width:height;
    }
    return width;
  }
  if(WXEnvironment.isApkDebugable()){
    throw new WXRuntimeException("Error Context is null When getScreenHeight");
  }
  return 0;
}
 
Example #6
Source File: WXTextDomObject.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
@Override
public WXTextDomObject clone() {
  WXTextDomObject dom = null;
  try {
    dom = new WXTextDomObject();
    copyFields(dom);
    dom.hasBeenMeasured = hasBeenMeasured;
    dom.atomicReference = atomicReference;
  } catch (Exception e) {
    if (WXEnvironment.isApkDebugable()) {
      WXLogUtils.e("WXTextDomObject clone error: ", e);
    }
  }
  if (dom != null) {
    dom.spanned = spanned;
  }
  return dom;
}
 
Example #7
Source File: WXComponent.java    From weex-uikit with MIT License 6 votes vote down vote up
/********************************
 *  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 #8
Source File: WXBridge.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
/**
 * JavaScript uses this methods to call Android code
 *
 * @param instanceId
 * @param tasks
 * @param callback
 */

public int callUpdateFinish(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().callUpdateFinish(instanceId, callback);
  } catch (Throwable e) {
    //catch everything during call native.
    if(WXEnvironment.isApkDebugable()){
      WXLogUtils.e(TAG,"callCreateBody throw exception:"+e.getMessage());
    }
  }
  if(instance != null) {
    instance.callNativeTime(System.currentTimeMillis() - start);
  }
  return errorCode;
}
 
Example #9
Source File: WXParallax.java    From incubator-weex-playground with Apache License 2.0 6 votes vote down vote up
int getColor(int XDelta, int YDelta) {
  if (WXEnvironment.isApkDebugable()) {
    WXLogUtils.d("WXParallax:getColor: XDelta" + XDelta + " YDelta:" + YDelta + " mOffsetY" + mOffsetY);
  }
  int r1, g1, b1;

  if (mOffsetY > input[1]) {
    return output[1];
  }

  if (mOffsetY < input[0]) {
    return output[0];
  }

  r1 = Color.red(output[0]) + (int) (mOffsetY - input[0]) * (Color.red(output[1]) - Color.red(output[0])) / (input[1] - input[0]);
  g1 = Color.green(output[0]) + (int) (mOffsetY - input[0]) * (Color.green(output[1]) - Color.green(output[0])) / (input[1] - input[0]);
  b1 = Color.blue(output[0]) + (int) (mOffsetY - input[0]) * (Color.blue(output[1]) - Color.blue(output[0])) / (input[1] - input[0]);

  if (WXEnvironment.isApkDebugable()) {
    WXLogUtils.d("WXParallax:getColor: r1" + r1 + " g1:" + g1 + " b1:" + b1);
  }
  return Color.rgb(r1, g1, b1);
}
 
Example #10
Source File: WXScroller.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
@Override
protected MeasureOutput measure(int width, int height) {
  MeasureOutput measureOutput = new MeasureOutput();
  if (this.mOrientation == Constants.Orientation.HORIZONTAL) {
    int screenW = WXViewUtils.getScreenWidth(WXEnvironment.sApplication);
    int weexW = WXViewUtils.getWeexWidth(getInstanceId());
    measureOutput.width = width > (weexW >= screenW ? screenW : weexW) ? FrameLayout.LayoutParams.MATCH_PARENT
                                                                       : width;
    measureOutput.height = height;
  } else {
    int screenH = WXViewUtils.getScreenHeight(WXEnvironment.sApplication);
    int weexH = WXViewUtils.getWeexHeight(getInstanceId());
    measureOutput.height = height > (weexH >= screenH ? screenH : weexH) ? FrameLayout.LayoutParams.MATCH_PARENT
                                                                         : height;
    measureOutput.width = width;
  }
  return measureOutput;
}
 
Example #11
Source File: DefaultUriAdapterTest.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
@Before
public void setup() {
  WXEnvironment.sApplication = RuntimeEnvironment.application;
  WXSDKManager wxsdkManager = WXSDKManager.getInstance();
  if (!new MockUtil().isSpy(wxsdkManager)) {
    WXSDKManager spy = Mockito.spy(wxsdkManager);
    WXSDKManagerTest.setInstance(spy);
    Mockito.when(spy.getIWXHttpAdapter()).thenReturn(new IWXHttpAdapter() {
      @Override
      public void sendRequest(WXRequest request, OnHttpListener listener) {
        //do nothing.
      }
    });
  }

  adapter = new DefaultUriAdapter();
  instance = WXSDKInstanceTest.createInstance();
}
 
Example #12
Source File: WXCirclePageAdapter.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
@Override
public Object instantiateItem(ViewGroup container, int position) {
  View pageView = null;
  try {
    pageView = shadow.get(position);
    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: ", e);
  }
  return pageView;
}
 
Example #13
Source File: WXBridgeManager.java    From weex-uikit with MIT License 6 votes vote down vote up
private WXParams assembleDefaultOptions() {
  Map<String, String> config = WXEnvironment.getConfig();
  WXParams wxParams = new WXParams();
  wxParams.setPlatform(config.get("os"));
  wxParams.setOsVersion(config.get("sysVersion"));
  wxParams.setAppVersion(config.get("appVersion"));
  wxParams.setWeexVersion(config.get("weexVersion"));
  wxParams.setDeviceModel(config.get("sysModel"));
  wxParams.setShouldInfoCollect(config.get("infoCollect"));
  wxParams.setLogLevel(config.get(WXConfig.logLevel));
  String appName = config.get("appName");
  if (!TextUtils.isEmpty(appName)) {
    wxParams.setAppName(appName);
  }
  wxParams.setDeviceWidth(TextUtils.isEmpty(config.get("deviceWidth")) ? String.valueOf(WXViewUtils.getScreenWidth(WXEnvironment.sApplication)) : config.get("deviceWidth"));
  wxParams.setDeviceHeight(TextUtils.isEmpty(config.get("deviceHeight")) ? String.valueOf(WXViewUtils.getScreenHeight(WXEnvironment.sApplication)) : config.get("deviceHeight"));
  wxParams.setOptions(WXEnvironment.getCustomOptions());
  return wxParams;
}
 
Example #14
Source File: WXBridgeManager.java    From weex-uikit with MIT License 6 votes vote down vote up
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 WXModuleManager.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 #15
Source File: WXRenderStatement.java    From weex with Apache License 2.0 6 votes vote down vote up
WXComponent createBodyOnDomThread(WXDomObject dom) {
  if (mWXSDKInstance == null) {
    return null;
  }
  WXDomObject domObject = new WXDomObject();
  domObject.type = WXBasicComponentType.DIV;
  domObject.ref = "god";
  mGodComponent = (WXVContainer) WXComponentFactory.newInstance(mWXSDKInstance, domObject, null);
  mGodComponent.createView(null, -1);
  if (mGodComponent == null) {
    if (WXEnvironment.isApkDebugable()) {
      WXLogUtils.e("rootView failed!");
    }
    //TODO error callback
    return null;
  }
  FrameLayout frameLayout = (FrameLayout) mGodComponent.getView();
  ViewGroup.LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
  frameLayout.setLayoutParams(layoutParams);
  frameLayout.setBackgroundColor(Color.TRANSPARENT);

  WXComponent component = generateComponentTree(dom, mGodComponent);
  mGodComponent.addChild(component);
  mRegistry.put(component.getRef(), component);
  return component;
}
 
Example #16
Source File: WXBridge.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
/**
 * JavaScript uses this methods to call Android code
 * @param instanceId
 * @param ref
 * @param parentref
 * @param index
 * @param callback
 * @return int
 */
public int callMoveElement(String instanceId, String ref, String parentref, String index, String callback) {
  long start = System.currentTimeMillis();
  WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(instanceId);
  if(instance != null) {
    instance.firstScreenCreateInstanceTime(start);
  }
  int errorCode = IWXBridge.INSTANCE_RENDERING;
  try {
    // Integer.parseInt(index)
    errorCode = WXBridgeManager.getInstance().callMoveElement(instanceId, ref, parentref, index, callback);
  } catch (Throwable e) {
    //catch everything during call native.
    if(WXEnvironment.isApkDebugable()){
      WXLogUtils.e(TAG,"callMoveElement throw exception:" + e.getMessage());
    }
  }
  if(instance != null) {
    instance.callNativeTime(System.currentTimeMillis() - start);
  }
  return errorCode;
}
 
Example #17
Source File: WXBridge.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
/**
 * JavaScript uses this methods to call Android code
 * @param instanceId
 * @param ref
 * @param event
 * @param callback
 * @return int
 */
public int callAddEvent(String instanceId, String ref, String event, 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().callAddEvent(instanceId, ref, event, callback);
  } catch (Throwable e) {
    //catch everything during call native.
    if(WXEnvironment.isApkDebugable()){
      WXLogUtils.e(TAG,"callAddEvent throw exception:" + e.getMessage());
    }
  }
  if(instance != null) {
    instance.callNativeTime(System.currentTimeMillis() - start);
  }
  return errorCode;
}
 
Example #18
Source File: WXDomRegistry.java    From weex-uikit with MIT License 6 votes vote down vote up
public static boolean registerDomObject(String type, Class<? extends WXDomObject> clazz) throws WXException {
  if (clazz == null || TextUtils.isEmpty(type)) {
    return false;
  }

  if (sDom.containsKey(type)) {
    if (WXEnvironment.isApkDebugable()) {
      throw new WXException("WXDomRegistry had duplicate Dom:" + type);
    } else {
      WXLogUtils.e("WXDomRegistry had duplicate Dom: " + type);
      return false;
    }
  }
  sDom.put(type, clazz);
  return true;
}
 
Example #19
Source File: WXRenderStatement.java    From weex with Apache License 2.0 6 votes vote down vote up
/**
 * create RootView ,every weex Instance View has a rootView;
 * @see com.taobao.weex.dom.WXDomStatement#createBody(JSONObject)
 */
void createBody(WXComponent component) {
  long start = System.currentTimeMillis();
  component.createView(mGodComponent, -1);
  if (WXEnvironment.isApkDebugable()) {
    WXLogUtils.renderPerformanceLog("createView", (System.currentTimeMillis() - start));
  }
  start = System.currentTimeMillis();
  component.applyLayoutAndEvent(component);
  component.bindData(component);

  if (WXEnvironment.isApkDebugable()) {
    WXLogUtils.renderPerformanceLog("bind", (System.currentTimeMillis() - start));
  }

  if (component instanceof WXScroller) {
    WXScroller scroller = (WXScroller) component;
    if (scroller.getView() instanceof ScrollView) {
      mWXSDKInstance.setRootScrollView((ScrollView) scroller.getView());
    }
  }
  mWXSDKInstance.setRootView(mGodComponent.getRealView());
  if (mWXSDKInstance.getRenderStrategy() != WXRenderStrategy.APPEND_ONCE) {
    mWXSDKInstance.onViewCreated(mGodComponent);
  }
}
 
Example #20
Source File: WXBridgeManager.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
public Object callNativeComponent(String instanceId, String componentRef, String method, JSONArray arguments, Object options) {
    if (WXEnvironment.isApkDebugable()) {
        mLodBuilder.append("[WXBridgeManager] callNativeComponent >>>> instanceId:").append(instanceId)
                .append(", componentRef:").append(componentRef).append(", method:").append(method).append(", arguments:").append(arguments);
        WXLogUtils.d(mLodBuilder.substring(0));
        mLodBuilder.setLength(0);
    }
    try {

        WXDomModule dom = getDomModule(instanceId);
        dom.invokeMethod(componentRef, 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 #21
Source File: WXLogUtils.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
public static void d(String tag, String msg) {
  if (WXEnvironment.isApkDebugable() && !TextUtils.isEmpty(msg) && WXEnvironment.sLogLevel.compare(LogLevel.DEBUG) >= 0) {
    msg = getLineNumber() + msg;
    Log.d(tag, msg);
    /** This log method will be invoked from jni code, so try to extract loglevel from message. **/
    writeConsoleLog("debug", tag + ":" + msg);
    if(msg.contains(" | __")){
      String[] msgs=msg.split(" | __");
      LogLevel level;
      if( msgs!=null && msgs.length==4 && !TextUtils.isEmpty(msgs[0]) && !TextUtils.isEmpty(msgs[2])){
        level=getLogLevel(msgs[2]);
        sendLog(level,msgs[0]);
        return;
      }
    }
    sendLog(LogLevel.DEBUG, tag + ":" + msg);
  }
}
 
Example #22
Source File: WXPerformance.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
public String getPerfData(){
    return  "networkTime:" + networkTime
            + " actualNetworkTime:" + actualNetworkTime
            + " connectionType:" + connectionType
            + " requestType:" + requestType
            + " firstScreenRenderTime:" + screenRenderTime
            + " firstScreenJSFExecuteTime:" + firstScreenJSFExecuteTime
            + " componentCount:" + componentCount
            + " JSTemplateSize:" + JSTemplateSize
            + " SDKInitTime:" + WXEnvironment.sSDKInitTime
            + " totalTime:" + totalTime
            + " JSLibVersion:" + JSLibVersion
            + " WXSDKVersion:" + WXSDKVersion
            + " pageName:" + pageName
            + " useScroller:" + useScroller;

}
 
Example #23
Source File: WXBridgeManager.java    From weex-uikit with MIT License 6 votes vote down vote up
public Object callNativeComponent(String instanceId, String componentRef, String method, JSONArray arguments, Object options) {
    if (WXEnvironment.isApkDebugable()) {
        mLodBuilder.append("[WXBridgeManager] callNativeComponent >>>> instanceId:").append(instanceId)
                .append(", componentRef:").append(componentRef).append(", method:").append(method).append(", arguments:").append(arguments);
        WXLogUtils.d(mLodBuilder.substring(0));
        mLodBuilder.setLength(0);
    }
    try {

        WXDomModule dom = getDomModule(instanceId);
        dom.invokeMethod(componentRef, 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 #24
Source File: WXSoInstallMgrSdk.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
static void commit(IWXUserTrackAdapter utAdapter, String errCode, String errMsg) {
  if (mStatisticsListener != null) {
    mStatisticsListener.onException("0", errCode, errMsg);
  }

  if (utAdapter == null) {
    return;
  }
  if (errCode != null && errMsg != null) {
    WXPerformance p = new WXPerformance();
    p.errCode = errCode;
    p.errMsg = errMsg;
    utAdapter.commit(null, null, WXEnvironment.ENVIRONMENT, p, null);
  } else {
    utAdapter.commit(null, null, WXEnvironment.ENVIRONMENT, null, null);

  }
}
 
Example #25
Source File: WXViewUtils.java    From weex with Apache License 2.0 6 votes vote down vote up
public static int getScreenWidth(Context cxt) {
  if(cxt!=null){
    int width = WXEnvironment.sApplication.getResources().getDisplayMetrics().widthPixels;

    if(WXEnvironment.SETTING_FORCE_VERTICAL_SCREEN){
      int height = WXEnvironment.sApplication.getResources()
              .getDisplayMetrics()
              .heightPixels;
      width = height > width ?width:height;
    }
    return width;
  }
  if(WXEnvironment.isApkDebugable()){
    throw new WXRuntimeException("Error Context is null When getScreenHeight");
  }
  return 0;
}
 
Example #26
Source File: WXThread.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
@Override
public boolean handleMessage(Message msg) {
  boolean result = false;
  try{
    if(mCallback != null){
      result = mCallback.handleMessage(msg);
    }
  }catch (Throwable e){
    //catch everything may throw from exection.
    if(WXEnvironment.isApkDebugable()){
      WXLogUtils.e(TAG,"SafeCallback handleMessage throw expection:"+e.getMessage());
      throw e;
    }
  }
  return result;
}
 
Example #27
Source File: WXBridgeManager.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
private WXParams assembleDefaultOptions() {
  Map<String, String> config = WXEnvironment.getConfig();
  WXParams wxParams = new WXParams();
  wxParams.setPlatform(config.get(WXConfig.os));
  wxParams.setOsVersion(config.get(WXConfig.sysVersion));
  wxParams.setAppVersion(config.get(WXConfig.appVersion));
  wxParams.setWeexVersion(config.get(WXConfig.weexVersion));
  wxParams.setDeviceModel(config.get(WXConfig.sysModel));
  wxParams.setShouldInfoCollect(config.get("infoCollect"));
  wxParams.setLogLevel(config.get(WXConfig.logLevel));
  String appName = config.get(WXConfig.appName);
  if (!TextUtils.isEmpty(appName)) {
    wxParams.setAppName(appName);
  }
  wxParams.setDeviceWidth(TextUtils.isEmpty(config.get("deviceWidth")) ? String.valueOf(WXViewUtils.getScreenWidth(WXEnvironment.sApplication)) : config.get("deviceWidth"));
  wxParams.setDeviceHeight(TextUtils.isEmpty(config.get("deviceHeight")) ? String.valueOf(WXViewUtils.getScreenHeight(WXEnvironment.sApplication)) : config.get("deviceHeight"));
  wxParams.setOptions(WXEnvironment.getCustomOptions());
  wxParams.setNeedInitV8(WXSDKManager.getInstance().needInitV8());
  return wxParams;
}
 
Example #28
Source File: WXCirclePageAdapter.java    From weex-uikit with MIT License 6 votes vote down vote up
@Override
public Object instantiateItem(ViewGroup container, int position) {
  View pageView = null;
  try {
    pageView = shadow.get(position);
    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: ", e);
  }
  return pageView;
}
 
Example #29
Source File: WXTextDomObject.java    From weex with Apache License 2.0 5 votes vote down vote up
@Override
public WXTextDomObject clone() {
  WXTextDomObject dom = null;
  try {
    dom = new WXTextDomObject();
    if (this.cssstyle != null) {
      dom.cssstyle.copy(this.cssstyle);
    }
    dom.ref = ref;
    dom.type = type;
    dom.style = style;
    dom.attr = attr;
    dom.event = event == null ? null : event.clone();
    dom.hasBeenMeasured = hasBeenMeasured;
    dom.atomicReference=atomicReference;
    if (this.csslayout != null) {
      dom.csslayout.copy(this.csslayout);
    }
  } catch (Exception e) {
    if (WXEnvironment.isApkDebugable()) {
      WXLogUtils.e("WXTextDomObject clone error: " + WXLogUtils.getStackTrace(e));
    }
  }
  if (dom != null) {
    dom.spannableStringBuilder = spannableStringBuilder;
  }
  return dom;
}
 
Example #30
Source File: WXIndicator.java    From weex-uikit with MIT License 5 votes vote down vote up
@Override
protected WXCircleIndicator initComponentHostView(@NonNull Context context) {
  WXCircleIndicator view = new WXCircleIndicator(context);
  if (getParent() instanceof WXSlider) {
    return view;
  } else {
    if (WXEnvironment.isApkDebugable()) {
      throw new WXRuntimeException("WXIndicator initView error.");
    }
  }
  return null;
}