diff --git a/briar-android/src/main/java/org/briarproject/briar/android/login/SetupControllerImpl.java b/briar-android/src/main/java/org/briarproject/briar/android/login/SetupControllerImpl.java index 6d12d55f163b3408e827a7aa344651981ca55db0..97814637bf7db30f53c646e93ffa4810b14b912f 100644 --- a/briar-android/src/main/java/org/briarproject/briar/android/login/SetupControllerImpl.java +++ b/briar-android/src/main/java/org/briarproject/briar/android/login/SetupControllerImpl.java @@ -26,7 +26,7 @@ public class SetupControllerImpl extends PasswordControllerImpl Logger.getLogger(SetupControllerImpl.class.getName()); @Nullable - private SetupActivity setupActivity; // TODO: Should be volatile + private volatile SetupActivity setupActivity; @Inject SetupControllerImpl(SharedPreferences briarPrefs, @@ -44,6 +44,7 @@ public class SetupControllerImpl extends PasswordControllerImpl @Override public boolean needToShowDozeFragment() { + SetupActivity setupActivity = this.setupActivity; if (setupActivity == null) throw new IllegalStateException(); return DozeView.needsToBeShown(setupActivity) || HuaweiView.needsToBeShown(setupActivity); @@ -51,31 +52,35 @@ public class SetupControllerImpl extends PasswordControllerImpl @Override public void setAuthorName(String authorName) { + SetupActivity setupActivity = this.setupActivity; if (setupActivity == null) throw new IllegalStateException(); setupActivity.setAuthorName(authorName); } @Override public void setPassword(String password) { + SetupActivity setupActivity = this.setupActivity; if (setupActivity == null) throw new IllegalStateException(); setupActivity.setPassword(password); } @Override public void showPasswordFragment() { + SetupActivity setupActivity = this.setupActivity; if (setupActivity == null) throw new IllegalStateException(); setupActivity.showPasswordFragment(); } @Override public void showDozeFragment() { + SetupActivity setupActivity = this.setupActivity; if (setupActivity == null) throw new IllegalStateException(); setupActivity.showDozeFragment(); } @Override public void createAccount() { - if (setupActivity == null) throw new IllegalStateException(); + SetupActivity setupActivity = this.setupActivity; UiResultHandler<Void> resultHandler = new UiResultHandler<Void>(setupActivity) { @Override @@ -90,6 +95,7 @@ public class SetupControllerImpl extends PasswordControllerImpl // Package access for testing void createAccount(ResultHandler<Void> resultHandler) { + SetupActivity setupActivity = this.setupActivity; if (setupActivity == null) throw new IllegalStateException(); String authorName = setupActivity.getAuthorName(); if (authorName == null) throw new IllegalStateException();