class WXModalUIModule extends WXSDKEngine.DestroyableModule {

  @JSMethod(uiThread = true)
  public void toast(JSONObject jsObj) {

    String message = "";
    int duration = Toast.LENGTH_SHORT;
    if (jsObj != null) {
      try {
        message = jsObj.getString(MESSAGE);
        if(jsObj.containsKey(DURATION)) {
          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();
  }

}