com.taobao.weex.ui.component.WXComponentFactory Java Examples

The following examples show how to use com.taobao.weex.ui.component.WXComponentFactory. 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: AbstractAddElementAction.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
protected WXComponent generateComponentTree(DOMActionContext context, WXDomObject dom, WXVContainer parent) {
  if (dom == null) {
    return null;
  }
  WXComponent component = WXComponentFactory.newInstance(context.getInstance(), dom, parent);

  context.registerComponent(dom.getRef(), component);
  if (component instanceof WXVContainer) {
    WXVContainer parentC = (WXVContainer) component;
    int count = dom.childCount();
    WXDomObject child = null;
    for (int i = 0; i < count; ++i) {
      child = dom.getChild(i);
      if (child != null) {
        parentC.addChild(generateComponentTree(context, child, parentC));
      }
    }
  }

  return component;
}
 
Example #2
Source File: WXRenderStatement.java    From weex-uikit with MIT License 6 votes vote down vote up
private WXComponent generateComponentTree(WXDomObject dom, WXVContainer parent) {
  if (dom == null ) {
    return null;
  }
  WXComponent component = WXComponentFactory.newInstance(mWXSDKInstance, dom,parent);

  mRegistry.put(dom.getRef(), component);
  if (component instanceof WXVContainer) {
    WXVContainer parentC = (WXVContainer) component;
    int count = dom.childCount();
    WXDomObject child = null;
    for (int i = 0; i < count; ++i) {
      child = dom.getChild(i);
      if (child != null) {
        parentC.addChild(generateComponentTree(child, parentC));
      }
    }
  }

  return component;
}
 
Example #3
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 #4
Source File: WXRenderStatement.java    From weex with Apache License 2.0 6 votes vote down vote up
private WXComponent generateComponentTree(WXDomObject dom, WXVContainer parent) {
  if (dom == null || parent == null) {
    return null;
  }
  WXComponent component = WXComponentFactory.newInstance(mWXSDKInstance, dom,
                                                         parent, parent.isLazy());

  mRegistry.put(dom.ref, component);
  if (component instanceof WXVContainer) {
    WXVContainer parentC = (WXVContainer) component;
    int count = dom.childCount();
    WXDomObject child = null;
    for (int i = 0; i < count; ++i) {
      child = dom.getChild(i);
      if (child != null) {
        parentC.addChild(generateComponentTree(child, parentC));
      }
    }
  }

  return component;
}
 
Example #5
Source File: WXSDKInstance.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
@Override
public void onActivityPause() {
  onViewDisappear();
  if(!isCommit){
    Set<String> componentTypes= WXComponentFactory.getComponentTypesByInstanceId(getInstanceId());
    if(componentTypes!=null && componentTypes.contains(WXBasicComponentType.SCROLLER)){
      mWXPerformance.useScroller=1;
    }
    mWXPerformance.maxDeepViewLayer=getMaxDeepLayer();
    if (mUserTrackAdapter != null) {
      mUserTrackAdapter.commit(mContext, null, IWXUserTrackAdapter.LOAD, mWXPerformance, getUserTrackParams());
    }
    isCommit=true;
  }
  // module listen Activity onActivityPause
  WXModuleManager.onActivityPause(getInstanceId());
  if(mRootComp != null) {
    mRootComp.onActivityPause();
  }else{
    WXLogUtils.w("Warning :Component tree has not build completely,onActivityPause can not be call!");
  }

  WXLogUtils.i("Application onActivityPause()");
  if (!mCurrentGround) {
    WXLogUtils.i("Application to be in the backround");
    Intent intent = new Intent(WXGlobalEventReceiver.EVENT_ACTION);
    intent.putExtra(WXGlobalEventReceiver.EVENT_NAME, Constants.Event.PAUSE_EVENT);
    intent.putExtra(WXGlobalEventReceiver.EVENT_WX_INSTANCEID, getInstanceId());
    mContext.sendBroadcast(intent);
    this.mCurrentGround = true;
  }
}
 
Example #6
Source File: WXSDKInstance.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
public synchronized void destroy() {
  WXSDKManager.getInstance().destroyInstance(mInstanceId);
  WXComponentFactory.removeComponentTypesByInstanceId(getInstanceId());

  if(mGlobalEventReceiver!=null){
    getContext().unregisterReceiver(mGlobalEventReceiver);
    mGlobalEventReceiver=null;
  }
  if(mRootComp != null ) {
    mRootComp.destroy();
    destroyView(mRenderContainer);
    mRenderContainer = null;
    mRootComp = null;
  }

  if(mGlobalEvents!=null){
    mGlobalEvents.clear();
  }

  if(mComponentObserver != null){
      mComponentObserver = null;
  }

  mNestedInstanceInterceptor = null;
  mUserTrackAdapter = null;
  mScrollView = null;
  mContext = null;
  mRenderListener = null;
  isDestroy = true;
  mStatisticsListener = null;
}
 
Example #7
Source File: WXSDKInstanceTest.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
public static void setupRoot(WXSDKInstance instance){

    WXDomObject domObject = new WXDomObject();
    WXVContainer comp = (WXVContainer) WXComponentFactory.newInstance(instance, domObject, null);

    WXComponent root = WXDivTest.create(comp);
    comp.addChild(root);
    comp.createView();

    instance.onCreateFinish();
    ShadowLooper.idleMainLooper();
  }
 
Example #8
Source File: WXRenderStatementTest.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    PowerMockito.mockStatic(WXSoInstallMgrSdk.class);
    PowerMockito.mockStatic(TextUtils.class);
    PowerMockito.mockStatic(WXComponentFactory.class);
    PowerMockito.when(TextUtils.isEmpty("124")).thenReturn(true);
    PowerMockito.when(WXSoInstallMgrSdk.initSo(null, 1, null)).thenReturn(true);
    WXSDKInstance instance = Mockito.mock(WXSDKInstance.class);
    mWXRenderStatement = new RenderActionContextImpl(instance);
}
 
Example #9
Source File: WXSDKInstance.java    From weex-uikit with MIT License 5 votes vote down vote up
@Override
public void onActivityPause() {
  onViewDisappear();
  if(!isCommit){
    Set<String> componentTypes= WXComponentFactory.getComponentTypesByInstanceId(getInstanceId());
    if(componentTypes!=null && componentTypes.contains(WXBasicComponentType.SCROLLER)){
      mWXPerformance.useScroller=1;
    }
    mWXPerformance.maxDeepViewLayer=getMaxDeepLayer();
    if (mUserTrackAdapter != null) {
      mUserTrackAdapter.commit(mContext, null, IWXUserTrackAdapter.LOAD, mWXPerformance, getUserTrackParams());
    }
    isCommit=true;
  }
  // module listen Activity onActivityPause
  WXModuleManager.onActivityPause(getInstanceId());
  if(mRootComp != null) {
    mRootComp.onActivityPause();
  }else{
    WXLogUtils.w("Warning :Component tree has not build completely,onActivityPause can not be call!");
  }

  Intent intent=new Intent(WXGlobalEventReceiver.EVENT_ACTION);
  intent.putExtra(WXGlobalEventReceiver.EVENT_NAME,Constants.Event.PAUSE_EVENT);
  intent.putExtra(WXGlobalEventReceiver.EVENT_WX_INSTANCEID,getInstanceId());
  mContext.sendBroadcast(intent);
}
 
Example #10
Source File: WXSDKInstance.java    From weex-uikit with MIT License 5 votes vote down vote up
public synchronized void destroy() {
  WXSDKManager.getInstance().destroyInstance(mInstanceId);
  WXComponentFactory.removeComponentTypesByInstanceId(getInstanceId());

  if(mGlobalEventReceiver!=null){
    getContext().unregisterReceiver(mGlobalEventReceiver);
    mGlobalEventReceiver=null;
  }

  if(mRootComp != null ) {
    mRootComp.destroy();
    destroyView(mRenderContainer);
    mRenderContainer = null;
    mRootComp = null;
  }

  if(mGlobalEvents!=null){
    mGlobalEvents.clear();
  }


  mNestedInstanceInterceptor = null;
  mUserTrackAdapter = null;
  mScrollView = null;
  mContext = null;
  mRenderListener = null;
  isDestroy=true;
}
 
Example #11
Source File: WXRenderStatementTest.java    From weex-uikit with MIT License 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    PowerMockito.mockStatic(WXSoInstallMgrSdk.class);
    PowerMockito.mockStatic(TextUtils.class);
    PowerMockito.mockStatic(WXComponentFactory.class);
    PowerMockito.when(TextUtils.isEmpty("124")).thenReturn(true);
    PowerMockito.when(WXSoInstallMgrSdk.initSo(null, 1, null)).thenReturn(true);
    WXSDKInstance instance = Mockito.mock(WXSDKInstance.class);
    mWXRenderStatement = new WXRenderStatement(instance);
}
 
Example #12
Source File: WXRenderStatementTest.java    From weex with Apache License 2.0 5 votes vote down vote up
@Before
    public void setUp() throws Exception {
        PowerMockito.mockStatic(WXSoInstallMgrSdk.class);
        PowerMockito.mockStatic(TextUtils.class);
        PowerMockito.mockStatic(WXComponentFactory.class);
        PowerMockito.when(TextUtils.isEmpty("124")).thenReturn(true);
        PowerMockito.when(WXSoInstallMgrSdk.initSo(null, 1, null)).thenReturn(true);
//        WXSDKEngine.init(RuntimeEnvironment.application);
        WXSDKInstance instance = Mockito.mock(WXSDKInstance.class);
        mWXRenderStatement = new WXRenderStatement(instance, "123");
    }