From 2628eceb6b7548d151ab61c42969b42064e586bd Mon Sep 17 00:00:00 2001 From: masensio Date: Fri, 28 Mar 2014 15:04:10 +0100 Subject: [PATCH] Modify DetectAuthenticationMethodOperation so that , when returning its result through the callback, there is no crash if AuthenticatorActivity is not ready (rotating) --- .../authentication/AuthenticatorActivity.java | 21 +++++++++++++++++++ .../android/ui/activity/FileActivity.java | 8 +++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/com/owncloud/android/authentication/AuthenticatorActivity.java b/src/com/owncloud/android/authentication/AuthenticatorActivity.java index cf76883328..074751e63a 100644 --- a/src/com/owncloud/android/authentication/AuthenticatorActivity.java +++ b/src/com/owncloud/android/authentication/AuthenticatorActivity.java @@ -537,6 +537,27 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { } } + + @Override + protected void onStart() { + if (mOperationsServiceBinder != null) { + mOperationsServiceBinder.addOperationListener(AuthenticatorActivity.this, mHandler); + } + + super.onStart(); + } + + + @Override + protected void onStop() { + if (mOperationsServiceBinder != null) { + mOperationsServiceBinder.removeOperationListener(this); + } + super.onStop(); + } + + + /** * The redirection triggered by the OAuth authentication server as response to the GET AUTHORIZATION, and * deferred in {@link #onNewIntent(Intent)}, is processed here. diff --git a/src/com/owncloud/android/ui/activity/FileActivity.java b/src/com/owncloud/android/ui/activity/FileActivity.java index 42b90aec17..c4dd28a2b7 100644 --- a/src/com/owncloud/android/ui/activity/FileActivity.java +++ b/src/com/owncloud/android/ui/activity/FileActivity.java @@ -150,22 +150,26 @@ public class FileActivity extends SherlockFragmentActivity implements OnRemoteOp @Override protected void onStart() { - super.onStart(); + if (mAccountWasSet) { onAccountSet(mAccountWasRestored); } if (mOperationsServiceBinder != null) { mOperationsServiceBinder.addOperationListener(FileActivity.this, mHandler); } + + super.onStart(); } @Override protected void onStop() { - super.onStop(); + if (mOperationsServiceBinder != null) { mOperationsServiceBinder.removeOperationListener(this); } + + super.onStop(); }