com.taobao.weex.utils.WXLogUtils Java Examples

The following examples show how to use com.taobao.weex.utils.WXLogUtils. 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: WXDomRegistry.java    From weex-uikit with MIT License 6 votes vote down vote up
public static boolean registerDomObject(String type, Class<? extends WXDomObject> clazz) throws WXException {
  if (clazz == null || TextUtils.isEmpty(type)) {
    return false;
  }

  if (sDom.containsKey(type)) {
    if (WXEnvironment.isApkDebugable()) {
      throw new WXException("WXDomRegistry had duplicate Dom:" + type);
    } else {
      WXLogUtils.e("WXDomRegistry had duplicate Dom: " + type);
      return false;
    }
  }
  sDom.put(type, clazz);
  return true;
}
 
Example #2
Source File: WXBridge.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
public int callNative(String instanceId, String tasks, String callback) {
  long start = System.currentTimeMillis();
  WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(instanceId);
  if(instance != null) {
    instance.firstScreenCreateInstanceTime(start);
  }
  int errorCode = IWXBridge.INSTANCE_RENDERING;
  try {
    errorCode = WXBridgeManager.getInstance().callNative(instanceId, tasks, callback);
  }catch (Throwable e){
    //catch everything during call native.
    if(WXEnvironment.isApkDebugable()){
      WXLogUtils.e(TAG,"callNative throw exception:"+e.getMessage());
    }
  }

  if(instance != null) {
    instance.callNativeTime(System.currentTimeMillis() - start);
  }
  if(WXEnvironment.isApkDebugable()){
    if(errorCode == IWXBridge.DESTROY_INSTANCE){
      WXLogUtils.w("destroyInstance :"+instanceId+" JSF must stop callNative");
    }
  }
  return errorCode;
}
 
Example #3
Source File: WXCircleViewPager.java    From weex-uikit with MIT License 6 votes vote down vote up
/**
 * Override the Scroller instance with our own class so we can change the
 * duration
 */
private void postInitViewPager() {
  if (isInEditMode()) {
    return;
  }
  try {
    Field scroller = ViewPager.class.getDeclaredField("mScroller");
    scroller.setAccessible(true);
    Field interpolator = ViewPager.class
        .getDeclaredField("sInterpolator");
    interpolator.setAccessible(true);

    mScroller = new WXSmoothScroller(getContext(),
        (Interpolator) interpolator.get(null));
    scroller.set(this, mScroller);
  } catch (Exception e) {
    WXLogUtils.e("[CircleViewPager] postInitViewPager: ", e);
  }
}
 
Example #4
Source File: WXBridgeManager.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
/**
 * Report JavaScript Exception
 */
public void reportJSException(String instanceId, String function,
                              String exception) {
  if (WXEnvironment.isApkDebugable()) {
    WXLogUtils.e("reportJSException >>>> instanceId:" + instanceId
                 + ", exception function:" + function + ", exception:"
                 + exception);
  }
  WXSDKInstance instance;
  if (instanceId != null && (instance = WXSDKManager.getInstance().getSDKInstance(instanceId)) != null) {
    instance.onJSException(WXErrorCode.WX_ERR_JS_EXECUTE.getErrorCode(), function, exception);

    String err = "function:" + function + "#exception:" + exception;
    commitJSBridgeAlarmMonitor(instanceId, WXErrorCode.WX_ERR_JS_EXECUTE, err);

    IWXJSExceptionAdapter adapter = WXSDKManager.getInstance().getIWXJSExceptionAdapter();
    if (adapter != null) {
      WXJSExceptionInfo jsException = new WXJSExceptionInfo(instanceId, instance.getBundleUrl(), WXErrorCode.WX_ERR_JS_EXECUTE.getErrorCode(), function, exception, null);
      adapter.onJSException(jsException);
      if (WXEnvironment.isApkDebugable()) {
        WXLogUtils.d(jsException.toString());
      }
    }
  }
}
 
Example #5
Source File: WXCirclePageAdapter.java    From weex-uikit with MIT License 6 votes vote down vote up
@Override
public Object instantiateItem(ViewGroup container, int position) {
  View pageView = null;
  try {
    pageView = shadow.get(position);
    if (WXEnvironment.isApkDebugable()) {
      WXLogUtils.d("onPageSelected >>>> instantiateItem >>>>> position:" + position + ",position % getRealCount()" + position % getRealCount());
    }
    if (pageView.getParent() == null) {
      container.addView(pageView);
    } else {
      ((ViewGroup) pageView.getParent()).removeView(pageView);
      container.addView(pageView);
    }
  } catch (Exception e) {
    WXLogUtils.e("[CirclePageAdapter] instantiateItem: ", e);
  }
  return pageView;
}
 
Example #6
Source File: SimpleComponentHolder.java    From weex-uikit with MIT License 6 votes vote down vote up
private void loadConstructor(){
  Class<? extends WXComponent> c = mCompClz;
  Constructor<? extends WXComponent> constructor;
  try {
    constructor = c.getConstructor(WXSDKInstance.class, WXDomObject.class, WXVContainer.class);
  } catch (NoSuchMethodException e) {
    WXLogUtils.d("ClazzComponentCreator","Use deprecated component constructor");
    try {
      //compatible deprecated constructor with 4 args
      constructor = c.getConstructor(WXSDKInstance.class, WXDomObject.class, WXVContainer.class, boolean.class);
    } catch (NoSuchMethodException e1) {
      try {
        //compatible deprecated constructor with 5 args
        constructor = c.getConstructor(WXSDKInstance.class, WXDomObject.class, WXVContainer.class,String.class, boolean.class);
      } catch (NoSuchMethodException e2) {
        throw new WXRuntimeException("Can't find constructor of component.");
      }
    }
  }
  mConstructor = constructor;
}
 
Example #7
Source File: OkHttpWebSocketClient.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 6 votes vote down vote up
protected void sendProtocolMessage(int requestID, String message) {
    if (mWebSocket == null) {
        return;
    }
    try {
        Field textField = ReflectionUtil.tryGetDeclaredField(mMediaTypeClazz, "TEXT");
        Object textValue = ReflectionUtil.getFieldValue(textField, null);
        Method sendMessageMethod = ReflectionUtil.tryGetMethod(mWebSocketClazz,
                "sendMessage", new Class[]{mMediaTypeClazz, mBufferClazz});

        Object buffer = mBufferClazz.newInstance();
        Method writeUtf8 = ReflectionUtil.tryGetMethod(mBufferClazz, "writeUtf8",
                new Class[]{String.class});

        ReflectionUtil.tryInvokeMethod(mWebSocket, sendMessageMethod, textValue,
                ReflectionUtil.tryInvokeMethod(buffer, writeUtf8, message));
    } catch (Exception e) {
        WXLogUtils.e(TAG, e.getMessage());
    }
}
 
Example #8
Source File: BasicListComponent.java    From weex-uikit with MIT License 6 votes vote down vote up
/**
 * Remove the child from WXListComponent. This method will use {@link
 * java.util.List#indexOf(Object)} to retrieve the component to be deleted. Like {@link
 * #addChild(WXComponent)}, this method will not refresh the view immediately, the adapter will
 * decide when to refresh.
 *
 * @param child the child to be removed
 */
@Override
public void remove(WXComponent child, boolean destroy) {
  int index = mChildren.indexOf(child);
  if (destroy) {
    child.detachViewAndClearPreInfo();
  }
  unBindViewType(child);

  T view = getHostView();
  if (view == null) {
    return;
  }
  view.getRecyclerViewBaseAdapter().notifyItemRemoved(index);
  if (WXEnvironment.isApkDebugable()) {
    WXLogUtils.d(TAG, "removeChild child at " + index);
  }
  super.remove(child, destroy);
}
 
Example #9
Source File: WXImageView.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
@Override
public int getNaturalHeight() {
  Drawable drawable = getDrawable();
  if (drawable != null) {
    if (drawable instanceof ImageDrawable) {
      return ((ImageDrawable) drawable).getBitmapHeight();
    } else if (drawable instanceof BitmapDrawable) {
      Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap();
      if (bitmap != null) {
        return bitmap.getHeight();
      } else {
        WXLogUtils.w("WXImageView", "Bitmap on " + drawable.toString() + " is null");
      }
    } else {
      WXLogUtils.w("WXImageView", "Not supported drawable type: " + drawable.getClass().getSimpleName());
    }
  }
  return -1;
}
 
Example #10
Source File: BasicListComponent.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
@Override
public void onLoadMore(int offScreenY) {
  try {
    String offset = getDomObject().getAttrs().getLoadMoreOffset();

    if (TextUtils.isEmpty(offset)) {
      offset = "0";
    }
    float offsetParsed = WXViewUtils.getRealPxByWidth(Integer.parseInt(offset),getInstance().getInstanceViewPortWidth());

    if (offScreenY < offsetParsed) {

      if (mListCellCount != mChildren.size()
          || mForceLoadmoreNextTime) {
        fireEvent(Constants.Event.LOADMORE);
        mListCellCount = mChildren.size();
        mForceLoadmoreNextTime = false;
      }
    }
  } catch (Exception e) {
    WXLogUtils.d(TAG + "onLoadMore :", e);
  }
}
 
Example #11
Source File: WXCirclePageAdapter.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
@Override
public Object instantiateItem(ViewGroup container, int position) {
  View pageView = null;
  try {
    pageView = shadow.get(position);
    if (WXEnvironment.isApkDebugable()) {
      WXLogUtils.d("onPageSelected >>>> instantiateItem >>>>> position:" + position + ",position % getRealCount()" + position % getRealCount());
    }
    if (pageView.getParent() == null) {
      container.addView(pageView);
    } else {
      ((ViewGroup) pageView.getParent()).removeView(pageView);
      container.addView(pageView);
    }
  } catch (Exception e) {
    WXLogUtils.e("[CirclePageAdapter] instantiateItem: ", e);
  }
  return pageView;
}
 
Example #12
Source File: JacocoCodeCoverage.java    From incubator-weex-playground with Apache License 2.0 6 votes vote down vote up
public static void dumpCodeCoverage(Context context){

	WXLogUtils.d( TAG, "CoverageDataDumper BroadcastReceiver " );

	try {
	  Class
			  .forName( "com.vladium.emma.rt.RT" )
			  .getMethod( "dumpCoverageData", File.class, boolean.class, boolean.class )
			  .invoke( null,
					  new File(context.getExternalFilesDir( null ) + "/coverage.ec" ),
					  true, // merge
					  false // stopDataCollection
			  );
	  WXLogUtils.d( TAG, "generateCoverageReport: ok! " +
			  "file in [Android/data/org.apache.weex/files]" );
	}

	catch ( Exception e ) {
	  WXLogUtils.e( TAG, e );
	}
  }
 
Example #13
Source File: XiaomiOverlayViewPermissionHelper.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 6 votes vote down vote up
public static boolean isPermissionGranted(@NonNull Context context) {
    if(!"Xiaomi".equalsIgnoreCase(Build.MANUFACTURER)) {
        return true;
    }
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        AppOpsManager manager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
        try {
            Method method = manager.getClass().getDeclaredMethod("checkOp", int.class, int.class, String.class);
            int property = (Integer) method.invoke(manager, 24/*AppOpsManager.OP_SYSTEM_ALERT_WINDOW*/,
                    Binder.getCallingUid(), context.getApplicationContext().getPackageName());
            return AppOpsManager.MODE_ALLOWED == property;
        }catch (Throwable e) {
            WXLogUtils.e(TAG,e.getMessage());
            return true;
        }
    } else {
        return true;
    }
}
 
Example #14
Source File: WXSwitchDomObject.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
@Override
public void measure(CSSNode node, float width, MeasureOutput measureOutput) {
  try {
    Context context=((WXDomObject) node).getDomContext().getUIContext();
    WXSwitchView wxSwitchView = new WXSwitchView(context);
    int widthSpec, heightSpec;
    heightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
    if (Float.isNaN(width)) {
      widthSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
    } else {
      widthSpec = MeasureSpec.makeMeasureSpec((int) width, MeasureSpec.AT_MOST);
    }
    wxSwitchView.measure(widthSpec, heightSpec);
    measureOutput.width = wxSwitchView.getMeasuredWidth();
    measureOutput.height = wxSwitchView.getMeasuredHeight();
  } catch (RuntimeException e) {
    WXLogUtils.e(TAG, WXLogUtils.getStackTrace(e));
  }
}
 
Example #15
Source File: DefaultLocation.java    From incubator-weex-playground with Apache License 2.0 6 votes vote down vote up
@Override
public boolean handleMessage(Message msg) {
  if (msg.what == TIME_OUT_WHAT) {
    WXLogUtils.d(TAG, "into--[handleMessage] Location Time Out!");
    if (mContext == null || mLocationManager == null) {
      return false;
    }
    if (ActivityCompat.checkSelfPermission(mContext, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(mContext, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
      mLocationManager.removeUpdates(this);
    }
    Map<String, Object> options = new HashMap<>();
    options.put(ERROR_CODE, ErrorCode.LOCATION_TIME_OUT);
    options.put(ERROR_MSG, ErrorMsg.LOCATION_TIME_OUT);
    if (!TextUtils.isEmpty(mWatchId)) {
      options.put(WATCH_ID, mWatchId);
    }
    if (mErrorCallback != null) {
      mErrorCallback.invoke(options);
    }
    return true;
  }
  return false;
}
 
Example #16
Source File: WXSlider.java    From weex-uikit with MIT License 6 votes vote down vote up
@Deprecated
@WXComponentProp(name = Constants.Name.VALUE)
public void setValue(String value) {
  if (value == null || getHostView() == null) {
    return;
  }
  int i;
  try {
    i = Integer.parseInt(value);
  } catch (NumberFormatException e) {
    WXLogUtils.e("", e);
    return;
  }

  setIndex(i);
}
 
Example #17
Source File: WXThread.java    From weex-uikit with MIT License 6 votes vote down vote up
@Override
public boolean handleMessage(Message msg) {
  boolean result = false;
  try{
    if(mCallback != null){
      result = mCallback.handleMessage(msg);
    }
  }catch (Throwable e){
    //catch everything may throw from exection.
    if(WXEnvironment.isApkDebugable()){
      WXLogUtils.e(TAG,"SafeCallback handleMessage throw expection:"+e.getMessage());
      throw e;
    }
  }
  return result;
}
 
Example #18
Source File: BasicListComponent.java    From weex-uikit with MIT License 6 votes vote down vote up
/**
   * Bind the component of the position to the holder. Then flush the view.
   *
   * @param holder   viewHolder, which holds reference to the view
   * @param position position of component in WXListComponent
   */
  @Override
  public void onBindViewHolder(ListBaseViewHolder holder, int position) {
    if (holder == null) return;
    holder.setComponentUsing(true);
    WXComponent component = getChild(position);
    if (component == null
        || (component instanceof WXRefresh)
        || (component instanceof WXLoading)
        || (component.getDomObject() != null && component.getDomObject().isFixed())
        ) {
      if (WXEnvironment.isApkDebugable()) {
        WXLogUtils.d(TAG, "Bind WXRefresh & WXLoading " + holder);
      }
      return;
    }

    if (holder.getComponent() != null && holder.getComponent() instanceof WXCell) {
      holder.getComponent().bindData(component);
//              holder.getComponent().refreshData(component);
    }

  }
 
Example #19
Source File: WXPageActivity.java    From incubator-weex-playground with Apache License 2.0 6 votes vote down vote up
@Override
public void onViewCreated(WXSDKInstance instance, View view) {
  WXLogUtils.e("into--[onViewCreated]");
  View wrappedView = null;
  if(mWxAnalyzerDelegate != null){
    wrappedView = mWxAnalyzerDelegate.onWeexViewCreated(instance,view);
  }
  if(wrappedView != null){
    view = wrappedView;
  }

  if(view.getParent() == null) {
    mContainer.addView(view);
  }
  mContainer.requestLayout();
  Log.d("WARenderListener", "renderSuccess");
}
 
Example #20
Source File: DefaultWXStorage.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
private long performGetLength() {
    SQLiteDatabase database = mDatabaseSupplier.getDatabase();
    if (database == null) {
        return 0;
    }

    String sql = "SELECT count(" + WXSQLiteOpenHelper.COLUMN_KEY + ") FROM " + WXSQLiteOpenHelper.TABLE_STORAGE;
    SQLiteStatement statement = null;
    try {
        statement = database.compileStatement(sql);
        return statement.simpleQueryForLong();
    } catch (Exception e) {
        WXLogUtils.e(WXSQLiteOpenHelper.TAG_STORAGE, "DefaultWXStorage occurred an exception when execute getLength:" + e.getMessage());
        return 0;
    } finally {
        if(statement != null) {
            statement.close();
        }
    }
}
 
Example #21
Source File: WXBridgeManager.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
public Object callNativeComponent(String instanceId, String componentRef, String method, JSONArray arguments, Object options) {
    if (WXEnvironment.isApkDebugable()) {
        mLodBuilder.append("[WXBridgeManager] callNativeComponent >>>> instanceId:").append(instanceId)
                .append(", componentRef:").append(componentRef).append(", method:").append(method).append(", arguments:").append(arguments);
        WXLogUtils.d(mLodBuilder.substring(0));
        mLodBuilder.setLength(0);
    }
    try {

        WXDomModule dom = getDomModule(instanceId);
        dom.invokeMethod(componentRef, method, arguments);

    } catch (Exception e) {
        WXLogUtils.e("[WXBridgeManager] callNative exception: ", e);
        commitJSBridgeAlarmMonitor(instanceId, WXErrorCode.WX_ERR_INVOKE_NATIVE, "[WXBridgeManager] callNativeModule exception " + e.getCause());
    }
    return null;
}
 
Example #22
Source File: DefaultWXStorage.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
@Override
public void close() {
    try {
        mDatabaseSupplier.closeDatabase();
        if (mExecutorService != null) {
            mExecutorService.shutdown();
            mExecutorService = null;
        }
    } catch (Exception e) {
        WXLogUtils.e(WXSQLiteOpenHelper.TAG_STORAGE, e.getMessage());
    }
}
 
Example #23
Source File: WXTextDomObject.java    From weex with Apache License 2.0 5 votes vote down vote up
@Override
public WXTextDomObject clone() {
  WXTextDomObject dom = null;
  try {
    dom = new WXTextDomObject();
    if (this.cssstyle != null) {
      dom.cssstyle.copy(this.cssstyle);
    }
    dom.ref = ref;
    dom.type = type;
    dom.style = style;
    dom.attr = attr;
    dom.event = event == null ? null : event.clone();
    dom.hasBeenMeasured = hasBeenMeasured;
    dom.atomicReference=atomicReference;
    if (this.csslayout != null) {
      dom.csslayout.copy(this.csslayout);
    }
  } catch (Exception e) {
    if (WXEnvironment.isApkDebugable()) {
      WXLogUtils.e("WXTextDomObject clone error: " + WXLogUtils.getStackTrace(e));
    }
  }
  if (dom != null) {
    dom.spannableStringBuilder = spannableStringBuilder;
  }
  return dom;
}
 
Example #24
Source File: DefaultDragHelper.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
@Override
public void onDragEnd(@NonNull WXComponent component, int from, int to) {
    if (WXEnvironment.isApkDebugable()) {
        WXLogUtils.d(TAG, "list on drag end : " + "from index " + from + " to index " + to);
    }
    mEventTrigger.triggerEvent(EVENT_END_DRAG, buildEvent(component.getRef(), from, to));
}
 
Example #25
Source File: WXScroller.java    From weex with Apache License 2.0 5 votes vote down vote up
/**
 * Handle loadMore Event.when Scroller has bind loadMore Event and set the attr of loadMoreOffset
 * it will tell the JS to handle the event of onLoadMore;
 * @param scrollView  the WXScrollView
 * @param x the X direction
 * @param y the Y direction
 */
protected void onLoadMore(WXScrollView scrollView, int x, int y) {
  try {
    String offset = mDomObj.attr.getLoadMoreOffset();

    if (TextUtils.isEmpty(offset)) {
      return;
    }

    int contentH = scrollView.getChildAt(0).getHeight();
    int scrollerH = scrollView.getHeight();
    int offScreenY = contentH - y - scrollerH;
    if (offScreenY < Integer.parseInt(offset)) {
      if (WXEnvironment.isApkDebugable()) {
        WXLogUtils.d("[WXScroller-onScroll] offScreenY :" + offScreenY);
      }

      if (mContentHeight != contentH) {
        WXSDKManager.getInstance().fireEvent(mInstanceId, mDomObj.ref, WXEventType.LIST_LOAD_MORE);
        mContentHeight = contentH;
      }
    }
  } catch (Exception e) {
    WXLogUtils.d("[WXScroller-onScroll] " + WXLogUtils.getStackTrace(e));
  }

}
 
Example #26
Source File: WXSDKEngine.java    From weex with Apache License 2.0 5 votes vote down vote up
private static void doInitInternal(final Application application,final InitConfig config){
  WXEnvironment.sApplication = application;
  WXEnvironment.JsFrameworkInit = false;

  WXBridgeManager.getInstance().getJSHandler().post(new Runnable() {
    @Override
    public void run() {
      long start = System.currentTimeMillis();
      WXSDKManager sm = WXSDKManager.getInstance();
      if(config != null ) {
        sm.setIWXHttpAdapter(config.getHttpAdapter());
        sm.setIWXImgLoaderAdapter(config.getImgAdapter());
        sm.setIWXUserTrackAdapter(config.getUtAdapter());
        sm.setIWXDebugAdapter(config.getDebugAdapter());
        if(config.getDebugAdapter()!=null){
          config.getDebugAdapter().initDebug(application);
        }
      }
      WXSoInstallMgrSdk.init(application);
      boolean isSoInitSuccess = WXSoInstallMgrSdk.initSo(V8_SO_NAME, 1, config!=null?config.getUtAdapter():null);
      if (!isSoInitSuccess) {
        return;
      }
      sm.initScriptsFramework(null);

      WXEnvironment.sSDKInitExecuteTime = System.currentTimeMillis() - start;
      WXLogUtils.renderPerformanceLog("SDKInitInvokeTime", WXEnvironment.sSDKInitInvokeTime);
      WXLogUtils.renderPerformanceLog("SDKInitExecuteTime", WXEnvironment.sSDKInitExecuteTime);
    }
  });
  register();
}
 
Example #27
Source File: WXAnimationModule.java    From weex-uikit with MIT License 5 votes vote down vote up
public static void startAnimation(WXSDKInstance mWXSDKInstance, WXComponent component,
                                  @NonNull WXAnimationBean animationBean, @Nullable String callback) {
  if(component == null){
    return;
  }
  if (component.getHostView() == null) {
    AnimationHolder holder = new AnimationHolder(animationBean, callback);
    component.postAnimation(holder);
    return;
  }
  try {
    Animator animator = createAnimator(animationBean, component.getHostView(),mWXSDKInstance.getViewPortWidth());
    if (animator != null) {
      Animator.AnimatorListener animatorCallback = createAnimatorListener(mWXSDKInstance, callback);
      if(Build.VERSION.SDK_INT<Build.VERSION_CODES.JELLY_BEAN_MR2) {
        component.getHostView().setLayerType(View.LAYER_TYPE_HARDWARE, null);
      }
      Interpolator interpolator = createTimeInterpolator(animationBean);
      if (animatorCallback != null) {
        animator.addListener(animatorCallback);
      }
      if (interpolator != null) {
        animator.setInterpolator(interpolator);
      }
      animator.setDuration(animationBean.duration);
      animator.start();
    }
  } catch (RuntimeException e) {
    e.printStackTrace();
    WXLogUtils.e("", e);
  }
}
 
Example #28
Source File: OkHttpWebSocketClient.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 5 votes vote down vote up
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

    if ("onOpen".equals(method.getName())) {
        mWebSocket = mWebSocketClazz.cast(args[0]);
        if (mConnectCallback != null) {
            mConnectCallback.onOpen(null);
        }
    } else if ("onFailure".equals(method.getName())) {
        abort("Websocket exception", (IOException) args[0]);
    } else if ("onMessage".equals(method.getName())) {
        Object bufferedSource = mBufferedSourceClazz.cast(args[0]);
        Method readUtf8 = ReflectionUtil.tryGetMethod(mBufferedSourceClazz, "readUtf8");
        try {
            String message = (String) ReflectionUtil.tryInvokeMethod(bufferedSource, readUtf8);
            mProxy.handleMessage(message);
        } catch (Exception e) {
            WXLogUtils.v(TAG, "Unexpected I/O exception processing message: " + e);
        } finally {
            Method closeMethod = ReflectionUtil.tryGetMethod(mBufferedSourceClazz, "close");
            ReflectionUtil.tryInvokeMethod(bufferedSource, closeMethod);
        }
    } else if ("onPong".equals(method.getName())) {
        //Nope
    } else if ("onClose".equals(method.getName())) {
        if (mHandlerThread != null && mHandlerThread.isAlive()) {
            mHandler.sendEmptyMessage(CLOSE_WEB_SOCKET);
        }
    }
    return null;
}
 
Example #29
Source File: WXBridgeManager.java    From weex-uikit with MIT License 5 votes vote down vote up
public int callAddElement(String instanceId, String ref,String dom,String index, String callback){

    if (WXEnvironment.isApkDebugable()) {
      mLodBuilder.append("[WXBridgeManager] callNative::callAddElement >>>> instanceId:").append(instanceId)
              .append(", ref:").append(ref).append(", dom:").append(dom).append(", callback:").append(callback);
      WXLogUtils.d(mLodBuilder.substring(0));
      mLodBuilder.setLength(0);
    }

    if(mDestroyedInstanceId!=null && mDestroyedInstanceId.contains(instanceId)){
      return IWXBridge.DESTROY_INSTANCE;
    }


    if (WXSDKManager.getInstance().getSDKInstance(instanceId) != null) {
      long start = System.currentTimeMillis();
      JSONObject domObject = JSON.parseObject(dom);

      if (WXSDKManager.getInstance().getSDKInstance(instanceId) != null) {
        WXSDKManager.getInstance().getSDKInstance(instanceId).jsonParseTime(System.currentTimeMillis() - start);
      }
      WXDomModule domModule = getDomModule(instanceId);
      domModule.addElement(ref, domObject, Integer.parseInt(index));
    }

    if (UNDEFINED.equals(callback) || NON_CALLBACK.equals(callback)) {
      return IWXBridge.INSTANCE_RENDERING_ERROR;
    }
    // get next tick
    getNextTick(instanceId, callback);
    return IWXBridge.INSTANCE_RENDERING;

  }
 
Example #30
Source File: BasicListComponent.java    From weex-uikit with MIT License 5 votes vote down vote up
/**
 * Recycle viewHolder and its underlying view. This may because the view is removed or reused.
 * Either case, this method will be called.
 *
 * @param holder The view holder to be recycled.
 */
@Override
public void onViewRecycled(ListBaseViewHolder holder) {
  long begin = System.currentTimeMillis();
  holder.setComponentUsing(false);
  recycleViewList.add(holder);
  if (WXEnvironment.isApkDebugable()) {
    WXLogUtils.d(TAG, "Recycle holder " + (System.currentTimeMillis() - begin) + "  Thread:" + Thread.currentThread().getName());
  }
}