title: MVP Architecture
body: <p><strong>I tried to Refactor the Login Module of the Application Any Mistakes and Suggestions what else should i work on and i should keep in mind</strong></p>
  
  <p><strong>Login Presenter.java</strong></p>
  
  <pre><code>public class LoginPresenter implements LoginInteractor.LoginPresenter {
  private LoginInteractor.LoginView loginView;
  
  public LoginPresenter(LoginInteractor.LoginView loginView) {
      this.loginView = loginView;
  
  
  }
  @Override
  public void CheckIdUserVerified(FirebaseUser currentUser, Context context) {
      if (currentUser != null) {
          if (currentUser.isEmailVerified()) {
              loginView.OnLoginSuccess();
          }
      }
  }
  @Override
  public void Register() {
      loginView.OnRegister();
  }
  @Override
  public void Login(String email,String password,final FirebaseAuth mAuth){
  
      if (email.isEmpty() &amp;&amp; password.isEmpty()) {
          loginView.OnMessage("password is empty");
          return;
      } else if (email.isEmpty()) {
          loginView.OnMessage("email is empty");
          return;
      } else if (password.isEmpty()) {
          loginView.OnMessage("password is empty");
          return;
      } else {
          mAuth.signInWithEmailAndPassword(email, password)
                  .addOnCompleteListener((Executor) this, new OnCompleteListener&lt;AuthResult&gt;() {
                      @Override
                      public void onComplete(@NonNull Task&lt;AuthResult&gt; task) {
                          if (task.isSuccessful()) {
                              if (mAuth.getCurrentUser().isEmailVerified()) {
                                  loginView.OnLoginSuccess();
  
  
                              } else {
                                  loginView.builderr("Verify","Verify mo to","Verify");
  
                                  loginView.OnMessage("Failed");
                              }
  
  
                          }
                      }});}}}
  </code></pre>
  
  <p>Should i Use Firebase on the Model part or its ok if its in View </p>
  
  <p><strong>Login View.java</strong></p>
  
  <pre><code>    public class LoginView extends AppCompatActivity implements 
     LoginInteractor.LoginView {
  private LoginPresenter loginPresenter;
  public Button login;
  public TextView register;
  EditText editTextEmail, editTextPassword;
  FirebaseAuth mAuth;
  FirebaseUser currentUser;
  ProgressDialog progressDialog;
  
  
  
  
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_login);
      Initialize();
  
      loginPresenter.CheckIdUserVerified(currentUser,this);
  
  
      //LoginButtonOnClick
      login.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
  
      loginPresenter.Login(editTextEmail.getText().toString(),
  editTextPassword.getText().toString(),mAuth);
          }
      });
  
      //Goto Register Page
      register.setOnClickListener(new View.OnClickListener() {
       @Override
       public void onClick(View v) {
             loginPresenter.Register();
       }
  });
  
  }
  
  @Override
  public void Initialize() {
      loginPresenter = new LoginPresenter(this);
      editTextEmail = (EditText) findViewById(R.id.editTextEmail);
      editTextPassword = (EditText) findViewById(R.id.editTextPassword);
      login = (Button)findViewById(R.id.buttonLogin);
      register = (TextView)findViewById(R.id.registertext);
      editTextEmail = (EditText) findViewById(R.id.editTextEmail);
      editTextPassword = (EditText) findViewById(R.id.editTextPassword);
      progressDialog = new ProgressDialog(this);
      progressDialog.setMessage("Logging in..");
      progressDialog.setCancelable(false);
      mAuth = FirebaseAuth.getInstance();
      currentUser = mAuth.getCurrentUser();
  
  }
  public void OnVerify(){
  
      Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.google.android.gm");
      if (launchIntent != null) {
          startActivity(launchIntent);//null pointer check in case package name was not found
      } else {
          startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://mail.google.com/mail/#inbox")));
      }
  
  }
  public void OnRegister(){
      startActivity(new Intent(LoginView.this, RegisterView.class));
  }
  public void OnMessage(String message){
  Toast.makeText(LoginView.this, message, Toast.LENGTH_SHORT).show();
           }
   public void OnLoginSuccess(){
  startActivity(new Intent(LoginView.this, MainActivity.class));
  finish();
         }
  public void builderr(String BulderTitle,String BuilderMessage,String 
        PositiveButton) {
      AlertDialog.Builder builder;
      builder = new AlertDialog.Builder(this);
      builder.setCancelable(true);
      builder.setTitle(BulderTitle);
      builder.setMessage(BuilderMessage);
      builder.setInverseBackgroundForced(true);
      builder.setPositiveButton(PositiveButton,
              new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                      OnVerify();
  
                  }});
      AlertDialog alert = builder.create();
      alert.show();
  
  
  
  }}
  </code></pre>
  
  <p><strong>LoginInteractor</strong></p>
  
  <pre><code>      public interface LoginInteractor {
  interface LoginView{
      void Initialize();
      void OnLoginSuccess();
      void OnMessage(String message);
      void OnRegister();
      void builderr(String BulderTitle,String BuilderMessage,String 
      PositiveButton);
  }
  interface LoginPresenter{
      void CheckIdUserVerified(FirebaseUser currentUser, Context context);
      void Login(String email, String password, FirebaseAuth mAuth);
      void Register();
  
  }
  }
  </code></pre>
  
  <p>**
  If i should put firebase on model any idea that will look like?
  i was kinda reasearching and looking for answers but how should i initialize firebase without the oncreate Method?**</p>