com.taobao.weex.bridge.WXModuleManager Java Examples

The following examples show how to use com.taobao.weex.bridge.WXModuleManager. 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: WXSDKInstance.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
/********************************
 *  begin hook Activity life cycle callback
 ********************************************************/

@Override
public void onActivityCreate() {

  // module listen Activity onActivityCreate
  WXModuleManager.onActivityCreate(getInstanceId());

  if(mRootComp != null) {
    mRootComp.onActivityCreate();
  }else{
    WXLogUtils.w("Warning :Component tree has not build completely,onActivityCreate can not be call!");
  }

  mGlobalEventReceiver=new WXGlobalEventReceiver(this);
  getContext().registerReceiver(mGlobalEventReceiver,new IntentFilter(WXGlobalEventReceiver.EVENT_ACTION));
}
 
Example #2
Source File: WXSDKInstance.java    From weex-uikit with MIT License 6 votes vote down vote up
@Override
public void onActivityResume() {

  // notify onActivityResume callback to module
  WXModuleManager.onActivityResume(getInstanceId());

  if(mRootComp != null) {
    mRootComp.onActivityResume();
  }else{
    WXLogUtils.w("Warning :Component tree has not build completely, onActivityResume can not be call!");
  }

  Intent intent=new Intent(WXGlobalEventReceiver.EVENT_ACTION);
  intent.putExtra(WXGlobalEventReceiver.EVENT_NAME,Constants.Event.RESUME_EVENT);
  intent.putExtra(WXGlobalEventReceiver.EVENT_WX_INSTANCEID,getInstanceId());
  mContext.sendBroadcast(intent);

  onViewAppear();
}
 
Example #3
Source File: WXSDKInstance.java    From weex-uikit with MIT License 6 votes vote down vote up
/********************************
 *  begin hook Activity life cycle callback
 ********************************************************/

@Override
public void onActivityCreate() {

  // module listen Activity onActivityCreate
  WXModuleManager.onActivityCreate(getInstanceId());

  if(mRootComp != null) {
    mRootComp.onActivityCreate();
  }else{
    WXLogUtils.w("Warning :Component tree has not build completely,onActivityCreate can not be call!");
  }

  mGlobalEventReceiver=new WXGlobalEventReceiver(this);
  getContext().registerReceiver(mGlobalEventReceiver,new IntentFilter(WXGlobalEventReceiver.EVENT_ACTION));
}
 
Example #4
Source File: WXSDKInstance.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityResume() {

  // notify onActivityResume callback to module
  WXModuleManager.onActivityResume(getInstanceId());

  if(mRootComp != null) {
    mRootComp.onActivityResume();
  }else{
    WXLogUtils.w("Warning :Component tree has not build completely, onActivityResume can not be call!");
  }

  if (mCurrentGround) {
    WXLogUtils.i("Application  to be in the foreground");
    Intent intent = new Intent(WXGlobalEventReceiver.EVENT_ACTION);
    intent.putExtra(WXGlobalEventReceiver.EVENT_NAME, Constants.Event.RESUME_EVENT);
    intent.putExtra(WXGlobalEventReceiver.EVENT_WX_INSTANCEID, getInstanceId());
    mContext.sendBroadcast(intent);
    mCurrentGround = false;
  }

  onViewAppear();

  setViewPortWidth(mInstanceViewPortWidth);
}
 
Example #5
Source File: WXSDKInstance.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
public boolean onCreateOptionsMenu(Menu menu) {

    WXModuleManager.onCreateOptionsMenu(getInstanceId(),menu);
    if(mRootComp != null) {
      mRootComp.onCreateOptionsMenu(menu);
    }else{
      WXLogUtils.w("Warning :Component tree has not build completely,onActivityStart can not be call!");
    }
    return true;
  }
 
Example #6
Source File: WXSDKManager.java    From weex with Apache License 2.0 5 votes vote down vote up
void destroyInstance(String instanceId) {
  if (TextUtils.isEmpty(instanceId)) {
    return;
  }
  if (!WXUtils.isUiThread()) {
    throw new WXRuntimeException("[WXSDKManager] destroyInstance error");
  }
  mWXRenderManager.removeRenderStatement(instanceId);
  mWXDomManager.removeDomStatement(instanceId);
  mBridgeManager.destroyInstance(instanceId);
  WXModuleManager.destroyInstanceModules(instanceId);
}
 
Example #7
Source File: WXSDKEngine.java    From weex-uikit with MIT License 5 votes vote down vote up
public static void reload(final Context context,String framework, boolean remoteDebug) {
  WXEnvironment.sRemoteDebugMode = remoteDebug;
  WXBridgeManager.getInstance().restart();
  WXBridgeManager.getInstance().initScriptsFramework(framework);
  WXModuleManager.reload();
  WXComponentRegistry.reload();
  WXSDKManager.getInstance().postOnUiThread(new Runnable() {
    @Override
    public void run() {
      LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent(JS_FRAMEWORK_RELOAD));
    }
  });
}
 
Example #8
Source File: WXSDKInstance.java    From weex-uikit with MIT License 5 votes vote down vote up
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {

    WXModuleManager.onRequestPermissionsResult(getInstanceId(),requestCode,permissions,grantResults);

    if(mRootComp != null) {
       mRootComp.onRequestPermissionsResult(requestCode,permissions,grantResults);
    }else{
      WXLogUtils.w("Warning :Component tree has not build completely, onRequestPermissionsResult can not be call!");
    }
  }
 
Example #9
Source File: WXSDKInstance.java    From weex-uikit with MIT License 5 votes vote down vote up
public void onActivityResult(int requestCode, int resultCode, Intent data){
  WXModuleManager.onActivityResult(getInstanceId(),requestCode,resultCode,data);

  if(mRootComp != null) {
    mRootComp.onActivityResult(requestCode,requestCode,data);
  }else{
    WXLogUtils.w("Warning :Component tree has not build completely, onActivityResult can not be call!");
  }
}
 
Example #10
Source File: WXSDKInstance.java    From weex-uikit with MIT License 5 votes vote down vote up
@Override
public boolean onActivityBack() {

  WXModuleManager.onActivityBack(getInstanceId());

  if(mRootComp != null) {
    return mRootComp.onActivityBack();
  }else{
    WXLogUtils.w("Warning :Component tree has not build completely, onActivityBack can not be call!");
  }

  return false;
}
 
Example #11
Source File: WXSDKInstance.java    From weex-uikit with MIT License 5 votes vote down vote up
@Override
public void onActivityDestroy() {
  WXModuleManager.onActivityDestroy(getInstanceId());

  if(mRootComp != null) {
    mRootComp.onActivityDestroy();
  }else{
    WXLogUtils.w("Warning :Component tree has not build completely, onActivityDestroy can not be call!");
  }

  destroy();
}
 
Example #12
Source File: WXSDKInstance.java    From weex-uikit with MIT License 5 votes vote down vote up
@Override
public void onActivityStop() {

  // notify onActivityResume callback to module
  WXModuleManager.onActivityStop(getInstanceId());

  if(mRootComp != null) {
    mRootComp.onActivityStop();
  }else{
    WXLogUtils.w("Warning :Component tree has not build completely, onActivityStop can not be call!");
  }


}
 
Example #13
Source File: WXSDKManager.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
void destroyInstance(String instanceId) {
  setCrashInfo(WXEnvironment.WEEX_CURRENT_KEY,"");
  if (TextUtils.isEmpty(instanceId)) {
    return;
  }
  if (!WXUtils.isUiThread()) {
    throw new WXRuntimeException("[WXSDKManager] destroyInstance error");
  }
  mWXRenderManager.removeRenderStatement(instanceId);
  mWXDomManager.removeDomStatement(instanceId);
  mBridgeManager.destroyInstance(instanceId);
  WXModuleManager.destroyInstanceModules(instanceId);
}
 
Example #14
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 #15
Source File: WXSDKInstance.java    From weex-uikit with MIT License 5 votes vote down vote up
public boolean onCreateOptionsMenu(Menu menu) {

    WXModuleManager.onCreateOptionsMenu(getInstanceId(),menu);
    if(mRootComp != null) {
      mRootComp.onCreateOptionsMenu(menu);
    }else{
      WXLogUtils.w("Warning :Component tree has not build completely,onActivityStart can not be call!");
    }
    return true;
  }
 
Example #16
Source File: WXSDKInstance.java    From weex-uikit with MIT License 5 votes vote down vote up
@Override
public void onActivityStart() {

  // module listen Activity onActivityCreate
  WXModuleManager.onActivityStart(getInstanceId());
  if(mRootComp != null) {
    mRootComp.onActivityStart();
  }else{
    WXLogUtils.w("Warning :Component tree has not build completely,onActivityStart can not be call!");
  }

}
 
Example #17
Source File: WXSDKInstance.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
@Override
public void onActivityStart() {

  // module listen Activity onActivityCreate
  WXModuleManager.onActivityStart(getInstanceId());
  if(mRootComp != null) {
    mRootComp.onActivityStart();
  }else{
    WXLogUtils.w("Warning :Component tree has not build completely,onActivityStart can not be call!");
  }

}
 
Example #18
Source File: WXSDKManager.java    From weex-uikit with MIT License 5 votes vote down vote up
void destroyInstance(String instanceId) {
  if (TextUtils.isEmpty(instanceId)) {
    return;
  }
  if (!WXUtils.isUiThread()) {
    throw new WXRuntimeException("[WXSDKManager] destroyInstance error");
  }
  mWXRenderManager.removeRenderStatement(instanceId);
  mWXDomManager.removeDomStatement(instanceId);
  mBridgeManager.destroyInstance(instanceId);
  WXModuleManager.destroyInstanceModules(instanceId);
}
 
Example #19
Source File: WXSDKEngine.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
public static void reload(final Context context,String framework, boolean remoteDebug) {
  WXEnvironment.sRemoteDebugMode = remoteDebug;
  WXBridgeManager.getInstance().restart();
  WXBridgeManager.getInstance().initScriptsFramework(framework);
  WXModuleManager.reload();
  WXComponentRegistry.reload();
  WXSDKManager.getInstance().postOnUiThread(new Runnable() {
    @Override
    public void run() {
      LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent(JS_FRAMEWORK_RELOAD));
    }
  }, 1000);
}
 
Example #20
Source File: WXSDKInstance.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {

    WXModuleManager.onRequestPermissionsResult(getInstanceId(),requestCode,permissions,grantResults);

    if(mRootComp != null) {
       mRootComp.onRequestPermissionsResult(requestCode,permissions,grantResults);
    }else{
      WXLogUtils.w("Warning :Component tree has not build completely, onRequestPermissionsResult can not be call!");
    }
  }
 
Example #21
Source File: WXSDKInstance.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
public void onActivityResult(int requestCode, int resultCode, Intent data){
  WXModuleManager.onActivityResult(getInstanceId(),requestCode,resultCode,data);

  if(mRootComp != null) {
    mRootComp.onActivityResult(requestCode,resultCode,data);
  }else{
    WXLogUtils.w("Warning :Component tree has not build completely, onActivityResult can not be call!");
  }
}
 
Example #22
Source File: WXSDKInstance.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onActivityBack() {

  WXModuleManager.onActivityBack(getInstanceId());

  if(mRootComp != null) {
    return mRootComp.onActivityBack();
  }else{
    WXLogUtils.w("Warning :Component tree has not build completely, onActivityBack can not be call!");
  }

  return false;
}
 
Example #23
Source File: WXSDKInstance.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
@Override
public void onActivityDestroy() {
  WXModuleManager.onActivityDestroy(getInstanceId());

  if(mRootComp != null) {
    mRootComp.onActivityDestroy();
  }else{
    WXLogUtils.w("Warning :Component tree has not build completely, onActivityDestroy can not be call!");
  }

  destroy();
}
 
Example #24
Source File: WXSDKInstance.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
@Override
public void onActivityStop() {

  // notify onActivityResume callback to module
  WXModuleManager.onActivityStop(getInstanceId());

  if(mRootComp != null) {
    mRootComp.onActivityStop();
  }else{
    WXLogUtils.w("Warning :Component tree has not build completely, onActivityStop can not be call!");
  }


}
 
Example #25
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 #26
Source File: WXSDKEngine.java    From ucar-weex-core with Apache License 2.0 4 votes vote down vote up
private static <T extends WXModule> boolean registerModule(String moduleName, ModuleFactory factory, boolean global) throws WXException {
  return WXModuleManager.registerModule(moduleName, factory,global);
}
 
Example #27
Source File: WXSDKEngine.java    From weex-uikit with MIT License 4 votes vote down vote up
private static <T extends WXModule> boolean registerModule(String moduleName, ModuleFactory factory, boolean global) throws WXException {
  return WXModuleManager.registerModule(moduleName, factory,global);
}
 
Example #28
Source File: WXSDKEngine.java    From weex with Apache License 2.0 4 votes vote down vote up
private static <T extends WXModule> boolean registerModule(String moduleName, ModuleFactory factory, boolean global) throws WXException {
  return WXModuleManager.registerModule(moduleName, factory,global);
}