Пример #1
0
  public void onClickButton(View v) {

    switch (v.getId()) {
      case R.id.button_changepassword:
        // change password
        if (requiredFieldsAreFilled()) {
          EditText et;
          // get old password
          et = (EditText) findViewById(R.id.editText_changepassword_oldpassword);
          CharSequence oldPassword = et.getText().toString();
          // get new password
          et = (EditText) findViewById(R.id.editText_changepassword_newpassword);
          CharSequence newPassword = et.getText().toString();
          // get user email
          CharSequence userEmail = LocalStorage.getInstance().getUserEmail(this);
          // UI
          showProgressBar(true);
          // call web service
          UsersController controller = new UsersController(this);
          controller.changeUserPassword(userEmail, newPassword, oldPassword);
        } else {
          Toast.makeText(this, R.string.toast_requiredfields2, Toast.LENGTH_SHORT).show();
        }
        break;
    }
  }
Пример #2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getActionBar().hide();
    setContentView(R.layout.activity_password);

    TextView tv = (TextView) findViewById(R.id.textView_changepassword_email);
    CharSequence userEmail = LocalStorage.getInstance().getUserEmail(this);
    tv.setText(userEmail);
  }
Пример #3
0
  /**
   * Method called when a request is received from the server. Parse the JSON data and delivers it
   * to the properly activity according to the route request and the status code.
   *
   * @param route
   * @param statusCode
   * @param jObject
   * @param jArray
   */
  public synchronized void requestFinished(
      String route, int statusCode, JSONObject jObject, JSONArray jArray) {
    try {
      if (statusCode == HttpStatusCode.REQUEST_TIMEOUT) {
        throw new Exception();
      }

      if (route.matches("collections/" + Regex.INTEGER)) {
        // GET <URLbase>/collections/{idCollection}
        if (jObject != null) {
          // get language code
          String lang = LocalStorage.getInstance().getLocaleLanguage(activity);
          // collection
          Collection collection = new Collection(jObject, lang);

          if (activity instanceof ProductActivity) {
            ProductActivity productActivity = (ProductActivity) activity;
            productActivity.collectionReceived(collection);
          }
        }
      }

    } catch (Exception e) {
      if (!RESTClient.isOnline(activity)) {
        Toast.makeText(
                activity,
                activity.getResources().getString(R.string.toast_problem_internetconnection),
                Toast.LENGTH_SHORT)
            .show();
      } else {
        Toast.makeText(
                activity,
                activity.getResources().getString(R.string.toast_problem_request),
                Toast.LENGTH_SHORT)
            .show();
      }
      activity.finish();
    }
  }