コード例 #1
0
  private void processForm() {
    if (mDelegate != null) {
      Account account = new Account();
      account.setCity(mFormData.get(CITY_KEY));
      account.setCountry(mFormData.get(COUNTRY_KEY));
      account.setEmail(mFormData.get(EMAIL_KEY));
      account.setGender(mFormData.get(GENDER_KEY));
      account.setName(mFormData.get(FULL_NAME_KEY));
      account.setPassword(mFormData.get(PASSWORD_KEY));
      account.setPostalCode(mFormData.get(ZIP_KEY));

      mDelegate.processForm(account);
    }
  }
コード例 #2
0
  public void showErrors(Account account) {
    mAccount = account;
    mFormData.clear();
    mFormData.put(FULL_NAME_KEY, mAccount.getName());
    mFormData.put(EMAIL_KEY, mAccount.getEmail());
    mFormData.put(GENDER_KEY, mAccount.getGender());
    mFormData.put(CITY_KEY, mAccount.getCity());
    mFormData.put(COUNTRY_KEY, mAccount.getCountry());
    mFormData.put(ZIP_KEY, mAccount.getPostalCode());

    notifyDataSetChanged();
  }
コード例 #3
0
  private TextView createErrorView(String key) {
    TextView ret = new TextView(mContext);
    LinearLayout.LayoutParams params =
        new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
    params.topMargin = 10;
    params.bottomMargin = 10;
    ret.setLayoutParams(params);
    ret.setTextColor(Color.RED);
    ret.setTextSize(TypedValue.COMPLEX_UNIT_SP, 10);

    HashMap<String, String> errors = mAccount.getErrors();
    if (errors != null && errors.containsKey(key)) {
      ret.setText(errors.get(key));
      ret.setVisibility(View.VISIBLE);
    } else {
      ret.setVisibility(View.INVISIBLE);
    }

    return ret;
  }