Skip to content

Commit

Permalink
fix unique/primary/secondary ids when reloading with new study
Browse files Browse the repository at this point in the history
  • Loading branch information
chaneylc committed Jul 10, 2023
1 parent 3b6f4ba commit 3f1c6b0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,13 @@ private void switchField(int studyId, String fieldName, @Nullable String obsUnit
//updates obs. range view in database
database.switchField(studyId);

//rangeBox.setAllRangeID();
FieldObject fo = database.getFieldObject(studyId);

ep.edit().putString(GeneralKeys.UNIQUE_NAME, fo.getUnique_id()).apply();
ep.edit().putString(GeneralKeys.PRIMARY_NAME, fo.getPrimary_id()).apply();
ep.edit().putString(GeneralKeys.SECONDARY_NAME, fo.getSecondary_id()).apply();

rangeBox.setAllRangeID();
int[] rangeID = rangeBox.getRangeID();

//refresh collect activity UI
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/java/com/fieldbook/tracker/views/RangeBoxView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,11 @@ class RangeBoxView : ConstraintLayout {
}

fun reload() {

firstName = controller.getPreferences().getString(GeneralKeys.PRIMARY_NAME, "") ?: ""
secondName = controller.getPreferences().getString(GeneralKeys.SECONDARY_NAME, "") ?: ""
uniqueName = controller.getPreferences().getString(GeneralKeys.UNIQUE_NAME, "") ?: ""

switchVisibility(controller.getPreferences().getBoolean(GeneralKeys.QUICK_GOTO, false))
setName(8)
paging = 1
Expand Down

0 comments on commit 3f1c6b0

Please sign in to comment.