Android Open Source - ribbit Forgot Password Activity






From Project

Back to project page ribbit.

License

The source code is released under:

MIT License

If you think the Android project ribbit listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.lleshiart.ribbit;
//  w  w  w. jav  a2 s.  c  o m
import android.app.Activity;
import android.app.AlertDialog;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;

import com.parse.ParseException;
import com.parse.ParseUser;
import com.parse.RequestPasswordResetCallback;

public class ForgotPasswordActivity extends Activity {
  
  public static final String TAG = ForgotPasswordActivity.class.getSimpleName();

  protected EditText mForgotPasswordText;
  protected Button mForgotPasswordButton;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setContentView(R.layout.activity_forgot_password);
    
    mForgotPasswordText = (EditText) findViewById(R.id.resetEmailField);
    mForgotPasswordButton = (Button)findViewById(R.id.forgotPasswordButton);
    mForgotPasswordButton.setOnClickListener(new View.OnClickListener() {
      
      @Override
      public void onClick(View v) {
        String email = mForgotPasswordText.getText().toString();
        
        email = email.trim();
        
        if (email.isEmpty()) {
          AlertDialog.Builder builder = new AlertDialog.Builder(ForgotPasswordActivity.this);
          builder.setTitle(R.string.forgot_password_error_title)
            
            .setMessage(R.string.forgot_password_error_message)
            .setPositiveButton(android.R.string.ok, null);
          AlertDialog dialog = builder.create();
          dialog.show();
        }
        else {
          // Reset Password
          setProgressBarIndeterminateVisibility(true);
          ParseUser.requestPasswordResetInBackground(email, new RequestPasswordResetCallback() {
            
            @Override
            public void done(ParseException e) {
              setProgressBarIndeterminateVisibility(false);
              
              if (e == null) {
                // Email was sent
                AlertDialog.Builder builder = new AlertDialog.Builder(ForgotPasswordActivity.this);
                builder.setTitle(R.string.forgot_password_success_title)
                  
                  .setMessage(R.string.forgot_password_success_message)
                  .setPositiveButton(android.R.string.ok, null);
                AlertDialog dialog = builder.create();
                dialog.show();
              }
              else {
                // Something went wrong
                AlertDialog.Builder builder = new AlertDialog.Builder(ForgotPasswordActivity.this);
                builder.setTitle(R.string.forgot_password_error_title)
                  
                  .setMessage(e.getMessage())
                  .setPositiveButton(android.R.string.ok, null);
                AlertDialog dialog = builder.create();
                dialog.show();
              }
            }
          });
          
        }
      }
    });
  }
}




Java Source Code List

com.lleshiart.ribbit.EditFriendsActivity.java
com.lleshiart.ribbit.FileHelper.java
com.lleshiart.ribbit.ForgotPasswordActivity.java
com.lleshiart.ribbit.FriendsFragment.java
com.lleshiart.ribbit.ImageResizer.java
com.lleshiart.ribbit.InboxFragment.java
com.lleshiart.ribbit.LoginActivity.java
com.lleshiart.ribbit.MainActivity.java
com.lleshiart.ribbit.MessageAdapter.java
com.lleshiart.ribbit.NewMessageActivity.java
com.lleshiart.ribbit.ParseConstants.java
com.lleshiart.ribbit.RecipientsActivity.java
com.lleshiart.ribbit.SectionsPagerAdapter.java
com.lleshiart.ribbit.SignUpActivity.java
com.lleshiart.ribbit.ViewImageActivity.java