@Test public void testPush() throws Exception { module.push("{}",callback); module.push("{'url':'kdkdkdkdkd'}",callback); mockSetter(); module.push("{}",callback); }
@JSMethod(uiThread = true) public void push(String param, JSCallback callback) { if (!TextUtils.isEmpty(param)) { if (WXSDKEngine.getActivityNavBarSetter() != null) { if (WXSDKEngine.getActivityNavBarSetter().push(param)) { callback.invoke(MSG_SUCCESS); return; } } try { JSONObject jsonObject = JSON.parseObject(param); String url = jsonObject.getString(URL); if (!TextUtils.isEmpty(url)) { Uri rawUri = Uri.parse(url); String scheme = rawUri.getScheme(); Uri.Builder builder = rawUri.buildUpon(); if (TextUtils.isEmpty(scheme)) { builder.scheme(Constants.Scheme.HTTP); } Intent intent = new Intent(Intent.ACTION_VIEW, builder.build()); intent.addCategory(WEEX); intent.putExtra(INSTANCE_ID, mWXSDKInstance.getInstanceId()); mWXSDKInstance.getContext().startActivity(intent); callback.invoke(MSG_SUCCESS); } } catch (Exception e) { WXLogUtils.eTag(TAG, e); callback.invoke(MSG_FAILED); } } callback.invoke(MSG_FAILED); }
WXNavigatorModule extends WXModule { @JSMethod(uiThread = true) public void push(String param, JSCallback callback) { if (!TextUtils.isEmpty(param)) { if (WXSDKEngine.getActivityNavBarSetter() != null) { if (WXSDKEngine.getActivityNavBarSetter().push(param)) { callback.invoke(MSG_SUCCESS); return; } } try { JSONObject jsonObject = JSON.parseObject(param); String url = jsonObject.getString(URL); if (!TextUtils.isEmpty(url)) { Uri rawUri = Uri.parse(url); String scheme = rawUri.getScheme(); Uri.Builder builder = rawUri.buildUpon(); if (TextUtils.isEmpty(scheme)) { builder.scheme(Constants.Scheme.HTTP); } Intent intent = new Intent(Intent.ACTION_VIEW, builder.build()); intent.addCategory(WEEX); intent.putExtra(INSTANCE_ID, mWXSDKInstance.getInstanceId()); mWXSDKInstance.getContext().startActivity(intent); callback.invoke(MSG_SUCCESS); } } catch (Exception e) { WXLogUtils.eTag(TAG, e); callback.invoke(MSG_FAILED); } } callback.invoke(MSG_FAILED); } }
WXNavigatorModule extends WXModule { @JSMethod(uiThread = true) public void push(String param, JSCallback callback) { if (!TextUtils.isEmpty(param)) { if (WXSDKEngine.getActivityNavBarSetter() != null) { if (WXSDKEngine.getActivityNavBarSetter().push(param)) { callback.invoke(MSG_SUCCESS); return; } } try { JSONObject jsonObject = JSON.parseObject(param); String url = jsonObject.getString(URL); if (!TextUtils.isEmpty(url)) { Uri rawUri = Uri.parse(url); String scheme = rawUri.getScheme(); Uri.Builder builder = rawUri.buildUpon(); if (TextUtils.isEmpty(scheme)) { builder.scheme(Constants.Scheme.HTTP); } Intent intent = new Intent(Intent.ACTION_VIEW, builder.build()); intent.addCategory(WEEX); intent.putExtra(INSTANCE_ID, mWXSDKInstance.getInstanceId()); mWXSDKInstance.getContext().startActivity(intent); callback.invoke(MSG_SUCCESS); } } catch (Exception e) { WXLogUtils.eTag(TAG, e); callback.invoke(MSG_FAILED); } } callback.invoke(MSG_FAILED); }  }
WXNavigatorModule extends WXModule { @JSMethod(uiThread = true) public void push(String param, JSCallback callback) { if (!TextUtils.isEmpty(param)) { if (WXSDKEngine.getActivityNavBarSetter() != null) { if (WXSDKEngine.getActivityNavBarSetter().push(param)) { callback.invoke(MSG_SUCCESS); return; } } try { JSONObject jsonObject = JSON.parseObject(param); String url = jsonObject.getString(URL); if (!TextUtils.isEmpty(url)) { Uri rawUri = Uri.parse(url); String scheme = rawUri.getScheme(); Uri.Builder builder = rawUri.buildUpon(); if (TextUtils.isEmpty(scheme)) { builder.scheme(Constants.Scheme.HTTP); } Intent intent = new Intent(Intent.ACTION_VIEW, builder.build()); intent.addCategory(WEEX); intent.putExtra(INSTANCE_ID, mWXSDKInstance.getInstanceId()); mWXSDKInstance.getContext().startActivity(intent); callback.invoke(MSG_SUCCESS); } } catch (Exception e) { WXLogUtils.eTag(TAG, e); callback.invoke(MSG_FAILED); } } callback.invoke(MSG_FAILED); }  @JSMethod(uiThread = true) void open(JSONObject options, JSCallback success, JSCallback failure); @JSMethod(uiThread = true) void close(JSONObject options, JSCallback success, JSCallback failure); @JSMethod(uiThread = true) void push(String param, JSCallback callback); @JSMethod(uiThread = true) void pop(String param, JSCallback callback); @JSMethod(uiThread = true) void setNavBarRightItem(String param, JSCallback callback); @JSMethod(uiThread = true) void clearNavBarRightItem(String param, JSCallback callback); @JSMethod(uiThread = true) void setNavBarLeftItem(String param, JSCallback callback); @JSMethod(uiThread = true) void clearNavBarLeftItem(String param, JSCallback callback); @JSMethod(uiThread = true) void setNavBarMoreItem(String param, JSCallback callback); @JSMethod(uiThread = true) void clearNavBarMoreItem(String param, JSCallback callback); @JSMethod(uiThread = true) void setNavBarTitle(String param, JSCallback callback); @JSMethod void setNavBarHidden(String param, final String callback); }
WXNavigatorModule extends WXModule { @JSMethod(uiThread = true) public void push(String param, JSCallback callback) { if (!TextUtils.isEmpty(param)) { if (WXSDKEngine.getActivityNavBarSetter() != null) { if (WXSDKEngine.getActivityNavBarSetter().push(param)) { callback.invoke(MSG_SUCCESS); return; } } try { JSONObject jsonObject = JSON.parseObject(param); String url = jsonObject.getString(URL); if (!TextUtils.isEmpty(url)) { Uri rawUri = Uri.parse(url); String scheme = rawUri.getScheme(); Uri.Builder builder = rawUri.buildUpon(); if (TextUtils.isEmpty(scheme)) { builder.scheme(Constants.Scheme.HTTP); } Intent intent = new Intent(Intent.ACTION_VIEW, builder.build()); intent.addCategory(WEEX); intent.putExtra(INSTANCE_ID, mWXSDKInstance.getInstanceId()); mWXSDKInstance.getContext().startActivity(intent); callback.invoke(MSG_SUCCESS); } } catch (Exception e) { WXLogUtils.eTag(TAG, e); callback.invoke(MSG_FAILED); } } callback.invoke(MSG_FAILED); }  @JSMethod(uiThread = true) void open(JSONObject options, JSCallback success, JSCallback failure); @JSMethod(uiThread = true) void close(JSONObject options, JSCallback success, JSCallback failure); @JSMethod(uiThread = true) void push(String param, JSCallback callback); @JSMethod(uiThread = true) void pop(String param, JSCallback callback); @JSMethod(uiThread = true) void setNavBarRightItem(String param, JSCallback callback); @JSMethod(uiThread = true) void clearNavBarRightItem(String param, JSCallback callback); @JSMethod(uiThread = true) void setNavBarLeftItem(String param, JSCallback callback); @JSMethod(uiThread = true) void clearNavBarLeftItem(String param, JSCallback callback); @JSMethod(uiThread = true) void setNavBarMoreItem(String param, JSCallback callback); @JSMethod(uiThread = true) void clearNavBarMoreItem(String param, JSCallback callback); @JSMethod(uiThread = true) void setNavBarTitle(String param, JSCallback callback); @JSMethod void setNavBarHidden(String param, final String callback); static final String MSG_SUCCESS; static final String MSG_FAILED; static final String MSG_PARAM_ERR; static final String CALLBACK_RESULT; static final String CALLBACK_MESSAGE; }