Java Code Examples for com.taobao.weex.utils.WXUtils#isUiThread()

The following examples show how to use com.taobao.weex.utils.WXUtils#isUiThread() . 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: WXDomManager.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
/**
 * Remove the specified dom statement. This is called when {@link WXSDKManager} destroy
 * instances.
 * @param instanceId {@link com.taobao.weex.WXSDKInstance#mInstanceId} for the instance
 */
public void removeDomStatement(String instanceId) {
  if (!WXUtils.isUiThread()) {
    throw new WXRuntimeException("[WXDomManager] removeDomStatement");
  }
  final DOMActionContextImpl statement = mDomRegistries.remove(instanceId);
  if (statement != null) {
    post(new Runnable() {

      @Override
      public void run() {
        statement.destroy();
      }
    });
  }
}
 
Example 2
Source File: WXComponent.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
public void destroy() {
  ComponentObserver observer;
  if ((observer = getInstance().getComponentObserver()) != null) {
    observer.onPreDestory(this);
  }

  if (WXEnvironment.isApkDebugable() && !WXUtils.isUiThread()) {
    throw new WXRuntimeException("[WXComponent] destroy can only be called in main thread");
  }
  if(mHost!= null && mHost.getLayerType()==View.LAYER_TYPE_HARDWARE && isLayerTypeEnabled()) {
    mHost.setLayerType(View.LAYER_TYPE_NONE, null);
  }
  removeAllEvent();
  removeStickyStyle();

  View view;
  if(mDomObj.isFixed() && (view = getHostView()) != null){
    getInstance().removeFixedView(view);
  }

  mDomObj = ImmutableDomObject.DESTROYED;
  mIsDestroyed = true;
}
 
Example 3
Source File: WXDomManager.java    From weex-uikit with MIT License 6 votes vote down vote up
/**
 * Remove the specified dom statement. This is called when {@link WXSDKManager} destroy
 * instances.
 * @param instanceId {@link com.taobao.weex.WXSDKInstance#mInstanceId} for the instance
 */
public void removeDomStatement(String instanceId) {
  if (!WXUtils.isUiThread()) {
    throw new WXRuntimeException("[WXDomManager] removeDomStatement");
  }
  final WXDomStatement statement = mDomRegistries.remove(instanceId);
  if (statement != null) {
    post(new Runnable() {

      @Override
      public void run() {
        statement.destroy();
      }
    });
  }
}
 
Example 4
Source File: WXComponent.java    From weex-uikit with MIT License 6 votes vote down vote up
/********************************
 *  end hook Activity life cycle callback
 ********************************************************/


public void destroy() {
  if (WXEnvironment.isApkDebugable() && !WXUtils.isUiThread()) {
    throw new WXRuntimeException("[WXComponent] destroy can only be called in main thread");
  }
  if(mHost!= null && mHost.getLayerType()==View.LAYER_TYPE_HARDWARE) {
    mHost.setLayerType(View.LAYER_TYPE_NONE, null);
  }
  removeAllEvent();
  removeStickyStyle();
  if (mDomObj != null) {
    mDomObj = null;
  }
}
 
Example 5
Source File: WXDomManager.java    From weex with Apache License 2.0 6 votes vote down vote up
/**
 * Remove the specified dom statement. This is called when {@link WXSDKManager} destroy
 * instances.
 * @param instanceId {@link com.taobao.weex.WXSDKInstance#mInstanceId} for the instance
 */
public void removeDomStatement(String instanceId) {
  if (!WXUtils.isUiThread()) {
    throw new WXRuntimeException("[WXDomManager] removeDomStatement");
  }
  final WXDomStatement statement = mDomRegistries.remove(instanceId);
  if (statement != null) {
    post(new Runnable() {

      @Override
      public void run() {
        statement.destroy();
      }
    });
  }
}
 
Example 6
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 7
Source File: WXRenderManager.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
/**
 * Remove renderStatement, can only be invoked in UI thread.
 * @param instanceId {@link WXSDKInstance#mInstanceId}
 */
public void removeRenderStatement(String instanceId) {
  if (!WXUtils.isUiThread()) {
    throw new WXRuntimeException("[WXRenderManager] removeRenderStatement can only be called in main thread");
  }
  RenderActionContextImpl statement = mRegistries.remove(instanceId);
  if (statement != null) {
    statement.destroy();
  }
}
 
Example 8
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 9
Source File: WXRenderManager.java    From weex-uikit with MIT License 5 votes vote down vote up
/**
 * Remove renderStatement, can only be invoked in UI thread.
 * @param instanceId {@link WXSDKInstance#mInstanceId}
 */
public void removeRenderStatement(String instanceId) {
  if (!WXUtils.isUiThread()) {
    throw new WXRuntimeException("[WXRenderManager] removeRenderStatement can only be called in main thread");
  }
  WXRenderStatement statement = mRegistries.remove(instanceId);
  if (statement != null) {
    statement.destroy();
  }
}
 
Example 10
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 11
Source File: WXRenderManager.java    From weex with Apache License 2.0 5 votes vote down vote up
/**
 * Remove renderStatement, can only be invoked in UI thread.
 * @param instanceId {@link WXSDKInstance#mInstanceId}
 */
public void removeRenderStatement(String instanceId) {
  if (!WXUtils.isUiThread()) {
    throw new WXRuntimeException("[WXRenderManager] removeRenderStatement can only be called in main thread");
  }
  WXRenderStatement statement = mRegistries.remove(instanceId);
  if (statement != null) {
    statement.destroy();
  }
}
 
Example 12
Source File: WXComponent.java    From weex with Apache License 2.0 5 votes vote down vote up
public void destroy() {
  if (WXEnvironment.isApkDebugable() && !WXUtils.isUiThread()) {
    throw new WXRuntimeException("[WXComponent] destroy can only be called in main thread");
  }
  removeAllEvent();
  removeStickyStyle();
  if (mDomObj != null) {
    mDomObj.destroy();
  }
}