当前位置: 首页>>代码示例>>Java>>正文


Java WXSDKInstance类代码示例

本文整理汇总了Java中com.taobao.weex.WXSDKInstance的典型用法代码示例。如果您正苦于以下问题:Java WXSDKInstance类的具体用法?Java WXSDKInstance怎么用?Java WXSDKInstance使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


WXSDKInstance类属于com.taobao.weex包,在下文中一共展示了WXSDKInstance类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: callRemoveEvent

import com.taobao.weex.WXSDKInstance; //导入依赖的package包/类
/**
 * JavaScript uses this methods to call Android code
 * @param instanceId
 * @param ref
 * @param event
 * @param callback
 * @return int
 */
public int callRemoveEvent(String instanceId, String ref, String event, 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().callRemoveEvent(instanceId, ref, event, callback);
  } catch (Throwable e) {
    //catch everything during call native.
    if(WXEnvironment.isApkDebugable()){
      WXLogUtils.e(TAG,"callRemoveEvent throw exception:" + e.getMessage());
    }
  }
  if(instance != null) {
    instance.callNativeTime(System.currentTimeMillis() - start);
  }
  return errorCode;
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:29,代码来源:WXBridge.java

示例2: onViewCreated

import com.taobao.weex.WXSDKInstance; //导入依赖的package包/类
@Override
    public void onViewCreated(WXSDKInstance wxsdkInstance, View view) {
        super.onViewCreated(wxsdkInstance, view);
        WXComponent comp = mInstance.getRootComponent();
        if (comp != null) {
            WXEvent events = comp.getDomObject().getEvents();
            boolean hasReady = events.contains(UConstants.Event.READY);
            if (hasReady) {
                Map<String, Object> data = new HashMap<>();
                data.put("param", wxInfo.getParam());
                WXBridgeManager.getInstance().fireEvent(mInstance.getInstanceId(), comp.getRef(), UConstants.Event.READY, data, null);
            }
        }
//        if (!isHasNavBar) {
//            setTranslateAnimation(getContainer());
//        }
    }
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:18,代码来源:UWXFrameBaseActivity.java

示例3: callCreateBody

import com.taobao.weex.WXSDKInstance; //导入依赖的package包/类
public int callCreateBody(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().callCreateBody(instanceId, tasks, callback);
  }catch (Throwable e){
    //catch everything during call native.
    if(WXEnvironment.isApkDebugable()){
      WXLogUtils.e(TAG,"callCreateBody throw exception:"+e.getMessage());
    }
  }
  if(instance != null) {
    instance.callNativeTime(System.currentTimeMillis() - start);
  }
  return errorCode;
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:21,代码来源:WXBridge.java

示例4: reportJSException

import com.taobao.weex.WXSDKInstance; //导入依赖的package包/类
/**
 * 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());
      }
    }
  }
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:28,代码来源:WXBridgeManager.java

示例5: onException

import com.taobao.weex.WXSDKInstance; //导入依赖的package包/类
@Override
public void onException(WXSDKInstance instance, String errCode,
                        String msg) {
  if(mWxAnalyzerDelegate != null){
    mWxAnalyzerDelegate.onException(instance,errCode,msg);
  }
  mProgressBar.setVisibility(View.GONE);
  if (!TextUtils.isEmpty(errCode) && errCode.contains("|")) {
    String[] errCodeList = errCode.split("\\|");
    String code = errCodeList[1];
    String codeType = errCode.substring(0, errCode.indexOf("|"));

    if (TextUtils.equals("1", codeType)) {
      String errMsg = "codeType:" + codeType + "\n" + " errCode:" + code + "\n" + " ErrorInfo:" + msg;
      degradeAlert(errMsg);
      return;
    } else {
      Toast.makeText(getApplicationContext(), "errCode:" + errCode + " Render ERROR:" + msg, Toast.LENGTH_SHORT).show();
    }
  }
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:22,代码来源:WXPageActivity.java

示例6: setUp

import com.taobao.weex.WXSDKInstance; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    super.setUp();

    Map<String, String> map = new HashMap<>();
    map.put(WXConfig.scale, Float.toString(TEST_DENSITY));
    PowerMockito.mockStatic(WXEnvironment.class);
    PowerMockito.when(WXEnvironment.class, "getConfig").thenReturn(map);

    PowerMockito.mockStatic(WXViewUtils.class);
    PowerMockito.when(WXViewUtils.class, "getScreenWidth").thenReturn(TEST_SCREEN_WIDTH);

    PowerMockito.mockStatic(WXSDKInstance.class);
    PowerMockito.when(WXSDKInstance.class, "getViewPortWidth").thenReturn(TEST_VIEW_PORT);

    PowerMockito.mockStatic(TextUtils.class);
    PowerMockito.when(TextUtils.isEmpty(any(CharSequence.class))).thenAnswer(new Answer<Boolean>() {
        @Override
        public Boolean answer(InvocationOnMock invocation) throws Throwable {
            CharSequence a = (CharSequence) invocation.getArguments()[0];
            return !(a != null && a.length() > 0);
        }
    });
    // also look at @PrepareForTest if add mock of new class
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:26,代码来源:WXUtilsTest.java

示例7: callRefreshFinish

import com.taobao.weex.WXSDKInstance; //导入依赖的package包/类
/**
 * JavaScript uses this methods to call Android code
 *
 * @param instanceId
 * @param tasks
 * @param callback
 */

public int callRefreshFinish(String instanceId, byte [] 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().callRefreshFinish(instanceId, callback);
  } catch (Throwable e) {
    //catch everything during call native.
    if(WXEnvironment.isApkDebugable()){
      WXLogUtils.e(TAG,"callCreateFinish throw exception:" + e.getMessage());
    }
  }
  if(instance != null) {
    instance.callNativeTime(System.currentTimeMillis() - start);
  }
  return errorCode;
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:29,代码来源:WXBridge.java

示例8: rewrite

import com.taobao.weex.WXSDKInstance; //导入依赖的package包/类
@NonNull
@Override
public Uri rewrite(WXSDKInstance instance, String type, Uri uri) {
  if (TextUtils.isEmpty(instance.getBundleUrl())) {
    return uri;
  }

  Uri base = Uri.parse(instance.getBundleUrl());
  Uri.Builder resultBuilder = uri.buildUpon();
  
 if (uri.isRelative()) {
    //When uri is empty, means use the base url instead. Web broswer behave this way.
    if(uri.getEncodedPath().length() == 0){
      return base;
    } else {
      resultBuilder = buildRelativeURI(resultBuilder, base, uri);
      return resultBuilder.build();
    }
  }
  return uri;
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:22,代码来源:DefaultUriAdapter.java

示例9: loadConstructor

import com.taobao.weex.WXSDKInstance; //导入依赖的package包/类
private void loadConstructor(){
  Class<? extends WXComponent> c = mCompClz;
  Constructor<? extends WXComponent> constructor;
  try {
    constructor = c.getConstructor(WXSDKInstance.class, WXDomObject.class, WXVContainer.class, boolean.class);
  } catch (NoSuchMethodException e) {
    WXLogUtils.d("ClazzComponentCreator","Use deprecated component constructor");
    try {
      //compatible deprecated constructor
      constructor = c.getConstructor(WXSDKInstance.class, WXDomObject.class, WXVContainer.class,String.class, boolean.class);
    } catch (NoSuchMethodException e1) {
      throw new WXRuntimeException("Can't find constructor of component.");
    }
  }
  mConstructor = constructor;
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:17,代码来源:SimpleComponentHolder.java

示例10: onViewCreated

import com.taobao.weex.WXSDKInstance; //导入依赖的package包/类
@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 (mWAView != null && mContainer != null && mWAView.getParent() == mContainer) {
    mContainer.removeView(mWAView);
  }

  mWAView = view;
  mContainer.addView(view);
  mContainer.requestLayout();
  Log.d("WARenderListener", "renderSuccess");
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:20,代码来源:WXPageActivity.java

示例11: callNative

import com.taobao.weex.WXSDKInstance; //导入依赖的package包/类
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;
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:27,代码来源:WXBridge.java

示例12: WXComponent

import com.taobao.weex.WXSDKInstance; //导入依赖的package包/类
public WXComponent(WXSDKInstance instance, WXDomObject dom, WXVContainer parent, int type) {
  mInstance = instance;
  mContext = mInstance.getContext();
  mParent = parent;
  mType = type;
  mDomObj = dom.clone();
  mCurrentRef = mDomObj.getRef();
  mGestureType = new HashSet<>();
  ++mComponentNum;
  onCreate();
  ComponentObserver observer;
  if ((observer = getInstance().getComponentObserver()) != null) {
    observer.onCreate(this);
  }
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:16,代码来源:WXComponent.java

示例13: setUp

import com.taobao.weex.WXSDKInstance; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    WXSDKInstance instance = Mockito.mock(WXSDKInstance.class);
    Mockito.when(instance.getContext()).thenReturn(RuntimeEnvironment.application);

    WXDomObject divDom = new WXDomObject();
    WXDomObject spy = Mockito.spy(divDom);
    Mockito.when(spy.getPadding()).thenReturn(new Spacing());
    Mockito.when(spy.getEvents()).thenReturn(new WXEvent());
    Mockito.when(spy.clone()).thenReturn(divDom);
    TestDomObject.setRef(divDom,"1");
    mWXDiv = new WXDiv(instance, divDom, null);
    mWXDiv.initView();
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:15,代码来源:WXDivTest.java

示例14: onViewCreated

import com.taobao.weex.WXSDKInstance; //导入依赖的package包/类
@Override
public void onViewCreated(WXSDKInstance wxsdkInstance, View view) {
  if (mContainer != null) {
    mContainer.removeAllViews();
    mContainer.addView(view);
  }
}
 
开发者ID:wangwei123,项目名称:my-weex,代码行数:8,代码来源:AbsWeexActivity.java

示例15: addEvent

import com.taobao.weex.WXSDKInstance; //导入依赖的package包/类
/**
 * Create a command object for adding a default event listener to the corresponding {@link
 * WXDomObject} and put the command object in the queue.
 * When the event is triggered, the eventListener will call {@link WXSDKManager#fireEvent(String, String, String)}
 * , and the JS will handle all the operations from there.
 *
 * @param ref Reference of the dom.
 * @param type the type of the event, this may be a plain event defined in
 * {@link com.taobao.weex.common.Constants.Event} or a gesture defined in {@link com.taobao
 * .weex.ui.view.gesture.WXGestureType}
 */
void addEvent(final String ref, final String type) {
  if (mDestroy) {
    return;
  }
  WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(mInstanceId);
  final WXDomObject domObject = mRegistry.get(ref);
  if (domObject == null) {
    if (instance != null) {
      instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_ADDEVENT);
    }
    return;
  }
  domObject.addEvent(type);
  mNormalTasks.add(new IWXRenderTask() {

    @Override
    public void execute() {
      WXComponent comp = mWXRenderManager.getWXComponent(mInstanceId,ref);
      if(comp != null){
        //sync dom change to component
        comp.updateDom(domObject);
        mWXRenderManager.addEvent(mInstanceId, ref, type);
      }
    }

    @Override
    public String toString() {
      return "Add event";
    }
  });

  mDirty = true;
  if (instance != null) {
    instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS);
  }
}
 
开发者ID:erguotou520,项目名称:weex-uikit,代码行数:48,代码来源:WXDomStatement.java


注:本文中的com.taobao.weex.WXSDKInstance类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。