diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/LoginActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/LoginActivity.java index 048caf78..f8bf17eb 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/LoginActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/LoginActivity.java @@ -49,21 +49,11 @@ public class LoginActivity extends BaseActivity { return; } - btnLogin.setEnabled(false); - - final ProgressDialog progressDialog = new ProgressDialog(LoginActivity.this, - R.style.AppTheme_Dark_Dialog); - progressDialog.setIndeterminate(true); - progressDialog.setMessage("Authenticating..."); - progressDialog.show(); - String username = inputUsername.getText().toString().trim(); String password = inputPassword.getText().toString().trim(); - // login user + // login user new LoginTask().execute(username,password); - - progressDialog.dismiss(); } }); @@ -88,7 +78,9 @@ public class LoginActivity extends BaseActivity { btnLogin.setEnabled(true); } - private class LoginTask extends AsyncTask { + private class LoginTask extends AsyncTask + { + ProgressDialog progressDialog; @Override protected Integer doInBackground(String... params) { @@ -96,6 +88,18 @@ public class LoginActivity extends BaseActivity { return loginData.getStatus(); } + @Override + protected void onPreExecute() { + btnLogin.setEnabled(false); + + progressDialog = new ProgressDialog(LoginActivity.this, + R.style.AppTheme_Dark_Dialog); + progressDialog.setIndeterminate(true); + progressDialog.setMessage("Authenticating..."); + progressDialog.show(); + } + + @Override protected void onPostExecute(Integer result) { switch (result) { @@ -135,14 +139,7 @@ public class LoginActivity extends BaseActivity { break; } btnLogin.setEnabled(true); - } - - @Override - protected void onPreExecute() { - } - - @Override - protected void onProgressUpdate(Void... values) { + progressDialog.dismiss(); } }