Search in sources :

Example 1 with WXRuntimeException

use of com.taobao.weex.common.WXRuntimeException in project weex-example by KalicyZhou.

the class WXComponentFactory method newInstance.

public static WXComponent newInstance(WXSDKInstance instance, WXDomObject node, WXVContainer parent) {
    if (instance == null || node == null || TextUtils.isEmpty(node.getType())) {
        return null;
    }
    if (sComponentTypes.get(instance.getInstanceId()) == null) {
        Set<String> types = new HashSet<>();
        sComponentTypes.put(instance.getInstanceId(), types);
    }
    sComponentTypes.get(instance.getInstanceId()).add(node.getType());
    IFComponentHolder holder = WXComponentRegistry.getComponent(node.getType());
    if (holder == null) {
        if (WXEnvironment.isApkDebugable()) {
            String tag = "WXComponentFactory error type:[" + node.getType() + "]" + " class not found";
            WXLogUtils.e(tag);
        }
        //For compatible reason of JS framework, unregistered type will be treated as container.
        holder = WXComponentRegistry.getComponent(WXBasicComponentType.CONTAINER);
        if (holder == null) {
            throw new WXRuntimeException("Container component not found.");
        }
    }
    try {
        return holder.createInstance(instance, node, parent);
    } catch (Exception e) {
        WXLogUtils.e("WXComponentFactory Exception type:[" + node.getType() + "] ", e);
    }
    return null;
}
Also used : WXRuntimeException(com.taobao.weex.common.WXRuntimeException) IFComponentHolder(com.taobao.weex.ui.IFComponentHolder) WXRuntimeException(com.taobao.weex.common.WXRuntimeException) HashSet(java.util.HashSet)

Example 2 with WXRuntimeException

use of com.taobao.weex.common.WXRuntimeException in project weex-example by KalicyZhou.

the class WXViewUtils method getScreenWidth.

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;
}
Also used : WXRuntimeException(com.taobao.weex.common.WXRuntimeException) Resources(android.content.res.Resources)

Aggregations

WXRuntimeException (com.taobao.weex.common.WXRuntimeException)2 Resources (android.content.res.Resources)1 IFComponentHolder (com.taobao.weex.ui.IFComponentHolder)1 HashSet (java.util.HashSet)1