Search in sources :

Example 1 with Destroyable

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

the class WXModuleManager method destroyInstanceModules.

public static void destroyInstanceModules(String instanceId) {
    sDomModuleMap.remove(instanceId);
    Map<String, WXModule> moduleMap = sInstanceModuleMap.remove(instanceId);
    if (moduleMap == null || moduleMap.size() < 1) {
        return;
    }
    Iterator<Entry<String, WXModule>> iterator = moduleMap.entrySet().iterator();
    Entry<String, WXModule> entry;
    while (iterator.hasNext()) {
        entry = iterator.next();
        WXModule module = entry.getValue();
        if (module instanceof Destroyable) {
            ((Destroyable) module).destroy();
        }
    }
}
Also used : Entry(java.util.Map.Entry) Destroyable(com.taobao.weex.common.Destroyable) WXModule(com.taobao.weex.common.WXModule)

Example 2 with Destroyable

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

the class WXSDKInstance method destroyView.

private void destroyView(View rootView) {
    try {
        if (rootView instanceof ViewGroup) {
            ViewGroup cViewGroup = ((ViewGroup) rootView);
            for (int index = 0; index < cViewGroup.getChildCount(); index++) {
                destroyView(cViewGroup.getChildAt(index));
            }
            cViewGroup.removeViews(0, ((ViewGroup) rootView).getChildCount());
            // Ensure that the viewgroup's status to be normal
            WXReflectionUtils.setValue(rootView, "mChildrenCount", 0);
        }
        if (rootView instanceof Destroyable) {
            ((Destroyable) rootView).destroy();
        }
    } catch (Exception e) {
        WXLogUtils.e("WXSDKInstance destroyView Exception: ", e);
    }
}
Also used : Destroyable(com.taobao.weex.common.Destroyable) ViewGroup(android.view.ViewGroup)

Aggregations

Destroyable (com.taobao.weex.common.Destroyable)2 ViewGroup (android.view.ViewGroup)1 WXModule (com.taobao.weex.common.WXModule)1 Entry (java.util.Map.Entry)1