示例#1
0
  /** *** CHECK FOR EMPTY FIELDS **** */
  private void checkEmpty() {

    /* HIDE THE KEYBOARD */
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(edtDishName.getWindowToken(), 0);

    /** GET THE REQUIRED DATA * */
    MEAL_NAME = edtDishName.getText().toString();
    MEAL_DESCRIPTION = edtDishDescription.getText().toString();
    MEAL_PRICE = edtDishPrice.getText().toString();

    if (MEAL_NAME.length() == 0) {
      inputDishName.setError("Menu / Dish name cannot be empty!");
      edtDishName.requestFocus();
    } else if (MEAL_DESCRIPTION.length() == 0) {
      inputDishDescription.setError("Please provide the Menu / Dish Description");
      edtDishDescription.requestFocus();
    } else if (MEAL_PRICE.length() == 0) {
      inputDishPrice.setError("The Menu / Dish needs to have a Price");
      edtDishPrice.requestFocus();
    } else {
      /* REMOVE THE ERRORS (IF SHOWN) */
      inputDishName.setErrorEnabled(false);
      inputDishDescription.setErrorEnabled(false);
      inputDishPrice.setErrorEnabled(false);

      /* CHECK FOR UNIQUE MENU / DISH NAME */
      new checkUniqueDishName().execute();
    }
  }
  @Nullable
  @OnClick(R.id.search_layout_btn)
  void onSearchClick() {

    /*关闭键盘*/
    inputMethodManager.hideSoftInputFromWindow(revealRootView.getApplicationWindowToken(), 0);

    if (TextUtils.isEmpty(searchEt.getText().toString())) return;

    ProductKeyListActivity.navigateToProductKeyList(
        SearchActivity.this, searchEt.getText().toString(), searchEt.getText().toString());
    overridePendingTransition(0, 0);
  }
  private ArrayList<UniversalButton> getCurrentUniversalButtons() {
    ArrayList<UniversalButton> buttons = new ArrayList<>();

    for (int i = 0; i < buttonsList.getChildCount(); i++) {
      LinearLayout universalButtonLayout = (LinearLayout) buttonsList.getChildAt(i);

      LinearLayout nameLayout = (LinearLayout) universalButtonLayout.getChildAt(0);
      AppCompatEditText nameEditText = (AppCompatEditText) nameLayout.getChildAt(0);
      AppCompatEditText signalEditText = (AppCompatEditText) universalButtonLayout.getChildAt(1);

      buttons.add(
          new UniversalButton(
              null, nameEditText.getText().toString(), null, signalEditText.getText().toString()));
    }

    return buttons;
  }
  /** *** CHECK FOR NECESSARY DETAILS **** */
  private void checkCatDetails() {

    /* HIDE THE KEYBOARD */
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(edtCategoryName.getWindowToken(), 0);

    /** CHECK THAT THE CATEGORY NAME AND THE CATEGORY THUMB ARE NOT EMPTY * */
    if (edtCategoryName.getText().toString().length() == 0 && CATEGORY_THUMB == null) {
      edtCategoryName.setError("You need to enter the Category Name");
      String strMessage = "An image representing the Category is necessary to save it!";
      Toast.makeText(getApplicationContext(), strMessage, Toast.LENGTH_SHORT).show();
    } else if (edtCategoryName.getText().toString().length() == 0 && CATEGORY_THUMB != null) {
      edtCategoryName.setError("You need to enter the Category Name");
    } else if (edtCategoryName.getText().toString().length() != 0 && CATEGORY_THUMB == null) {
      String strMessage = "An image representing the Category is necessary to save it!";
      Toast.makeText(getApplicationContext(), strMessage, Toast.LENGTH_SHORT).show();
    } else {
      /** *** CHECK FOR UNIQUE MEAL CATEGORY **** */
      new checkUniqueCategory().execute();
    }
  }
示例#5
0
  @Override
  public void onSaveInstanceState(Bundle savedInstanceState) {
    // Save state
    super.onSaveInstanceState(savedInstanceState);
    savedInstanceState.putInt(REPORT_ID, targetId);
    savedInstanceState.putInt(REPORT_TYPE, type);
    savedInstanceState.putInt(REPORT_CATEGORY, reportCategorySelect.getCheckedRadioButtonId());

    if (targetName != null) {
      savedInstanceState.putString(REPORT_USER, targetName);
    }
    if (reportContent != null) {
      savedInstanceState.putString(REPORT_CONTENT, reportContent.getText().toString());
    }
  }
  private void set(Alarm alarm, TimerObj timer, String tag) {
    String label = mLabelBox.getText().toString();
    if (label.trim().isEmpty()) {
      // Don't allow user to input label with only whitespace.
      label = "";
    }

    if (alarm != null) {
      set(alarm, tag, label);
    } else if (timer != null) {
      set(timer, tag, label);
    } else {
      LogUtils.e("No alarm or timer available.");
    }
  }
示例#7
0
  /** Wrapper for sending the report to NS servers. */
  private void startSendReport() {
    if (isFinishing()) {
      return;
    }

    String reportText = reportContent.getText().toString();
    if (reportText.length() <= 0) {
      SparkleHelper.makeSnackbar(view, getString(R.string.report_blank));
      return;
    }

    AlertDialog.Builder dialogBuilder =
        new AlertDialog.Builder(this, RaraHelper.getThemeMaterialDialog(this));
    dialogBuilder
        .setTitle(R.string.report_confirm)
        .setPositiveButton(R.string.report_send_confirm, dialogListener)
        .setNegativeButton(R.string.explore_negative, null)
        .show();
  }
示例#8
0
  private void sendReport() {
    if (isInProgress) {
      SparkleHelper.makeSnackbar(view, getString(R.string.multiple_request_error));
      return;
    }
    isInProgress = true;

    String typeHeader;
    String reasonHeader;
    switch (type) {
      case REPORT_TYPE_RMB:
        typeHeader = getString(R.string.report_header_rmb_post);
        reasonHeader = getString(R.string.report_header_reason);
        break;
      case REPORT_TYPE_TELEGRAM:
        typeHeader = getString(R.string.report_header_telegram);
        reasonHeader = getString(R.string.report_header_reason);
        break;
      case REPORT_TYPE_TASK:
        typeHeader = getString(R.string.report_header_task);
        reasonHeader = getString(R.string.report_header_response);
        break;
      default:
        typeHeader = "";
        reasonHeader = "";
        break;
    }
    final String commentHeader =
        String.format(
            Locale.US,
            getString(R.string.report_header_comment_template),
            typeHeader,
            targetId,
            reasonHeader,
            reportContent.getText().toString());

    final int problemHeader;
    if (type == REPORT_TYPE_TASK) {
      problemHeader = HEADER_GHR_MODREPLY;
    } else {
      switch (reportCategorySelect.getCheckedRadioButtonId()) {
        case R.id.report_inappropriate:
          problemHeader = HEADER_GHR_INAPPROPRIATE;
          break;
        case R.id.report_spam:
          problemHeader = HEADER_GHR_SPAMMER;
          break;
        default:
          problemHeader = HEADER_GHR_OTHER;
          break;
      }
    }

    NSStringRequest stringRequest =
        new NSStringRequest(
            getApplicationContext(),
            Request.Method.POST,
            REPORT_URL,
            new Response.Listener<String>() {
              @Override
              public void onResponse(String response) {
                isInProgress = false;
                mSwipeRefreshLayout.setRefreshing(false);
                finish();
              }
            },
            new Response.ErrorListener() {
              @Override
              public void onErrorResponse(VolleyError error) {
                SparkleHelper.logError(error.toString());
                mSwipeRefreshLayout.setRefreshing(false);
                isInProgress = false;
                if (error instanceof TimeoutError
                    || error instanceof NoConnectionError
                    || error instanceof NetworkError) {
                  SparkleHelper.makeSnackbar(view, getString(R.string.login_error_no_internet));
                } else {
                  SparkleHelper.makeSnackbar(view, getString(R.string.login_error_generic));
                }
              }
            });

    Map<String, String> params = new HashMap<String, String>();
    params.put("problem", Integer.toString(problemHeader));
    params.put("comment", SparkleHelper.escapeHtml(commentHeader));
    params.put("submit", "1");
    stringRequest.setParams(params);

    if (!DashHelper.getInstance(this).addRequest(stringRequest)) {
      mSwipeRefreshLayout.setRefreshing(false);
      isInProgress = false;
      SparkleHelper.makeSnackbar(view, getString(R.string.rate_limit_error));
    }
  }
示例#9
0
  private void validateData() {

    /** HIDE THE KEYBOARD * */
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(getWindow().getCurrentFocus().getWindowToken(), 0);

    /** * GRAB THE DATA ** */
    TAX_NAME = edtTaxName.getText().toString();
    TAX_PERCENTAGE = edtTaxPercentage.getText().toString();
    TAX_REGISTRATION = edtTaxRegistration.getText().toString();
    if (TAX_COMPLETE_AMOUNT) {
      TAX_PERCENT_OF_AMOUNT = "100";
    } else {
      TAX_PERCENT_OF_AMOUNT = edtTaxPercentageOfAmount.getText().toString();
    }

    /** *** CHECK FOR THE REQUIRED DATA **** */
    if (edtTaxName.getText().toString().length() == 0) {
      edtTaxName.setError(getResources().getString(R.string.tax_creator_tax_name_empty));
      edtTaxName.requestFocus();
    } else if (edtTaxPercentage.getText().toString().length() == 0) {
      edtTaxPercentage.setError(
          getResources().getString(R.string.tax_creator_tax_percentage_empty));
      edtTaxPercentage.requestFocus();
    } else if (edtTaxPercentage.getText().toString().equals("0")
        || edtTaxPercentage.getText().toString().equals("0.0")
        || edtTaxPercentage.getText().toString().equals("0.00")) {
      edtTaxPercentage.setError(getResources().getString(R.string.tax_creator_tax_percentage_zero));
      edtTaxPercentage.requestFocus();
    } else if (edtTaxRegistration.getText().toString().length() == 0) {
      edtTaxRegistration.setError(
          getResources().getString(R.string.tax_creator_tax_registration_empty));
      edtTaxRegistration.requestFocus();
    } else if (!TAX_COMPLETE_AMOUNT
        && edtTaxPercentageOfAmount.getText().toString().length() == 0) {
      edtTaxPercentageOfAmount.setError(
          getResources().getString(R.string.tax_creator_tax_percentage_of_amount_empty));
      edtTaxPercentageOfAmount.requestFocus();
    } else if (edtTaxPercentageOfAmount.getText().toString().equals("0")
        || edtTaxPercentageOfAmount.getText().toString().equals("0.0")
        || edtTaxPercentageOfAmount.getText().toString().equals("0.00")) {
      edtTaxPercentageOfAmount.setError(
          getResources().getString(R.string.tax_creator_tax_percentage_of_amount_zero));
      edtTaxPercentageOfAmount.requestFocus();
    } else {
      /** CHECK FOR UNIQUE TAX NAME * */
      new checkUniqueTaxName().execute();
    }
  }
 @Override
 public void onSaveInstanceState(@NonNull Bundle outState) {
   super.onSaveInstanceState(outState);
   outState.putString(KEY_LABEL, mLabelBox.getText().toString());
 }
示例#11
0
  private void handleRegisterRequest() {
    final String auth = mEtRegisterAuth.getText().toString().trim();
    final String psw = mEtRegisterPsw.getText().toString().trim();
    final String nick = mEtRegisterName.getText().toString().trim();
    if (TextUtils.isEmpty(auth)) {
      showShortToast("验证码不能为空");
      return;
    }
    if (TextUtils.isEmpty(psw)) {
      showShortToast("密码不能为空");
      return;
    }
    if (TextUtils.isEmpty(nick)) {
      showShortToast("昵称不能为空");
      return;
    }
    OkHttpClientManager.Param[] params =
        new OkHttpClientManager.Param[] {
          new OkHttpClientManager.Param("userPhone", phone),
          new OkHttpClientManager.Param("smsCodeKey", auth),
          new OkHttpClientManager.Param("loginPassword", psw),
          new OkHttpClientManager.Param("device", "2"),
          new OkHttpClientManager.Param("deviceVersion", android.os.Build.VERSION.RELEASE),
          new OkHttpClientManager.Param("model", android.os.Build.MODEL),
          new OkHttpClientManager.Param("imei", TDevice.getDeviceId(this)),
          new OkHttpClientManager.Param("userNike", nick),
          new OkHttpClientManager.Param("applicationVersion", TDevice.getVersionName())
        };
    OkHttpClientManager.postAsyn(
        Constants.LoginAndRegister.REGISTER,
        params,
        new OkHttpClientManager.ResultCallback<RegisterModel>() {
          @Override
          public void onError(Request request, Exception e) {
            e.printStackTrace();
            showShortToast("请检查网络");
          }

          @Override
          public void onResponse(RegisterModel us) {
            Log.e("TAG", us.toString());
            showShortToast(us.getResultMsg());
            if (us.getStatusCode() == 200) {
              // Sp数据保存
              BaseApplication.token = us.getTokenId();

              SPCache.putString(Constants.SharePreference.USER_TOKEN, us.getTokenId());
              SPCache.putInt(Constants.SharePreference.USER_STATUS, us.getData().getUserStatus());
              SPCache.putString(
                  Constants.SharePreference.USER_HEAD_IMAGE, us.getData().getUserSmallHeadImgUrl());
              SPCache.putString(Constants.SharePreference.USER_NICK, us.getData().getUserNick());
              SPCache.putString(
                  Constants.SharePreference.USER_PROFESSION, us.getData().getUserProfession());
              SPCache.putString(Constants.SharePreference.USER_PHONE, us.getData().getUserPhone());
              SPCache.putString(Constants.SharePreference.USER_SEX, us.getData().getUserSex());
              SPCache.putString(
                  Constants.SharePreference.USER_BIRTHDAY, us.getData().getUserBirthday());
              Intent intent = new Intent(RegisterActivity.this, MainActivity.class);
              startActivity(intent);
              finish();
            }
          }
        });
  }