Location loader now loads the correct location.json according to the selected language

This commit is contained in:
Bart
2021-01-06 16:03:59 +01:00
parent dabe3cfb99
commit 98a1ad799c
3 changed files with 145 additions and 3 deletions

View File

@@ -21,7 +21,14 @@ public class LocationLoader implements Loader<List<Location>> {
public ArrayList<Location> load() {
FileIO<ArrayList<Location>> fileIO = new FileIO<>();
ArrayList<Location> res = fileIO.readFileData(context,"locations.json",new TypeToken<ArrayList<Location>>(){}.getType());
String selectedLanguage = context.getSharedPreferences("Settings", Context.MODE_PRIVATE).getString("Language", "nl");
String fileName = "locations";
// choose the locations.json based of the selectedLanguage
if (!selectedLanguage.equals("en")) {
fileName += "-" + selectedLanguage;
}
ArrayList<Location> res = fileIO.readFileData(context,fileName + ".json",new TypeToken<ArrayList<Location>>(){}.getType());
return res == null ? new ArrayList<>() : res;
}