Java Code Examples for com.taobao.weex.utils.WXLogUtils#d()

The following examples show how to use com.taobao.weex.utils.WXLogUtils#d() . 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: WXSlider.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
@WXComponentProp(name = Constants.Name.INDEX)
public void setIndex(int index) {
  if (mViewPager != null && mAdapter != null) {
    if (index >= mAdapter.getRealCount() || index < 0) {
      initIndex = index;
      return;
    }
    mViewPager.setCurrentItem(index);
    if (mIndicator != null && mIndicator.getHostView() != null
            && mIndicator.getHostView().getRealCurrentItem() != index) {
      //OnPageChangeListener not triggered
      WXLogUtils.d("setIndex >>>> correction indicator to " + index);
      mIndicator.getHostView().setRealCurrentItem(index);
      mIndicator.getHostView().invalidate();

      if (mPageChangeListener != null && mAdapter != null) {
        mPageChangeListener.onPageSelected(mAdapter.getFirst() + index);
      }
    }
  }
}
 
Example 2
Source File: WXCirclePageAdapter.java    From weex with Apache License 2.0 6 votes vote down vote up
@Override
public Object instantiateItem(ViewGroup container, int position) {
  View pageView = null;
  try {
    pageView = views.get(position % getRealCount());
    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: " + WXLogUtils.getStackTrace(e));
  }
  return pageView;
}
 
Example 3
Source File: WXListComponent.java    From weex with Apache License 2.0 6 votes vote down vote up
@Override
    public void onLoadMore(int offScreenY) {
      try {
        String offset = mDomObj.attr.getLoadMoreOffset();

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

        if (offScreenY < Integer.parseInt(offset)) {
          String loadMoreRetry = mDomObj.attr.getLoadMoreRetry();

//          if (mListCellCount != mChildren.size()
//              || mLoadMoreRetry == null || !mLoadMoreRetry.equals(loadMoreRetry)) {
//            WXSDKManager.getInstance().fireEvent(mInstanceId, mDomObj.ref, WXEventType.LIST_LOAD_MORE);
            mListCellCount = mChildren.size();
//            mLoadMoreRetry = loadMoreRetry;
//          }
        }
      } catch (Exception e) {
        WXLogUtils.d(TAG, "onLoadMore :" + WXLogUtils.getStackTrace(e));
      }
    }
 
Example 4
Source File: SimpleComponentHolder.java    From ucar-weex-core with Apache License 2.0 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 5
Source File: WXBridgeManager.java    From weex-uikit with MIT License 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 6
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 7
Source File: WXComponent.java    From weex-uikit with MIT License 6 votes vote down vote up
private void setFixedHostLayoutParams(T host, int width, int height, int left, int right, int top, int bottom){
  if (host.getParent() instanceof ViewGroup) {
    ViewGroup viewGroup = (ViewGroup) host.getParent();
    viewGroup.removeView(host);
  }
  FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);

  params.width = width;
  params.height = height;
  params.setMargins(left, top, right, bottom);
  host.setLayoutParams(params);
  mInstance.addFixedView(host);

  if (WXEnvironment.isApkDebugable()) {
    WXLogUtils.d("Weex_Fixed_Style", "WXComponent:setLayout :" + left + " " + top + " " + width + " " + height);
    WXLogUtils.d("Weex_Fixed_Style", "WXComponent:setLayout Left:" + mDomObj.getStyles().getLeft() + " " + (int) mDomObj.getStyles().getTop());
  }
}
 
Example 8
Source File: BasicListComponent.java    From weex-uikit with MIT License 5 votes vote down vote up
@Override
public void notifyAppearStateChange(int firstVisible, int lastVisible, int directionX, int directionY) {
  //notify appear state
  Iterator<AppearanceHelper> it = mAppearComponents.values().iterator();
  String direction = directionY > 0 ? Constants.Value.DIRECTION_UP :
      directionY < 0 ? Constants.Value.DIRECTION_DOWN : null;
  if (getOrientation() == Constants.Orientation.HORIZONTAL && directionX != 0) {
    direction = directionX > 0 ? Constants.Value.DIRECTION_LEFT : Constants.Value.DIRECTION_RIGHT;
  }

  while (it.hasNext()) {
    AppearanceHelper item = it.next();
    WXComponent component = item.getAwareChild();

    if (!item.isWatch()) {
      continue;
    }

    boolean outOfVisibleRange = item.getCellPositionINScollable() < firstVisible || item.getCellPositionINScollable() > lastVisible;

    View view = component.getHostView();
    if (view == null) {
      continue;
    }

    boolean visible = (!outOfVisibleRange) && item.isViewVisible();

    int result = item.setAppearStatus(visible);
    if (WXEnvironment.isApkDebugable()) {
      WXLogUtils.d("appear", "item " + item.getCellPositionINScollable() + " result " + result);
    }
    if (result == AppearanceHelper.RESULT_NO_CHANGE) {
      continue;
    }
    component.notifyAppearStateChange(result == AppearanceHelper.RESULT_APPEAR ? Constants.Event.APPEAR : Constants.Event.DISAPPEAR, direction);
  }
}
 
Example 9
Source File: WXBridgeManager.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
public int callAddEvent(String instanceId, String ref, String event, String callback) {

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

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

    try {
      if (WXSDKManager.getInstance().getSDKInstance(instanceId) != null) {
        WXDomModule domModule = getDomModule(instanceId);
        Action action = Actions.getAddEvent(ref, event);
        domModule.postAction((DOMAction)action, false);
      }
    } catch (Exception e) {
      WXLogUtils.e("[WXBridgeManager] callAddEvent exception: ", e);
      commitJSBridgeAlarmMonitor(instanceId, WXErrorCode.WX_ERR_DOM_ADDEVENT,"[WXBridgeManager] callAddEvent exception " + e.getCause());
    }

    if (UNDEFINED.equals(callback) || NON_CALLBACK.equals(callback)) {
      return IWXBridge.INSTANCE_RENDERING_ERROR;
    }
    // get next tick
    getNextTick(instanceId, callback);
    return IWXBridge.INSTANCE_RENDERING;
  }
 
Example 10
Source File: WXEnvironment.java    From weex-uikit with MIT License 5 votes vote down vote up
/**
 * Tell whether Weex can run on current hardware.
 * @return true if weex can run on current hardware, otherwise false.
 */
public static boolean isHardwareSupport() {
  boolean excludeX86 = "true".equals(options.get(SETTING_EXCLUDE_X86SUPPORT));
  boolean isX86AndExcluded = WXSoInstallMgrSdk.isX86() && excludeX86;
  boolean isCPUSupport = WXSoInstallMgrSdk.isCPUSupport() && !isX86AndExcluded;
  if (WXEnvironment.isApkDebugable()) {
    WXLogUtils.d("WXEnvironment.sSupport:" + isCPUSupport
                 + "isX86AndExclueded: "+ isX86AndExcluded
                 + " !WXUtils.isTabletDevice():" + !WXUtils.isTabletDevice());
  }
  return isCPUSupport && !WXUtils.isTabletDevice();
}
 
Example 11
Source File: WXBridgeManager.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
public int callCreateFinish(String instanceId, String callback) {
  if (WXEnvironment.isApkDebugable()) {
    mLodBuilder.append("[WXBridgeManager] callCreateFinish >>>> instanceId:").append(instanceId)
            .append(", callback:").append(callback);
    WXLogUtils.d(mLodBuilder.substring(0));
    mLodBuilder.setLength(0);
  }

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

  try {
    if (WXSDKManager.getInstance().getSDKInstance(instanceId) != null) {
      WXDomModule domModule = getDomModule(instanceId);
      Action action = Actions.getCreateFinish();
      domModule.postAction((DOMAction)action, false);
    }
  } catch (Exception e) {
    WXLogUtils.e("[WXBridgeManager] callCreateFinish exception: ", e);
    commitJSBridgeAlarmMonitor(instanceId, WXErrorCode.WX_ERROR_DOM_CREATEFINISH,"[WXBridgeManager] callCreateFinish exception " + e.getCause());
  }

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

}
 
Example 12
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());
  }
}
 
Example 13
Source File: BasicListComponent.java    From ucar-weex-core with Apache License 2.0 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);
  if(holder.canRecycled()) {
    recycleViewList.add(holder);

    // recycleViewList allowed max size
    int threshold = visibleCellCount >= 6 ? (visibleCellCount * 6) : (6*6);

    /**
     * Recycle cache{@link recycleViewList} when recycleViewList.size() > list max child count or threshold
     */
    if (recycleViewList.size() > getChildCount() + 1 || recycleViewList.size() >= threshold) {
      WXLogUtils.d(TAG, "Recycle holder list recycled : cache size is " + recycleViewList.size() +
              ", visibleCellCount is " + visibleCellCount + ", threshold is " + threshold +
              ", child count is " + getChildCount());
      recycleViewHolderList();
    }
  } else {
    WXLogUtils.w(TAG, "this holder can not be allowed to  recycled" );
  }
  if (WXEnvironment.isApkDebugable()) {
    WXLogUtils.d(TAG, "Recycle holder " + (System.currentTimeMillis() - begin) + "  Thread:" + Thread.currentThread().getName());
  }
}
 
Example 14
Source File: WXBridgeManager.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
private void invokeDestroyInstance(String instanceId) {
  try {
    if (WXEnvironment.isApkDebugable()) {
      WXLogUtils.d("destroyInstance >>>> instanceId:" + instanceId);
    }
    WXJSObject instanceIdObj = new WXJSObject(WXJSObject.String,
                                              instanceId);
    WXJSObject[] args = {instanceIdObj};
    invokeExecJS(instanceId, null, METHOD_DESTROY_INSTANCE, args);
  } catch (Throwable e) {
    String err = "[WXBridgeManager] invokeDestroyInstance " + e.getCause();
    commitJSBridgeAlarmMonitor(instanceId, WXErrorCode.WX_ERR_INVOKE_NATIVE,err);
    WXLogUtils.e(err);
  }
}
 
Example 15
Source File: DefaultWXStorage.java    From weex-uikit with MIT License 5 votes vote down vote up
private String performGetItem(String key) {
    SQLiteDatabase database = mDatabaseSupplier.getDatabase();
    if (database == null) {
        return null;
    }

    Cursor c = database.query(WXSQLiteOpenHelper.TABLE_STORAGE,
            new String[]{WXSQLiteOpenHelper.COLUMN_VALUE},
            WXSQLiteOpenHelper.COLUMN_KEY + "=?",
            new String[]{key},
            null, null, null);
    try {
        if (c.moveToNext()) {
            ContentValues values = new ContentValues();
            //update timestamp
            values.put(WXSQLiteOpenHelper.COLUMN_TIMESTAMP, WXSQLiteOpenHelper.sDateFormatter.format(new Date()));
            int updateResult = mDatabaseSupplier.getDatabase().update(WXSQLiteOpenHelper.TABLE_STORAGE, values, WXSQLiteOpenHelper.COLUMN_KEY + "= ?", new String[]{key});

            WXLogUtils.d(WXSQLiteOpenHelper.TAG_STORAGE, "update timestamp " + (updateResult == 1 ? "success" : "failed") + " for operation [getItem(key = " + key + ")]");
            return c.getString(c.getColumnIndex(WXSQLiteOpenHelper.COLUMN_VALUE));
        } else {
            return null;
        }
    } catch (Exception e) {
        WXLogUtils.e(WXSQLiteOpenHelper.TAG_STORAGE, "DefaultWXStorage occurred an exception when execute getItem:" + e.getMessage());
        return null;
    } finally {
        c.close();
    }
}
 
Example 16
Source File: WXComponent.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
private void setFixedHostLayoutParams(T host, int width, int height, int left, int right, int top, int bottom){
  FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);

  params.width = width;
  params.height = height;
  params.setMargins(left, top, right, bottom);
  host.setLayoutParams(params);
  mInstance.moveFixedView(host);

  if (WXEnvironment.isApkDebugable()) {
    WXLogUtils.d("Weex_Fixed_Style", "WXComponent:setLayout :" + left + " " + top + " " + width + " " + height);
    WXLogUtils.d("Weex_Fixed_Style", "WXComponent:setLayout Left:" + mDomObj.getStyles().getLeft() + " " + (int) mDomObj.getStyles().getTop());
  }
}
 
Example 17
Source File: BasicListComponent.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
@WXComponentProp(name = Constants.Name.DRAGGABLE)
public void setDraggable(boolean isDraggable) {
  if (mDragHelper != null) {
    mDragHelper.setDraggable(isDraggable);
  }
  if (WXEnvironment.isApkDebugable()) {
    WXLogUtils.d("set draggable : " + isDraggable);
  }
}
 
Example 18
Source File: WXEnvironment.java    From weex-uikit with MIT License 5 votes vote down vote up
@Deprecated
/**
 * Use {@link #isHardwareSupport()} if you want to see whether current hardware support Weex.
 */
public static boolean isSupport() {
  boolean isInitialized = WXSDKEngine.isInitialized();
  if(WXEnvironment.isApkDebugable()){
    WXLogUtils.d("WXSDKEngine.isInitialized():" + isInitialized);
  }
  return isHardwareSupport() && isInitialized;
}
 
Example 19
Source File: AnalyzerService.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 4 votes vote down vote up
@Override
public void onOpen(String response) {
    WXLogUtils.d(Constants.TAG,"onOpen:"+response);
}
 
Example 20
Source File: WXSDKInstance.java    From weex-uikit with MIT License 4 votes vote down vote up
@Override
public void onHttpFinish(WXResponse response) {

  mWXPerformance.networkTime = System.currentTimeMillis() - startRequestTime;
  if(response.extendParams!=null){
    Object actualNetworkTime=response.extendParams.get("actualNetworkTime");
    mWXPerformance.actualNetworkTime=actualNetworkTime instanceof Long?(long)actualNetworkTime:0;
    WXLogUtils.renderPerformanceLog("actualNetworkTime", mWXPerformance.actualNetworkTime);

    Object pureNetworkTime=response.extendParams.get("pureNetworkTime");
    mWXPerformance.pureNetworkTime=pureNetworkTime instanceof Long?(long)pureNetworkTime:0;
    WXLogUtils.renderPerformanceLog("pureNetworkTime", mWXPerformance.pureNetworkTime);

    Object connectionType=response.extendParams.get("connectionType");
    mWXPerformance.connectionType=connectionType instanceof String?(String)connectionType:"";

    Object packageSpendTime=response.extendParams.get("packageSpendTime");
    mWXPerformance.packageSpendTime=packageSpendTime instanceof Long ?(long)packageSpendTime:0;

    Object syncTaskTime=response.extendParams.get("syncTaskTime");
    mWXPerformance.syncTaskTime=syncTaskTime instanceof Long ?(long)syncTaskTime:0;

    Object requestType=response.extendParams.get("requestType");
    mWXPerformance.requestType=requestType instanceof String?(String)requestType:"";

    if("network".equals(requestType) && mUserTrackAdapter!=null){
      WXPerformance performance=new WXPerformance();
      if(!TextUtils.isEmpty(mBundleUrl)){
        try {
          performance.args= Uri.parse(mBundleUrl).buildUpon().clearQuery().toString();
        } catch (Exception e) {
          performance.args=pageName;
        }
      }
      if(!"200".equals(response.statusCode)){
        performance.errCode=WXErrorCode.WX_ERR_JSBUNDLE_DOWNLOAD.getErrorCode();
        performance.appendErrMsg(response.errorCode);
        performance.appendErrMsg("|");
        performance.appendErrMsg(response.errorMsg);
      }else if("200".equals(response.statusCode) && (response.originalData==null || response.originalData.length<=0)){
        performance.errCode=WXErrorCode.WX_ERR_JSBUNDLE_DOWNLOAD.getErrorCode();
        performance.appendErrMsg(response.statusCode);
        performance.appendErrMsg("|template is null!");
      }else {
        performance.errCode=WXErrorCode.WX_SUCCESS.getErrorCode();
      }
      mUserTrackAdapter.commit(getContext(),null,IWXUserTrackAdapter.JS_DOWNLOAD,performance,null);
    }
  }
  WXLogUtils.renderPerformanceLog("networkTime", mWXPerformance.networkTime);
  if (response!=null && response.originalData!=null && TextUtils.equals("200", response.statusCode)) {
    String template = new String(response.originalData);
    render(pageName, template, options, jsonInitData, flag);
  } else if (TextUtils.equals(WXRenderErrorCode.WX_USER_INTERCEPT_ERROR, response.statusCode)) {
    WXLogUtils.d("user intercept");
    onRenderError(WXRenderErrorCode.WX_USER_INTERCEPT_ERROR,response.errorMsg);
  } else {
    onRenderError(WXRenderErrorCode.WX_NETWORK_ERROR, response.errorMsg);
  }
}