com.taobao.weex.utils.WXReflectionUtils Java Examples

The following examples show how to use com.taobao.weex.utils.WXReflectionUtils. 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
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);
  }
}
 
Example #2
Source File: WXSDKInstance.java    From weex-uikit with MIT License 6 votes vote down vote up
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);
  }
}
 
Example #3
Source File: WXSDKInstance.java    From weex with Apache License 2.0 6 votes vote down vote up
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);

    }
  } catch (Exception e) {
    WXLogUtils.e("WXSDKInstance destroyView Exception: " + WXLogUtils.getStackTrace(e));
  }
}
 
Example #4
Source File: NativeInvokeHelper.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
private Object[] prepareArguments(Type[] paramClazzs, JSONArray args) throws Exception {
  Object[] params = new Object[paramClazzs.length];
  Object value;
  Type paramClazz;
  for (int i = 0; i < paramClazzs.length; i++) {
    paramClazz = paramClazzs[i];
    if(i>=args.size()){
      if(!paramClazz.getClass().isPrimitive()) {
        params[i] = null;
        continue;
      }else {
        throw new Exception("[prepareArguments] method argument list not match.");
      }
    }
    value = args.get(i);

    if (paramClazz == JSONObject.class) {
      params[i] = value;
    } else if(JSCallback.class == paramClazz){
      if(value instanceof String){
        params[i] = new SimpleJSCallback(mInstanceId,(String)value);
      }else{
        throw new Exception("Parameter type not match.");
      }
    } else {
      params[i] = WXReflectionUtils.parseArgument(paramClazz,value);
    }
  }
  return params;
}
 
Example #5
Source File: WXScrollView.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
public WXScrollView(Context context) {
  super(context);
  mScrollViewListeners = new ArrayList<>();
  init();
  try {
    WXReflectionUtils.setValue(this, "mMinimumVelocity", 5);
  } catch (Exception e) {
    WXLogUtils.e("[WXScrollView] WXScrollView: ", e);
  }
}
 
Example #6
Source File: NativeInvokeHelper.java    From weex-uikit with MIT License 5 votes vote down vote up
private Object[] prepareArguments(Type[] paramClazzs, JSONArray args) throws Exception {
  Object[] params = new Object[paramClazzs.length];
  Object value;
  Type paramClazz;
  for (int i = 0; i < paramClazzs.length; i++) {
    paramClazz = paramClazzs[i];
    if(i>=args.size()){
      if(!paramClazz.getClass().isPrimitive()) {
        params[i] = null;
        continue;
      }else {
        throw new Exception("[prepareArguments] method argument list not match.");
      }
    }
    value = args.get(i);

    if (paramClazz == JSONObject.class) {
      params[i] = value;
    } else if(JSCallback.class == paramClazz){
      if(value instanceof String){
        params[i] = new SimpleJSCallback(mInstanceId,(String)value);
      }else{
        throw new Exception("Parameter type not match.");
      }
    } else {
      params[i] = WXReflectionUtils.parseArgument(paramClazz,value);
    }
  }
  return params;
}
 
Example #7
Source File: WXScrollView.java    From weex-uikit with MIT License 5 votes vote down vote up
public WXScrollView(Context context) {
  super(context);
  mScrollViewListeners = new ArrayList<>();
  init();
  try {
    WXReflectionUtils.setValue(this, "mMinimumVelocity", 5);
  } catch (Exception e) {
    WXLogUtils.e("[WXScrollView] WXScrollView: ", e);
  }
}
 
Example #8
Source File: WXScrollView.java    From weex with Apache License 2.0 5 votes vote down vote up
public WXScrollView(Context context) {
  super(context);
  mScrollViewListeners = new ArrayList<>();
  init();
  try {
    WXReflectionUtils.setValue(this, "mMinimumVelocity", 5);
  } catch (Exception e) {
    WXLogUtils.e("[WXScrollView] WXScrollView: " + WXLogUtils.getStackTrace(e));
  }
}