From bce5500e27f3d380563ce886ddcd12672b22b32e Mon Sep 17 00:00:00 2001 From: cretin45 Date: Fri, 27 Feb 2015 17:23:27 -0800 Subject: [PATCH] SetupWizard: Make sure fragment is attached in callback Change-Id: Id492defa4c1d9bcad87311250a5f62fa046ee381 --- .../setupwizard/setup/CyanogenServicesPage.java | 12 +++++++++--- .../setupwizard/setup/GmsAccountPage.java | 10 ++++++++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/com/cyanogenmod/setupwizard/setup/CyanogenServicesPage.java b/src/com/cyanogenmod/setupwizard/setup/CyanogenServicesPage.java index 7db6eca..6d9e149 100644 --- a/src/com/cyanogenmod/setupwizard/setup/CyanogenServicesPage.java +++ b/src/com/cyanogenmod/setupwizard/setup/CyanogenServicesPage.java @@ -127,9 +127,15 @@ public class CyanogenServicesPage extends SetupPage { ActivityOptions.makeCustomAnimation(mContext, android.R.anim.fade_in, android.R.anim.fade_out); - mFragment.startActivityForResult(intent, - SetupWizardApp.REQUEST_CODE_SETUP_CYANOGEN, - options.toBundle()); + if (!mFragment.isDetached()) { + mFragment.startActivityForResult(intent, + SetupWizardApp.REQUEST_CODE_SETUP_CYANOGEN, + options.toBundle()); + } else { + if (getCallbacks().isCurrentPage(CyanogenServicesPage.this)) { + getCallbacks().onNextPage(); + } + } } catch (OperationCanceledException e) { } catch (IOException e) { } catch (AuthenticatorException e) { diff --git a/src/com/cyanogenmod/setupwizard/setup/GmsAccountPage.java b/src/com/cyanogenmod/setupwizard/setup/GmsAccountPage.java index 20f25c1..a897db0 100644 --- a/src/com/cyanogenmod/setupwizard/setup/GmsAccountPage.java +++ b/src/com/cyanogenmod/setupwizard/setup/GmsAccountPage.java @@ -203,8 +203,14 @@ public class GmsAccountPage extends SetupPage { ActivityOptions.makeCustomAnimation(mContext, android.R.anim.fade_in, android.R.anim.fade_out); - mFragment.startActivityForResult(intent, - SetupWizardApp.REQUEST_CODE_SETUP_GMS, options.toBundle()); + if (!mFragment.isDetached()) { + mFragment.startActivityForResult(intent, + SetupWizardApp.REQUEST_CODE_SETUP_GMS, options.toBundle()); + } else { + if (getCallbacks().isCurrentPage(GmsAccountPage.this)) { + getCallbacks().onNextPage(); + } + } } catch (OperationCanceledException e) { } catch (IOException e) { } catch (AuthenticatorException e) {