com.taobao.weex.common.WXRenderStrategy Java Examples

The following examples show how to use com.taobao.weex.common.WXRenderStrategy. 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: SliceTestActivity.java    From incubator-weex-playground with Apache License 2.0 6 votes vote down vote up
public void render(String initData, int position) {
//
      if (true) {

        mInstance.render(
            "testPage",
            loadAssets(),
            null,
            initData,
            WXRenderStrategy.DATA_RENDER
        );
      } else {
//
        mInstance.render(
            "testPage",
            loadBytes(),
            null,
            initData
        );
      }
      mTextView.setText(String.valueOf(position));
      mRendered = true;
    }
 
Example #2
Source File: WXRenderStatement.java    From weex-uikit with MIT License 6 votes vote down vote up
/**
 * create RootView ,every weex Instance View has a rootView;
 * @see com.taobao.weex.dom.WXDomStatement#createBody(JSONObject)
 */
void createBody(WXComponent component) {
  long start = System.currentTimeMillis();
  component.createView();
  if (WXEnvironment.isApkDebugable()) {
    WXLogUtils.renderPerformanceLog("createView", (System.currentTimeMillis() - start));
  }
  start = System.currentTimeMillis();
  component.applyLayoutAndEvent(component);
  component.bindData(component);

  if (WXEnvironment.isApkDebugable()) {
    WXLogUtils.renderPerformanceLog("bind", (System.currentTimeMillis() - start));
  }

  if (component instanceof WXScroller) {
    WXScroller scroller = (WXScroller) component;
    if (scroller.getInnerView() instanceof ScrollView) {
      mWXSDKInstance.setRootScrollView((ScrollView) scroller.getInnerView());
    }
  }
  mWXSDKInstance.onRootCreated(component);
  if (mWXSDKInstance.getRenderStrategy() != WXRenderStrategy.APPEND_ONCE) {
    mWXSDKInstance.onCreateFinish();
  }
}
 
Example #3
Source File: WXRenderStatement.java    From weex with Apache License 2.0 6 votes vote down vote up
/**
 * create RootView ,every weex Instance View has a rootView;
 * @see com.taobao.weex.dom.WXDomStatement#createBody(JSONObject)
 */
void createBody(WXComponent component) {
  long start = System.currentTimeMillis();
  component.createView(mGodComponent, -1);
  if (WXEnvironment.isApkDebugable()) {
    WXLogUtils.renderPerformanceLog("createView", (System.currentTimeMillis() - start));
  }
  start = System.currentTimeMillis();
  component.applyLayoutAndEvent(component);
  component.bindData(component);

  if (WXEnvironment.isApkDebugable()) {
    WXLogUtils.renderPerformanceLog("bind", (System.currentTimeMillis() - start));
  }

  if (component instanceof WXScroller) {
    WXScroller scroller = (WXScroller) component;
    if (scroller.getView() instanceof ScrollView) {
      mWXSDKInstance.setRootScrollView((ScrollView) scroller.getView());
    }
  }
  mWXSDKInstance.setRootView(mGodComponent.getRealView());
  if (mWXSDKInstance.getRenderStrategy() != WXRenderStrategy.APPEND_ONCE) {
    mWXSDKInstance.onViewCreated(mGodComponent);
  }
}
 
Example #4
Source File: AbstractWeexActivity.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 5 votes vote down vote up
protected void renderPage(String template,String source,String jsonInitData){
  AssertUtil.throwIfNull(mContainer,new RuntimeException("Can't render page, container is null"));
  Map<String, Object> options = new HashMap<>();
  options.put(WXSDKInstance.BUNDLE_URL, source);
  mInstance.render(
    source,
    template,
    options,
    jsonInitData,
    ScreenUtil.getDisplayWidth(this),
    ScreenUtil.getDisplayHeight(this),
    WXRenderStrategy.APPEND_ASYNC);
}
 
Example #5
Source File: DefaultUriAdapterTest.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
@Test
public void testRewrite() throws Exception {

  final String host = "http://127.0.0.1";
  final String base = host + "/test/123/";
  final String bundleWithSlash = base + "?arg=value";
  final String bundle = base + "bundle.js?arg=value";


  instance.renderByUrl("", bundle, null, null, 0, 0, WXRenderStrategy.APPEND_ONCE);
  testRelative(host, base, bundle);
  instance.renderByUrl("", bundleWithSlash, null, null, 0, 0, WXRenderStrategy.APPEND_ONCE);
  testRelative(host, base, bundleWithSlash);
}
 
Example #6
Source File: AbsWeexActivity.java    From yanxuan-weex-demo with MIT License 5 votes vote down vote up
protected void renderPageByURL(String url, String jsonInitData) {
  CommonUtils.throwIfNull(mContainer, new RuntimeException("Can't render page, container is null"));
  Map<String, Object> options = new HashMap<>();
  options.put(WXSDKInstance.BUNDLE_URL, url);
  mInstance.renderByUrl(
      getPageName(),
      url,
      options,
      jsonInitData,
      CommonUtils.getDisplayWidth(this),
      CommonUtils.getDisplayHeight(this),
      WXRenderStrategy.APPEND_ASYNC);
}
 
Example #7
Source File: AbstractWeexActivity.java    From incubator-weex-playground with Apache License 2.0 5 votes vote down vote up
protected void renderPage(String template,String source,String jsonInitData){
  AssertUtil.throwIfNull(mContainer,new RuntimeException("Can't render page, container is null"));
  Map<String, Object> options = new HashMap<>();
  options.put(WXSDKInstance.BUNDLE_URL, source);
  // Set options.bundleDigest
  try {
    String banner = WXUtils.getBundleBanner(template);
    JSONObject jsonObj = JSONObject.parseObject(banner);
    String digest = null;
    if (jsonObj != null) {
      digest = jsonObj.getString(Constants.CodeCache.BANNER_DIGEST);
    }
    if (digest != null) {
      options.put(Constants.CodeCache.DIGEST, digest);
    }
  } catch (Throwable t) {}
  //Set options.codeCachePath
  String path = WXEnvironment.getFilesDir(getApplicationContext());
  path += File.separator;
  path += Constants.CodeCache.SAVE_PATH;
  path += File.separator;
  options.put(Constants.CodeCache.PATH, path);

  mInstance.setTrackComponent(true);
  mInstance.render(
    getPageName(),
    template,
    options,
    jsonInitData,
    WXRenderStrategy.APPEND_ASYNC);
}
 
Example #8
Source File: WXEmbed.java    From weex-uikit with MIT License 5 votes vote down vote up
private WXSDKInstance createInstance() {
  WXSDKInstance sdkInstance = getInstance().createNestedInstance(this);
  getInstance().addOnInstanceVisibleListener(this);
  sdkInstance.registerRenderListener(mListener);

  String url=src;
  if(mListener != null && mListener.mEventListener != null){
    url=mListener.mEventListener.transformUrl(src);
    if(!mListener.mEventListener.onPreCreate(this,src)){
      //cancel render
      return null;
    }
  }

  if(TextUtils.isEmpty(url)){
    mListener.mEventListener.onException(this,WXRenderErrorCode.WX_USER_INTERCEPT_ERROR,"degradeToH5");
    return sdkInstance;
  }

  ViewGroup.LayoutParams layoutParams = getHostView().getLayoutParams();
  sdkInstance.renderByUrl(WXPerformance.DEFAULT,
                          url,
                          null, null, layoutParams.width,
                          layoutParams.height,
                          WXRenderStrategy.APPEND_ASYNC);
  return sdkInstance;
}
 
Example #9
Source File: WXSDKInstance.java    From weex-uikit with MIT License 5 votes vote down vote up
private void renderInternal(String pageName,
                            String template,
                            Map<String, Object> options,
                            String jsonInitData,
                            WXRenderStrategy flag){
  if (mRendered || TextUtils.isEmpty(template)) {
    return;
  }

  ensureRenderArchor();

  Map<String, Object> renderOptions = options;
  if (renderOptions == null) {
    renderOptions = new HashMap<>();
  }

  if (WXEnvironment.sDynamicMode && !TextUtils.isEmpty(WXEnvironment.sDynamicUrl) && renderOptions.get("dynamicMode") == null) {
    renderOptions.put("dynamicMode", "true");
    renderByUrl(pageName, WXEnvironment.sDynamicUrl, renderOptions, jsonInitData, flag);
    return;
  }

  mWXPerformance.pageName = pageName;
  mWXPerformance.JSTemplateSize = template.length() / 1024;

  mRenderStartTime = System.currentTimeMillis();
  mRenderStrategy = flag;

  WXSDKManager.getInstance().createInstance(this, template, renderOptions, jsonInitData);
  mRendered = true;

  if (TextUtils.isEmpty(mBundleUrl)) {
    mBundleUrl = pageName;
  }
}
 
Example #10
Source File: WXSDKInstance.java    From weex-uikit with MIT License 5 votes vote down vote up
private void renderByUrlInternal(String pageName,
                                 final String url,
                                 Map<String, Object> options,
                                 final String jsonInitData,
                                 final WXRenderStrategy flag) {

  ensureRenderArchor();
  pageName = wrapPageName(pageName, url);
  mBundleUrl = url;

  Map<String, Object> renderOptions = options;
  if (renderOptions == null) {
    renderOptions = new HashMap<>();
  }
  if (!renderOptions.containsKey(BUNDLE_URL)) {
    renderOptions.put(BUNDLE_URL, url);
  }

  Uri uri = Uri.parse(url);
  if (uri != null && TextUtils.equals(uri.getScheme(), "file")) {
    render(pageName, WXFileUtils.loadAsset(assembleFilePath(uri), mContext), renderOptions, jsonInitData, flag);
    return;
  }

  IWXHttpAdapter adapter = WXSDKManager.getInstance().getIWXHttpAdapter();

  WXRequest wxRequest = new WXRequest();
  wxRequest.url = rewriteUri(Uri.parse(url),URIAdapter.BUNDLE).toString();
  if (wxRequest.paramMap == null) {
    wxRequest.paramMap = new HashMap<String, String>();
  }
  wxRequest.paramMap.put(KEY_USER_AGENT, WXHttpUtil.assembleUserAgent(mContext,WXEnvironment.getConfig()));
  adapter.sendRequest(wxRequest, new WXHttpListener(pageName, renderOptions, jsonInitData, flag, System.currentTimeMillis()));
}
 
Example #11
Source File: WXSDKInstance.java    From weex-uikit with MIT License 5 votes vote down vote up
private WXHttpListener(String pageName, Map<String, Object> options, String jsonInitData, WXRenderStrategy flag, long startRequestTime) {
  this.pageName = pageName;
  this.options = options;
  this.jsonInitData = jsonInitData;
  this.flag = flag;
  this.startRequestTime = startRequestTime;
}
 
Example #12
Source File: DefaultUriAdapterTest.java    From weex-uikit with MIT License 5 votes vote down vote up
@Test
public void testRewrite() throws Exception {

  final String host = "http://127.0.0.1";
  final String base = host + "/test/123/";
  final String bundleWithSlash = base + "?arg=value";
  final String bundle = base + "bundle.js?arg=value";


  instance.renderByUrl("", bundle, null, null, 0, 0, WXRenderStrategy.APPEND_ONCE);
  testRelative(host, base);
  instance.renderByUrl("", bundleWithSlash, null, null, 0, 0, WXRenderStrategy.APPEND_ONCE);
  testRelative(host, base);
}
 
Example #13
Source File: WXRenderStatement.java    From weex-uikit with MIT License 5 votes vote down vote up
/**
 * weex render finish
 * @see  com.taobao.weex.dom.WXDomStatement#createFinish()
 */
void createFinish(int width, int height) {
  if (mWXSDKInstance.getRenderStrategy() == WXRenderStrategy.APPEND_ONCE) {
    mWXSDKInstance.onCreateFinish();
  }
  mWXSDKInstance.onRenderSuccess(width, height);
}
 
Example #14
Source File: AbstractWeexActivity.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 5 votes vote down vote up
protected void renderPageByURL(String url,String jsonInitData){
  AssertUtil.throwIfNull(mContainer,new RuntimeException("Can't render page, container is null"));
  Map<String, Object> options = new HashMap<>();
  options.put(WXSDKInstance.BUNDLE_URL, url);
  mInstance.renderByUrl(
    getPageName(),
    url,
    options,
    jsonInitData,
    ScreenUtil.getDisplayWidth(this),
    ScreenUtil.getDisplayHeight(this),
    WXRenderStrategy.APPEND_ASYNC);
}
 
Example #15
Source File: AbsWeexActivity.java    From WeexOne with MIT License 5 votes vote down vote up
protected void renderPageByURL(String url, String jsonInitData) {
  AssertUtil.throwIfNull(mContainer, new RuntimeException("Can't render page, container is null"));
  Map<String, Object> options = new HashMap<>();
  options.put(WXSDKInstance.BUNDLE_URL, url);
  mInstance.renderByUrl(
      getPageName(),
      url,
      options,
      jsonInitData,
      ScreenUtil.getDisplayWidth(this),
      ScreenUtil.getDisplayHeight(this),
      WXRenderStrategy.APPEND_ASYNC);
}
 
Example #16
Source File: AbstractWeexActivity.java    From weex with Apache License 2.0 5 votes vote down vote up
protected void renderPage(String template,String source,String jsonInitData){
  AssertUtil.throwIfNull(mContainer,new RuntimeException("Can't render page, container is null"));
  Map<String, Object> options = new HashMap<>();
  options.put(WXSDKInstance.BUNDLE_URL, source);
  mInstance.render(
    getPageName(),
    template,
    options,
    jsonInitData,
    ScreenUtil.getDisplayWidth(this),
    ScreenUtil.getDisplayHeight(this),
    WXRenderStrategy.APPEND_ASYNC);
}
 
Example #17
Source File: AbstractWeexActivity.java    From weex with Apache License 2.0 5 votes vote down vote up
protected void renderPageByURL(String url,String jsonInitData){
  AssertUtil.throwIfNull(mContainer,new RuntimeException("Can't render page, container is null"));
  Map<String, Object> options = new HashMap<>();
  options.put(WXSDKInstance.BUNDLE_URL, url);
  mInstance.renderByUrl(
    getPageName(),
    url,
    options,
    jsonInitData,
    ScreenUtil.getDisplayWidth(this),
    ScreenUtil.getDisplayHeight(this),
    WXRenderStrategy.APPEND_ASYNC);
}
 
Example #18
Source File: WXRenderStatement.java    From weex with Apache License 2.0 5 votes vote down vote up
/**
 * weex render finish
 * @see  com.taobao.weex.dom.WXDomStatement#createFinish()
 */
void createFinish(int width, int height) {
  if (mWXSDKInstance.getRenderStrategy() == WXRenderStrategy.APPEND_ONCE) {
    mWXSDKInstance.onViewCreated(mGodComponent);
  }
  mWXSDKInstance.onRenderSuccess(width, height);
}
 
Example #19
Source File: WXSDKInstance.java    From weex with Apache License 2.0 5 votes vote down vote up
/**
 * Render template asynchronously
 *
 * @param pageName, used for performance log.
 * @param template bundle js
 * @param options  os   iphone/android/ipad
 *                 weexversion    Weex version(like 1.0.0)
 *                 appversion     App version(like 1.0.0)
 *                 devid        Device id(like Aqh9z8dRJNBhmS9drLG5BKCmXhecHUXIZoXOctKwFebH)
 *                 sysversion    Device system version(like 5.4.4、7.0.4, should be used with os)
 *                 sysmodel     Device model(like iOS:"MGA82J/A", android:"MI NOTE LTE")
 *                 Time    UNIX timestamp, UTC+08:00
 *                 TTID(Optional)
 *                 MarkertId
 *                 Appname(Optional)  tm,tb,qa
 *                 Bundleurl(Optional)  template url
 * @param jsonInitData Initial data for rendering
 * @param width    Width of weex's root container, the default is match_parent
 * @param height   Height of weex's root container, the default is match_parent
 * @param flag     RenderStrategy {@link WXRenderStrategy}
 */
public void render(String pageName, String template, Map<String, Object> options, String jsonInitData, int width, int height, WXRenderStrategy flag) {
  if (mRendered || TextUtils.isEmpty(template)) {
    return;
  }

  if(options==null){
    options=new HashMap<>();
  }

  if(WXEnvironment.sDynamicMode && !TextUtils.isEmpty(WXEnvironment.sDynamicUrl) && options!=null && options.get("dynamicMode")==null){
    options.put("dynamicMode","true");
    renderByUrl(pageName,WXEnvironment.sDynamicUrl,options,jsonInitData,width,height,flag);
    return;
  }

  mWXPerformance.pageName = pageName;
  mWXPerformance.JSTemplateSize = template.length() / 1024;

  mRenderStartTime = System.currentTimeMillis();
  mRenderStrategy = flag;
  mGodViewWidth = width;
  mGodViewHeight = height;
  mInstanceId = WXSDKManager.getInstance().generateInstanceId();
  WXSDKManager.getInstance().createInstance(this, template, options, jsonInitData);
  mRendered = true;
}
 
Example #20
Source File: WXSDKInstance.java    From weex with Apache License 2.0 5 votes vote down vote up
private WXHttpListener(String pageName, Map<String, Object> options, String jsonInitData, int width, int height, WXRenderStrategy flag, long startRequestTime) {
  this.pageName = pageName;
  this.options = options;
  this.jsonInitData = jsonInitData;
  this.width = width;
  this.height = height;
  this.flag = flag;
  this.startRequestTime = startRequestTime;
}
 
Example #21
Source File: AbstractWeexActivity.java    From incubator-weex-playground with Apache License 2.0 5 votes vote down vote up
protected void renderPageByURL(String url,String jsonInitData){
  AssertUtil.throwIfNull(mContainer,new RuntimeException("Can't render page, container is null"));
  Map<String, Object> options = new HashMap<>();
  options.put(WXSDKInstance.BUNDLE_URL, url);
  mInstance.setTrackComponent(true);
  mInstance.renderByUrl(
    getPageName(),
    url,
    options,
    jsonInitData,
    WXRenderStrategy.APPEND_ASYNC);
}
 
Example #22
Source File: WXPreLoadManager.java    From incubator-weex-playground with Apache License 2.0 5 votes vote down vote up
public void preLoad(String url) {

        boolean preDownLoad = url.contains("preDownLoad=true");
        boolean preInit = url.contains("preInitInstance=rax") || url.contains("preInitInstance=vue");
        if (!preDownLoad && !preInit){
            return;
        }


        WXSDKInstance instance = new WXSDKInstance();
        Map<String, Object> options = new HashMap<>();
        options.put("bundleUrl", url);
        options.put("render_strategy", WXRenderStrategy.APPEND_ASYNC.toString());
        options.put("wxPreInit",preInit);
        options.put("wxPreDownLoad",preDownLoad);
        String script = null;
        if (preInit){
            if (url.contains("preInitInstance=rax")) {
                script = "// { \"framework\": \"Rax\" }\n";
            } else if (url.contains("preInitInstance=vue")) {
                script = "// { \"framework\": \"Vue\" }\n";
            } else {
                WXLogUtils.e("WXPreLoadManager", "unsupport init bundle type :" + url);
            }
            if (null != script) {
                mPreInitInstanceMap.put(url, instance);
                Log.d("test->", "start preInit: ");
                instance.preInit(url, script, options, null, WXRenderStrategy.APPEND_ASYNC);
            }
        }
        if (preDownLoad){
            if (!mPreInitInstanceMap.containsKey(url)) {
                mPreInitInstanceMap.put(url, instance);
            }
            Log.d("test->", "start preDownLoad: ");
            instance.preDownLoad(url, options, null, WXRenderStrategy.APPEND_ASYNC);
        }
    }
 
Example #23
Source File: WeexActivity.java    From CrazyDaily with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mWXSDKInstance = new WXSDKInstance(this);
    mWXSDKInstance.registerRenderListener(this);
    final Intent intent = getIntent();
    mWXSDKInstance.render(intent.getStringExtra(ActivityConstant.PAGE), WXFileUtils.loadAsset(intent.getStringExtra(ActivityConstant.PATH), this), null, null, WXRenderStrategy.APPEND_ASYNC);
}
 
Example #24
Source File: TabPagerFragment.java    From CrazyDaily with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    String type = getArguments().getString("type");
    mGankIoContent = (FrameLayout) inflater.inflate(R.layout.layout_weex_gank_io, container, false);
    final Context context = getActivity();
    mWXSDKInstance = new WXSDKInstance(context);
    mWXSDKInstance.registerRenderListener(this);
    Map<String, Object> options = new HashMap<>();
    options.put("type", type);
    mWXSDKInstance.render("GankioList", WXFileUtils.loadAsset("weex/gankio/gankiolist.js", context), options, null, WXRenderStrategy.APPEND_ASYNC);
    return mGankIoContent;
}
 
Example #25
Source File: WXSDKInstance.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
private void renderByUrlInternal(String pageName,
                                 final String url,
                                 Map<String, Object> options,
                                 final String jsonInitData,
                                 final WXRenderStrategy flag) {

  ensureRenderArchor();
  pageName = wrapPageName(pageName, url);
  mBundleUrl = url;
  if(WXSDKManager.getInstance().getValidateProcessor()!=null) {
    mNeedValidate = WXSDKManager.getInstance().getValidateProcessor().needValidate(mBundleUrl);
  }

  Map<String, Object> renderOptions = options;
  if (renderOptions == null) {
    renderOptions = new HashMap<>();
  }
  if (!renderOptions.containsKey(BUNDLE_URL)) {
    renderOptions.put(BUNDLE_URL, url);
  }

  Uri uri = Uri.parse(url);
  if (uri != null && TextUtils.equals(uri.getScheme(), "file")) {
    render(pageName, WXFileUtils.loadFileOrAsset(assembleFilePath(uri), mContext), renderOptions, jsonInitData, flag);
    return;
  }

  IWXHttpAdapter adapter = WXSDKManager.getInstance().getIWXHttpAdapter();

  WXRequest wxRequest = new WXRequest();
  wxRequest.url = rewriteUri(Uri.parse(url),URIAdapter.BUNDLE).toString();
  if (wxRequest.paramMap == null) {
    wxRequest.paramMap = new HashMap<String, String>();
  }
  wxRequest.paramMap.put(KEY_USER_AGENT, WXHttpUtil.assembleUserAgent(mContext,WXEnvironment.getConfig()));
  WXHttpListener httpListener =
      new WXHttpListener(pageName, renderOptions, jsonInitData, flag, System.currentTimeMillis());
  httpListener.setSDKInstance(this);
  adapter.sendRequest(wxRequest, (IWXHttpAdapter.OnHttpListener) httpListener);
}
 
Example #26
Source File: AbsWeexActivity.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
protected void renderPageByURL(String url, String jsonInitData) {
  CommonUtils.throwIfNull(mContainer, new RuntimeException("Can't render page, container is null"));
  Map<String, Object> options = new HashMap<>();
  options.put(WXSDKInstance.BUNDLE_URL, url);
  mInstance.renderByUrl(
      getPageName(),
      url,
      options,
      jsonInitData,
      CommonUtils.getDisplayWidth(this),
      CommonUtils.getDisplayHeight(this),
      WXRenderStrategy.APPEND_ASYNC);
}
 
Example #27
Source File: UWXBaseFragment.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
private void render(String tempUrl) {
    mWXSDKInstance.renderByUrl(
            "",
            tempUrl,
            null,
            null,
            CommonUtils.getDisplayWidth(getActivity()),
            CommonUtils.getDisplayHeight(getActivity()),
            WXRenderStrategy.APPEND_ASYNC);
}
 
Example #28
Source File: UWXBaseActivity.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
protected void renderPageByURL(String url, String jsonInitData) {
    mUrl = url;
    CommonUtils.throwIfNull(mContainer, new RuntimeException("Can't render page, container is null"));
    Map<String, Object> options = new HashMap<>();
    options.put(WXSDKInstance.BUNDLE_URL, url);
    mInstance.renderByUrl(
            getPageName(),
            url,
            options,
            jsonInitData,
            CommonUtils.getDisplayWidth(this),
            CommonUtils.getDisplayHeight(this),
            WXRenderStrategy.APPEND_ASYNC);
}
 
Example #29
Source File: WXSDKInstance.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
private void renderInternal(String pageName,
                            String template,
                            Map<String, Object> options,
                            String jsonInitData,
                            WXRenderStrategy flag){
  if (mRendered || TextUtils.isEmpty(template)) {
    return;
  }

  ensureRenderArchor();

  Map<String, Object> renderOptions = options;
  if (renderOptions == null) {
    renderOptions = new HashMap<>();
  }

  if (WXEnvironment.sDynamicMode && !TextUtils.isEmpty(WXEnvironment.sDynamicUrl) && renderOptions.get("dynamicMode") == null) {
    renderOptions.put("dynamicMode", "true");
    renderByUrl(pageName, WXEnvironment.sDynamicUrl, renderOptions, jsonInitData, flag);
    return;
  }

  mWXPerformance.pageName = pageName;
  mWXPerformance.JSTemplateSize = template.length() / 1024;

  mRenderStartTime = System.currentTimeMillis();
  mRenderStrategy = flag;

  WXSDKManager.getInstance().setCrashInfo(WXEnvironment.WEEX_CURRENT_KEY,pageName);

  WXSDKManager.getInstance().createInstance(this, template, renderOptions, jsonInitData);
  mRendered = true;

  if (TextUtils.isEmpty(mBundleUrl)) {
    mBundleUrl = pageName;
  }
}
 
Example #30
Source File: CreateFinishAction.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
@Override
public void executeRender(RenderActionContext context) {
  WXSDKInstance instance = context.getInstance();
  if (instance.getRenderStrategy() == WXRenderStrategy.APPEND_ONCE) {
    instance.onCreateFinish();
  }
  instance.onRenderSuccess(mLayoutWidth, mLayoutHeight);
}