use of com.peterlaurence.trekadvisor.core.map.gson.MapGson in project TrekAdvisor by peterLaurence.
the class MapUpdateTask method doInBackground.
@Override
protected Void doInBackground(File... dirs) {
/* Search for json files */
for (File dir : dirs) {
findMaps(dir, 1);
}
/* Now parse the json files found */
for (File f : mapFilesFoundList) {
/* Get json file content as String */
String jsonString;
try {
jsonString = FileUtils.getStringFromFile(f);
} catch (Exception e) {
// Error while decoding the json file
Log.e(TAG, e.getMessage(), e);
continue;
}
try {
/* json deserialization */
MapGson mapGson = mGson.fromJson(jsonString, MapGson.class);
/* Map creation */
Map map = mapGson.thumbnail == null ? new Map(mapGson, f, null) : new Map(mapGson, f, new File(f.getParent(), mapGson.thumbnail));
/* Calibration */
map.calibrate();
/* Set BitMapProvider */
map.setBitmapProvider(MapLoader.makeBitmapProvider(map));
mMapList.add(map);
} catch (JsonSyntaxException | NullPointerException e) {
Log.e(TAG, e.getMessage(), e);
}
}
return null;
}
Aggregations