Verified Commit 1987dcb9 authored by akwizgran's avatar akwizgran

Make field that's used on background thread volatile.

parent f3b69a26
......@@ -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();
......
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