Commit 458562b1 authored by Sajal Narang's avatar Sajal Narang

Add ProgressDialog for login

parent e53c57e6
...@@ -3,6 +3,7 @@ package in.ac.iitb.gymkhana.iitbapp; ...@@ -3,6 +3,7 @@ package in.ac.iitb.gymkhana.iitbapp;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.app.ProgressDialog;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
...@@ -52,6 +53,7 @@ public class LoginActivity extends AppCompatActivity { ...@@ -52,6 +53,7 @@ public class LoginActivity extends AppCompatActivity {
private AuthorizationService mAuthService; private AuthorizationService mAuthService;
private BroadcastReceiver mRegistrationBroadcastReceiver; private BroadcastReceiver mRegistrationBroadcastReceiver;
private boolean isReceiverRegistered; private boolean isReceiverRegistered;
private ProgressDialog progressDialog;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
...@@ -162,17 +164,18 @@ public class LoginActivity extends AppCompatActivity { ...@@ -162,17 +164,18 @@ public class LoginActivity extends AppCompatActivity {
} }
private void handleAuthorizationResponse(@NonNull Intent intent) { private void handleAuthorizationResponse(@NonNull Intent intent) {
progressDialog = new ProgressDialog(this);
progressDialog.setMessage("Logging In");
progressDialog.setCancelable(false);
progressDialog.setIndeterminate(true);
progressDialog.show();
AuthorizationResponse response = AuthorizationResponse.fromIntent(intent); AuthorizationResponse response = AuthorizationResponse.fromIntent(intent);
AuthorizationException error = AuthorizationException.fromIntent(intent); AuthorizationException error = AuthorizationException.fromIntent(intent);
if (response != null) { if (response != null) {
authCode = response.authorizationCode; authCode = response.authorizationCode;
Log.d(TAG, "Received AuthorizationResponse: " + "AuthCode: " + authCode); Log.d(TAG, "Received AuthorizationResponse: " + "AuthCode: " + authCode);
Toast.makeText(this,
"AuthCode: " + authCode, Toast.LENGTH_SHORT)
.show();
if (checkPlayServices()) { if (checkPlayServices()) {
Intent registerIntent = new Intent(this, RegistrationIntentService.class); Intent registerIntent = new Intent(this, RegistrationIntentService.class);
startService(registerIntent); startService(registerIntent);
} }
...@@ -234,7 +237,7 @@ public class LoginActivity extends AppCompatActivity { ...@@ -234,7 +237,7 @@ public class LoginActivity extends AppCompatActivity {
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i); startActivity(i);
progressDialog.dismiss();
//Save credentials in AccountManager to keep user logged in //Save credentials in AccountManager to keep user logged in
//Go to MainActivity //Go to MainActivity
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment