Merge branch 'languages' into develop
This commit is contained in:
10
app/src/main/assets/coupons-nl.json
Normal file
10
app/src/main/assets/coupons-nl.json
Normal file
@@ -0,0 +1,10 @@
|
||||
[
|
||||
{
|
||||
"code": "KROKET10",
|
||||
"reward": "Gratis 2e kroket bij Kees Kroket™"
|
||||
},
|
||||
{
|
||||
"code": "654",
|
||||
"reward": ",juygly"
|
||||
}
|
||||
]
|
||||
40
app/src/main/assets/routes-nl.json
Normal file
40
app/src/main/assets/routes-nl.json
Normal file
@@ -0,0 +1,40 @@
|
||||
[
|
||||
{
|
||||
"name": "rondje stad",
|
||||
"locations": [
|
||||
{
|
||||
"name":"Prison Escape Kloosterlaan 168",
|
||||
"coordinates":"51.59073795635181,4.784917104321059",
|
||||
"description":"4811EE Breda",
|
||||
"imageUrl":"NULL"
|
||||
},
|
||||
{
|
||||
"name":"De Koepel - FutureDome Events Nassausingel 26",
|
||||
"coordinates":"51.590431588532105,4.786756741648511",
|
||||
"description":"4811HP Breda",
|
||||
"imageUrl":"NULL"
|
||||
},
|
||||
|
||||
{
|
||||
"name":"Escaping Breda: Escape Room Games Boschstraat 114",
|
||||
"coordinates":" 51.59110835530862,4.784147222780912",
|
||||
"description":"4811GK Breda",
|
||||
"imageUrl":"NULL"
|
||||
},
|
||||
{
|
||||
"name":"MEZZ Breda Keizerstraat 101",
|
||||
"coordinates":"51.58394697737321,4.779757901349616",
|
||||
"description":"4811HL Breda",
|
||||
"imageUrl":"NULL"
|
||||
},
|
||||
{
|
||||
"name":"Het Klooster Breda Schorsmolenstraat 13",
|
||||
"coordinates":"51.58775443759389,4.765568874365066",
|
||||
"description":"4811VN Breda",
|
||||
"imageUrl":"NULL"
|
||||
}
|
||||
],
|
||||
"totalDistance": 2.3434,
|
||||
"totalTime": 342342
|
||||
}
|
||||
]
|
||||
@@ -24,6 +24,7 @@ import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class FileIO<T> {
|
||||
private final String TAG = FileIO.class.getCanonicalName();
|
||||
@@ -34,8 +35,14 @@ public class FileIO<T> {
|
||||
AssetManager am = context.getAssets();
|
||||
T res = null;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
InputStream is = null;
|
||||
try {
|
||||
InputStream is = am.open(fileName);
|
||||
if (Arrays.asList(context.getResources().getAssets().list("")).contains(fileName)) {
|
||||
is = am.open(fileName);
|
||||
Log.d(TAG, "Opening file: " + fileName);
|
||||
} else {
|
||||
is = am.open(fileName.substring(0, fileName.length() - 8) + ".json");
|
||||
}
|
||||
InputStreamReader inputStreamReader = new InputStreamReader(is);
|
||||
BufferedReader reader = new BufferedReader(inputStreamReader);
|
||||
String line;
|
||||
|
||||
@@ -25,7 +25,14 @@ public class CouponLoader implements Loader<List<Coupon>> {
|
||||
@Override
|
||||
public ArrayList<Coupon> load() {
|
||||
FileIO<ArrayList<Coupon>> fileIO = new FileIO<>();
|
||||
ArrayList<Coupon> res = fileIO.readFileData(context, "coupons.json",new TypeToken<ArrayList<Coupon>>(){}.getType());
|
||||
|
||||
String selectedLanguage = context.getSharedPreferences("Settings", Context.MODE_PRIVATE).getString("Language", "nl");
|
||||
String fileName = "locations";
|
||||
// choose the coupon.json based of the selected language
|
||||
if (!selectedLanguage.equals("en")) {
|
||||
fileName += "-" + selectedLanguage;
|
||||
}
|
||||
ArrayList<Coupon> res = fileIO.readFileData(context, fileName + ".json", new TypeToken<ArrayList<Coupon>>(){}.getType());
|
||||
Log.d(TAG, "load: " + res);
|
||||
|
||||
return res == null ? new ArrayList<>() : res;
|
||||
|
||||
@@ -27,7 +27,7 @@ public class LocationLoader implements Loader<List<Location>> {
|
||||
|
||||
String selectedLanguage = context.getSharedPreferences("Settings", Context.MODE_PRIVATE).getString("Language", "nl");
|
||||
String fileName = "locations";
|
||||
// choose the locations.json based of the selectedLanguage
|
||||
// choose the locations.json based of the selected language
|
||||
if (!selectedLanguage.equals("en")) {
|
||||
fileName += "-" + selectedLanguage;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,15 @@ public class RouteLoader implements Loader<List<Route>> {
|
||||
public ArrayList<Route> load() {
|
||||
|
||||
FileIO<ArrayList<Route>> fileIO = new FileIO<>();
|
||||
ArrayList<Route> res = fileIO.readFileData(context, "routes.json",new TypeToken<ArrayList<Route>>(){}.getType());
|
||||
|
||||
String selectedLanguage = context.getSharedPreferences("Settings", Context.MODE_PRIVATE).getString("Language", "nl");
|
||||
String fileName = "routes";
|
||||
// choose the routes.json based of the selected language
|
||||
if (!selectedLanguage.equals("en")) {
|
||||
fileName += "-" + selectedLanguage;
|
||||
}
|
||||
|
||||
ArrayList<Route> res = fileIO.readFileData(context, fileName + ".json",new TypeToken<ArrayList<Route>>(){}.getType());
|
||||
return res == null ? new ArrayList<>() : res;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user