Skip to content

Commit

Permalink
code improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
chaneylc committed Jul 12, 2023
1 parent eb8381a commit 7143d28
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,8 @@ public class ConfigActivity extends ThemedActivity {
@Inject
public DataHelper database;
@Inject
public FieldSwitchImpl fieldSwitcher;
@Inject
public SoundHelperImpl soundHelper;
public FieldSwitchImpl fieldSwitcher = null;
Handler mHandler = new Handler();
boolean doubleBackToExitPressedOnce = false;
ListView settingsList;
Expand Down Expand Up @@ -341,6 +340,9 @@ private void loadScreen() {
.initiateScan();
});

//this must happen after migrations and can't be injected in config
fieldSwitcher = new FieldSwitchImpl(this);

}

/**
Expand Down Expand Up @@ -991,6 +993,10 @@ public void selectFirstField() {
*/
private void switchField(int studyId) {

if (fieldSwitcher == null) {
fieldSwitcher = new FieldSwitchImpl(this);
}

fieldSwitcher.switchField(studyId);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ class FieldSwitchImpl @Inject constructor(@ActivityContext private val context:
}

override fun switchField(studyId: Int) {
if (!::database.isInitialized) {
database = DataHelper(context)
}
val f = database.getFieldObject(studyId)
switchField(f)
}
Expand Down

0 comments on commit 7143d28

Please sign in to comment.