Java Code Examples for com.taobao.weex.utils.WXReflectionUtils

The following examples show how to use com.taobao.weex.utils.WXReflectionUtils. These examples are extracted from open source projects. 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 Project: ucar-weex-core   Source File: WXSDKInstance.java    License: 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 Project: weex-uikit   Source File: WXSDKInstance.java    License: 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 Project: weex   Source File: WXSDKInstance.java    License: 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 Project: ucar-weex-core   Source File: NativeInvokeHelper.java    License: 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 Project: ucar-weex-core   Source File: WXScrollView.java    License: 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 Project: weex-uikit   Source File: NativeInvokeHelper.java    License: 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 Project: weex-uikit   Source File: WXScrollView.java    License: 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 Project: weex   Source File: WXScrollView.java    License: 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));
  }
}