Permalink
Browse files

Let the user cancel the Login dialog and change their info

  • Loading branch information...
1 parent 5833a42 commit 48ee9ac81c8e861ef75a2fd0f9e07d0ab6faf3bd @konklone konklone committed Jan 2, 2010
Showing with 15 additions and 4 deletions.
  1. +15 −4 src/com/github/klondike/android/campfire/Login.java
@@ -2,6 +2,7 @@
import android.app.Activity;
import android.app.ProgressDialog;
+import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.AsyncTask;
@@ -84,10 +85,20 @@ public void onClick(View v) {
}
public void loadingDialog() {
- dialog = new ProgressDialog(this);
- dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
- dialog.setMessage("Logging in...");
- dialog.setCancelable(false);
+ dialog = new ProgressDialog(this);
+ dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
+ dialog.setMessage("Logging in...");
+
+ dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
+ @Override
+ public void onCancel(DialogInterface dialog) {
+ if (loginTask != null) {
+ loginTask.cancel(true);
+ loginTask = null; // so that the button will work again
+ }
+ }
+ });
+
dialog.show();
}

0 comments on commit 48ee9ac

Please sign in to comment.