@Test public void testToast() throws Exception { module.toast("{}"); }
@JSMethod(uiThread = true) public void toast(String param) { String message = ""; int duration = Toast.LENGTH_SHORT; if (!TextUtils.isEmpty(param)) { try { param = URLDecoder.decode(param, "utf-8"); JSONObject jsObj = JSON.parseObject(param); message = jsObj.getString(MESSAGE); duration = jsObj.getInteger(DURATION); } catch (Exception e) { WXLogUtils.e("[WXModalUIModule] alert param parse error ", e); } } if (TextUtils.isEmpty(message)) { WXLogUtils.e("[WXModalUIModule] toast param parse is null "); return; } if (duration > 3) { duration = Toast.LENGTH_LONG; } else { duration = Toast.LENGTH_SHORT; } if (toast == null) { toast = Toast.makeText(mWXSDKInstance.getContext(), message, duration); } else { toast.setDuration(duration); toast.setText(message); } toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); }
WXModalUIModule extends WXSDKEngine.DestroyableModule { @JSMethod(uiThread = true) public void toast(String param) { String message = ""; int duration = Toast.LENGTH_SHORT; if (!TextUtils.isEmpty(param)) { try { param = URLDecoder.decode(param, "utf-8"); JSONObject jsObj = JSON.parseObject(param); message = jsObj.getString(MESSAGE); duration = jsObj.getInteger(DURATION); } catch (Exception e) { WXLogUtils.e("[WXModalUIModule] alert param parse error ", e); } } if (TextUtils.isEmpty(message)) { WXLogUtils.e("[WXModalUIModule] toast param parse is null "); return; } if (duration > 3) { duration = Toast.LENGTH_LONG; } else { duration = Toast.LENGTH_SHORT; } if (toast == null) { toast = Toast.makeText(mWXSDKInstance.getContext(), message, duration); } else { toast.setDuration(duration); toast.setText(message); } toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); } }
WXModalUIModule extends WXSDKEngine.DestroyableModule { @JSMethod(uiThread = true) public void toast(String param) { String message = ""; int duration = Toast.LENGTH_SHORT; if (!TextUtils.isEmpty(param)) { try { param = URLDecoder.decode(param, "utf-8"); JSONObject jsObj = JSON.parseObject(param); message = jsObj.getString(MESSAGE); duration = jsObj.getInteger(DURATION); } catch (Exception e) { WXLogUtils.e("[WXModalUIModule] alert param parse error ", e); } } if (TextUtils.isEmpty(message)) { WXLogUtils.e("[WXModalUIModule] toast param parse is null "); return; } if (duration > 3) { duration = Toast.LENGTH_LONG; } else { duration = Toast.LENGTH_SHORT; } if (toast == null) { toast = Toast.makeText(mWXSDKInstance.getContext(), message, duration); } else { toast.setDuration(duration); toast.setText(message); } toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); }  }
WXModalUIModule extends WXSDKEngine.DestroyableModule { @JSMethod(uiThread = true) public void toast(String param) { String message = ""; int duration = Toast.LENGTH_SHORT; if (!TextUtils.isEmpty(param)) { try { param = URLDecoder.decode(param, "utf-8"); JSONObject jsObj = JSON.parseObject(param); message = jsObj.getString(MESSAGE); duration = jsObj.getInteger(DURATION); } catch (Exception e) { WXLogUtils.e("[WXModalUIModule] alert param parse error ", e); } } if (TextUtils.isEmpty(message)) { WXLogUtils.e("[WXModalUIModule] toast param parse is null "); return; } if (duration > 3) { duration = Toast.LENGTH_LONG; } else { duration = Toast.LENGTH_SHORT; } if (toast == null) { toast = Toast.makeText(mWXSDKInstance.getContext(), message, duration); } else { toast.setDuration(duration); toast.setText(message); } toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); }  @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 toast(String param) { String message = ""; int duration = Toast.LENGTH_SHORT; if (!TextUtils.isEmpty(param)) { try { param = URLDecoder.decode(param, "utf-8"); JSONObject jsObj = JSON.parseObject(param); message = jsObj.getString(MESSAGE); duration = jsObj.getInteger(DURATION); } catch (Exception e) { WXLogUtils.e("[WXModalUIModule] alert param parse error ", e); } } if (TextUtils.isEmpty(message)) { WXLogUtils.e("[WXModalUIModule] toast param parse is null "); return; } if (duration > 3) { duration = Toast.LENGTH_LONG; } else { duration = Toast.LENGTH_SHORT; } if (toast == null) { toast = Toast.makeText(mWXSDKInstance.getContext(), message, duration); } else { toast.setDuration(duration); toast.setText(message); } toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); }  @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; }