Java Code Examples for com.taobao.weex.utils.WXLogUtils#eTag()

The following examples show how to use com.taobao.weex.utils.WXLogUtils#eTag() . 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 vote down vote up
/**
 * 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 2
Source File: BasicListComponent.java    From weex-uikit with MIT License 6 votes vote down vote up
/**
 * 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 3
Source File: WXTextDomObject.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
/**
 * As warming up TextLayoutCache done in the DOM thread may manipulate UI operation,
 there may be some exception, in which case the exception is ignored. After all,
 this is just a warm up operation.
 * @return false for warm up failure, otherwise returns true.
 */
private boolean warmUpTextLayoutCache(Layout layout) {
  boolean result;
  try {
    layout.draw(DUMMY_CANVAS);
    result = true;
  } catch (Exception e) {
    WXLogUtils.eTag(TAG, e);
    result = false;
  }
  return result;
}
 
Example 4
Source File: WXNavigatorModule.java    From weex-uikit with MIT License 5 votes vote down vote up
@JSMethod(uiThread = true)
public void push(String param, JSCallback callback) {

    if (!TextUtils.isEmpty(param)) {
        if (WXSDKEngine.getActivityNavBarSetter() != null) {
            if (WXSDKEngine.getActivityNavBarSetter().push(param)) {
                callback.invoke(MSG_SUCCESS);
                return;
            }
        }

        try {
            JSONObject jsonObject = JSON.parseObject(param);
            String url = jsonObject.getString(URL);
            if (!TextUtils.isEmpty(url)) {
                Uri rawUri = Uri.parse(url);
                String scheme = rawUri.getScheme();
                Uri.Builder builder = rawUri.buildUpon();
                if (TextUtils.isEmpty(scheme)) {
                    builder.scheme(Constants.Scheme.HTTP);
                }
                Intent intent = new Intent(Intent.ACTION_VIEW, builder.build());
                intent.addCategory(WEEX);
                intent.putExtra(INSTANCE_ID, mWXSDKInstance.getInstanceId());
                mWXSDKInstance.getContext().startActivity(intent);
                callback.invoke(MSG_SUCCESS);
            }
        } catch (Exception e) {
            WXLogUtils.eTag(TAG, e);
            callback.invoke(MSG_FAILED);
        }
    }

    callback.invoke(MSG_FAILED);
}
 
Example 5
Source File: WXTextDomObject.java    From weex-uikit with MIT License 5 votes vote down vote up
/**
 * As warming up TextLayoutCache done in the DOM thread may manipulate UI operation,
 there may be some exception, in which case the exception is ignored. After all,
 this is just a warm up operation.
 * @return false for warm up failure, otherwise returns true.
 */
private boolean warmUpTextLayoutCache(Layout layout) {
  boolean result;
  try {
    layout.draw(DUMMY_CANVAS);
    result = true;
  } catch (Exception e) {
    WXLogUtils.eTag(TAG, e);
    result = false;
  }
  return result;
}
 
Example 6
Source File: UWXNavigatorModule.java    From ucar-weex-core with Apache License 2.0 4 votes vote down vote up
@JSMethod
public void pushNative(String encodeParam, JSCallback callback) {
    if (TextUtils.isEmpty(encodeParam)) {
        return;
    }
    try {
        JSONObject options = JSON.parseObject(encodeParam);
        String url = "";
        UWXTheme.NavBar navBar = null;
        JSONObject param = null;
        if (options.containsKey(UWXBundleInfo.KEY_URL)) {
            url = options.getString(UWXBundleInfo.KEY_URL);
        }
        if (options.containsKey(UWXBundleInfo.KEY_NAV_BAR)) {
            String _navBar = options.getString(UWXBundleInfo.KEY_NAV_BAR);
            if (!TextUtils.isEmpty(_navBar)) {
                navBar = JSON.parseObject(_navBar, UWXTheme.NavBar.class);
            }
        }
        if (options.containsKey(UWXBundleInfo.KEY_PARAM)) {
            param = options.getJSONObject(UWXBundleInfo.KEY_PARAM);
        }
        UWLog.v("params=" + encodeParam);
        if (!TextUtils.isEmpty(url)) {
            UWXNavigatorAdapter navigatorAdapter = UWXSDKManager.getInstance().getNavigatorAdapter();
            if (navigatorAdapter != null) {
                navigatorAdapter.pushNative((Activity) mWXSDKInstance.getContext(),url ,param);
                if (callback != null) {
                    callback.invoke(MSG_SUCCESS);
                }
            }
        } else {
            callback.invoke(MSG_FAILED);
        }
    } catch (Exception e) {
        WXLogUtils.eTag(TAG, e);
        if (callback != null) {
            callback.invoke(MSG_FAILED);
        }
    }
}
 
Example 7
Source File: UWXNavigatorModule.java    From ucar-weex-core with Apache License 2.0 4 votes vote down vote up
@JSMethod
public void push(String encodeParam, JSCallback callback) {
    if (TextUtils.isEmpty(encodeParam)) {
        return;
    }
    try {
        JSONObject options = JSON.parseObject(encodeParam);
        String url = "";
        UWXTheme.NavBar navBar = null;
        JSONObject param = null;
        boolean animated = false;
        if (options.containsKey(UWXBundleInfo.KEY_URL)) {
            url = options.getString(UWXBundleInfo.KEY_URL);
        }
        if (options.containsKey(UWXBundleInfo.KEY_NAV_BAR)) {
            String _navBar = options.getString(UWXBundleInfo.KEY_NAV_BAR);
            if (!TextUtils.isEmpty(_navBar)) {
                navBar = JSON.parseObject(_navBar, UWXTheme.NavBar.class);
            }
        }
        if (options.containsKey(UWXBundleInfo.KEY_PARAM)) {
            param = options.getJSONObject(UWXBundleInfo.KEY_PARAM);
        }

        if (options.containsKey(UWXBundleInfo.KEY_SCENE_CONFIGS)) {
            animated = options.getBoolean(UWXBundleInfo.KEY_SCENE_CONFIGS);
        }
        UWLog.v("params=" + encodeParam);
        UWXTheme theme = null;
        if (navBar == null) {
            theme = UWXThemeManager.getInstance().getPageTheme();
        } else {
            UWXThemeManager.getInstance().getPageTheme().setNavBar(navBar);
            theme = UWXThemeManager.getInstance().getPageTheme();
        }
        if (!TextUtils.isEmpty(url)) {

            UWXJumpUtil.openPageByUrl((Activity) mWXSDKInstance.getContext(), url, param, theme);
            if (callback != null) {
                callback.invoke(MSG_SUCCESS);
            }
        } else {
            callback.invoke(MSG_FAILED);
        }
    } catch (Exception e) {
        WXLogUtils.eTag(TAG, e);
        if (callback != null) {
            callback.invoke(MSG_FAILED);
        }
    }
}
 
Example 8
Source File: UWXNavigatorModule2.java    From ucar-weex-core with Apache License 2.0 4 votes vote down vote up
@JSMethod(uiThread = true)
public void push(String param, JSCallback callback) {

    if (!TextUtils.isEmpty(param)) {
        if (WXSDKEngine.getActivityNavBarSetter() != null) {
            if (WXSDKEngine.getActivityNavBarSetter().push(param)) {
                if (callback != null) {
                    callback.invoke(MSG_SUCCESS);
                }
                return;
            }
        }

        try {
            JSONObject jsonObject = JSON.parseObject(param);
            String url = jsonObject.getString(URL);
            if (!TextUtils.isEmpty(url)) {
                Uri rawUri = Uri.parse(url);
                String scheme = rawUri.getScheme();
                Uri.Builder builder = rawUri.buildUpon();
                if (TextUtils.isEmpty(scheme)) {
                    builder.scheme(Constants.Scheme.HTTP);
                }
                Intent intent = new Intent(Intent.ACTION_VIEW, builder.build());
                intent.addCategory(WEEX);
                intent.putExtra(INSTANCE_ID, mWXSDKInstance.getInstanceId());
                mWXSDKInstance.getContext().startActivity(intent);
                if (callback != null) {
                    callback.invoke(MSG_SUCCESS);
                }
            }
        } catch (Exception e) {
            WXLogUtils.eTag(TAG, e);
            if (callback != null) {
                callback.invoke(MSG_FAILED);
            }
        }
    } else if (callback != null) {
        callback.invoke(MSG_FAILED);
    }
}
 
Example 9
Source File: WXNavigatorModule.java    From ucar-weex-core with Apache License 2.0 4 votes vote down vote up
@JSMethod(uiThread = true)
public void push(String param, JSCallback callback) {

    if (!TextUtils.isEmpty(param)) {
        if (WXSDKEngine.getActivityNavBarSetter() != null) {
            if (WXSDKEngine.getActivityNavBarSetter().push(param)) {
                if (callback != null) {
                    callback.invoke(MSG_SUCCESS);
                }
                return;
            }
        }

        try {
            JSONObject jsonObject = JSON.parseObject(param);
            String url = jsonObject.getString(URL);
            if (!TextUtils.isEmpty(url)) {
                Uri rawUri = Uri.parse(url);
                String scheme = rawUri.getScheme();
                Uri.Builder builder = rawUri.buildUpon();
                if (TextUtils.isEmpty(scheme)) {
                    builder.scheme(Constants.Scheme.HTTP);
                }
                Intent intent = new Intent(Intent.ACTION_VIEW, builder.build());
                intent.addCategory(WEEX);
                intent.putExtra(INSTANCE_ID, mWXSDKInstance.getInstanceId());
                mWXSDKInstance.getContext().startActivity(intent);
                if (callback != null) {
                    callback.invoke(MSG_SUCCESS);
                }
            }
        } catch (Exception e) {
            WXLogUtils.eTag(TAG, e);
            if (callback != null) {
                callback.invoke(MSG_FAILED);
            }
        }
    } else if (callback != null) {
        callback.invoke(MSG_FAILED);
    }
}