Search in sources :

Example 1 with IFComponentHolder

use of com.taobao.weex.ui.IFComponentHolder 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)

Aggregations

WXRuntimeException (com.taobao.weex.common.WXRuntimeException)1 IFComponentHolder (com.taobao.weex.ui.IFComponentHolder)1 HashSet (java.util.HashSet)1