@Test public void testConfirm() throws Exception { JSCallback callback = Mockito.mock(JSCallback.class); module.confirm("{}",callback); }
@JSMethod(uiThread = true) public void confirm(String param, final JSCallback callback) { if (mWXSDKInstance.getContext() instanceof Activity) { String message = ""; String okTitle = OK; String cancelTitle = CANCEL; if (!TextUtils.isEmpty(param)) { try { param = URLDecoder.decode(param, "utf-8"); JSONObject jsObj = JSON.parseObject(param); message = jsObj.getString(MESSAGE); okTitle = jsObj.getString(OK_TITLE); cancelTitle = jsObj.getString(CANCEL_TITLE); } catch (Exception e) { WXLogUtils.e("[WXModalUIModule] confirm param parse error ", e); } } if (TextUtils.isEmpty(message)) { message = ""; } AlertDialog.Builder builder = new AlertDialog.Builder(mWXSDKInstance.getContext()); builder.setMessage(message); final String okTitleFinal = TextUtils.isEmpty(okTitle) ? OK : okTitle; final String cancelTitleFinal = TextUtils.isEmpty(cancelTitle) ? CANCEL : cancelTitle; builder.setPositiveButton(okTitleFinal, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (callback != null) { callback.invoke(okTitleFinal); } } }); builder.setNegativeButton(cancelTitleFinal, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (callback != null) { callback.invoke(cancelTitleFinal); } } }); AlertDialog alertDialog = builder.create(); alertDialog.setCanceledOnTouchOutside(false); alertDialog.show(); tracking(alertDialog); } else { WXLogUtils.e("[WXModalUIModule] when call confirm mWXSDKInstance.getContext() must instanceof Activity"); } }
WXModalUIModule extends WXSDKEngine.DestroyableModule { @JSMethod(uiThread = true) public void confirm(String param, final JSCallback callback) { if (mWXSDKInstance.getContext() instanceof Activity) { String message = ""; String okTitle = OK; String cancelTitle = CANCEL; if (!TextUtils.isEmpty(param)) { try { param = URLDecoder.decode(param, "utf-8"); JSONObject jsObj = JSON.parseObject(param); message = jsObj.getString(MESSAGE); okTitle = jsObj.getString(OK_TITLE); cancelTitle = jsObj.getString(CANCEL_TITLE); } catch (Exception e) { WXLogUtils.e("[WXModalUIModule] confirm param parse error ", e); } } if (TextUtils.isEmpty(message)) { message = ""; } AlertDialog.Builder builder = new AlertDialog.Builder(mWXSDKInstance.getContext()); builder.setMessage(message); final String okTitleFinal = TextUtils.isEmpty(okTitle) ? OK : okTitle; final String cancelTitleFinal = TextUtils.isEmpty(cancelTitle) ? CANCEL : cancelTitle; builder.setPositiveButton(okTitleFinal, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (callback != null) { callback.invoke(okTitleFinal); } } }); builder.setNegativeButton(cancelTitleFinal, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (callback != null) { callback.invoke(cancelTitleFinal); } } }); AlertDialog alertDialog = builder.create(); alertDialog.setCanceledOnTouchOutside(false); alertDialog.show(); tracking(alertDialog); } else { WXLogUtils.e("[WXModalUIModule] when call confirm mWXSDKInstance.getContext() must instanceof Activity"); } } }
WXModalUIModule extends WXSDKEngine.DestroyableModule { @JSMethod(uiThread = true) public void confirm(String param, final JSCallback callback) { if (mWXSDKInstance.getContext() instanceof Activity) { String message = ""; String okTitle = OK; String cancelTitle = CANCEL; if (!TextUtils.isEmpty(param)) { try { param = URLDecoder.decode(param, "utf-8"); JSONObject jsObj = JSON.parseObject(param); message = jsObj.getString(MESSAGE); okTitle = jsObj.getString(OK_TITLE); cancelTitle = jsObj.getString(CANCEL_TITLE); } catch (Exception e) { WXLogUtils.e("[WXModalUIModule] confirm param parse error ", e); } } if (TextUtils.isEmpty(message)) { message = ""; } AlertDialog.Builder builder = new AlertDialog.Builder(mWXSDKInstance.getContext()); builder.setMessage(message); final String okTitleFinal = TextUtils.isEmpty(okTitle) ? OK : okTitle; final String cancelTitleFinal = TextUtils.isEmpty(cancelTitle) ? CANCEL : cancelTitle; builder.setPositiveButton(okTitleFinal, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (callback != null) { callback.invoke(okTitleFinal); } } }); builder.setNegativeButton(cancelTitleFinal, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (callback != null) { callback.invoke(cancelTitleFinal); } } }); AlertDialog alertDialog = builder.create(); alertDialog.setCanceledOnTouchOutside(false); alertDialog.show(); tracking(alertDialog); } else { WXLogUtils.e("[WXModalUIModule] when call confirm mWXSDKInstance.getContext() must instanceof Activity"); } }  }
WXModalUIModule extends WXSDKEngine.DestroyableModule { @JSMethod(uiThread = true) public void confirm(String param, final JSCallback callback) { if (mWXSDKInstance.getContext() instanceof Activity) { String message = ""; String okTitle = OK; String cancelTitle = CANCEL; if (!TextUtils.isEmpty(param)) { try { param = URLDecoder.decode(param, "utf-8"); JSONObject jsObj = JSON.parseObject(param); message = jsObj.getString(MESSAGE); okTitle = jsObj.getString(OK_TITLE); cancelTitle = jsObj.getString(CANCEL_TITLE); } catch (Exception e) { WXLogUtils.e("[WXModalUIModule] confirm param parse error ", e); } } if (TextUtils.isEmpty(message)) { message = ""; } AlertDialog.Builder builder = new AlertDialog.Builder(mWXSDKInstance.getContext()); builder.setMessage(message); final String okTitleFinal = TextUtils.isEmpty(okTitle) ? OK : okTitle; final String cancelTitleFinal = TextUtils.isEmpty(cancelTitle) ? CANCEL : cancelTitle; builder.setPositiveButton(okTitleFinal, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (callback != null) { callback.invoke(okTitleFinal); } } }); builder.setNegativeButton(cancelTitleFinal, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (callback != null) { callback.invoke(cancelTitleFinal); } } }); AlertDialog alertDialog = builder.create(); alertDialog.setCanceledOnTouchOutside(false); alertDialog.show(); tracking(alertDialog); } else { WXLogUtils.e("[WXModalUIModule] when call confirm mWXSDKInstance.getContext() must instanceof Activity"); } }  @JSMethod(uiThread = true) void toast(String param); @JSMethod(uiThread = true) void alert(String param, final JSCallback callback); @JSMethod(uiThread = true) void confirm(String param, final JSCallback callback); @JSMethod(uiThread = true) void prompt(String param, final JSCallback callback); @Override void destroy(); }
WXModalUIModule extends WXSDKEngine.DestroyableModule { @JSMethod(uiThread = true) public void confirm(String param, final JSCallback callback) { if (mWXSDKInstance.getContext() instanceof Activity) { String message = ""; String okTitle = OK; String cancelTitle = CANCEL; if (!TextUtils.isEmpty(param)) { try { param = URLDecoder.decode(param, "utf-8"); JSONObject jsObj = JSON.parseObject(param); message = jsObj.getString(MESSAGE); okTitle = jsObj.getString(OK_TITLE); cancelTitle = jsObj.getString(CANCEL_TITLE); } catch (Exception e) { WXLogUtils.e("[WXModalUIModule] confirm param parse error ", e); } } if (TextUtils.isEmpty(message)) { message = ""; } AlertDialog.Builder builder = new AlertDialog.Builder(mWXSDKInstance.getContext()); builder.setMessage(message); final String okTitleFinal = TextUtils.isEmpty(okTitle) ? OK : okTitle; final String cancelTitleFinal = TextUtils.isEmpty(cancelTitle) ? CANCEL : cancelTitle; builder.setPositiveButton(okTitleFinal, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (callback != null) { callback.invoke(okTitleFinal); } } }); builder.setNegativeButton(cancelTitleFinal, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (callback != null) { callback.invoke(cancelTitleFinal); } } }); AlertDialog alertDialog = builder.create(); alertDialog.setCanceledOnTouchOutside(false); alertDialog.show(); tracking(alertDialog); } else { WXLogUtils.e("[WXModalUIModule] when call confirm mWXSDKInstance.getContext() must instanceof Activity"); } }  @JSMethod(uiThread = true) void toast(String param); @JSMethod(uiThread = true) void alert(String param, final JSCallback callback); @JSMethod(uiThread = true) void confirm(String param, final JSCallback callback); @JSMethod(uiThread = true) void prompt(String param, final JSCallback callback); @Override void destroy(); static final String OK; static final String CANCEL; static final String RESULT; static final String DATA; static final String MESSAGE; static final String DURATION; static final String OK_TITLE; static final String CANCEL_TITLE; static final String DEFAULT; }