diff options
author | jandegr <jandegr@users.noreply.github.com> | 2018-05-28 17:59:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-28 17:59:22 +0200 |
commit | 0bb580a30f39e9267c433b29fe5366f071147351 (patch) | |
tree | 7123a79e09e3dd9b87fa5c072c8ffca008e051d0 | |
parent | bc1bc1a4dea91192f9cb9ebd86105516b96f9bf8 (diff) | |
download | navit-0bb580a30f39e9267c433b29fe5366f071147351.tar.gz |
refactor-cleanup
-rw-r--r-- | navit/android/src/org/navitproject/navit/NavitDownloadSelectMapActivity.java | 86 |
1 files changed, 40 insertions, 46 deletions
diff --git a/navit/android/src/org/navitproject/navit/NavitDownloadSelectMapActivity.java b/navit/android/src/org/navitproject/navit/NavitDownloadSelectMapActivity.java index 10805d467..61ff87762 100644 --- a/navit/android/src/org/navitproject/navit/NavitDownloadSelectMapActivity.java +++ b/navit/android/src/org/navitproject/navit/NavitDownloadSelectMapActivity.java @@ -44,7 +44,7 @@ public class NavitDownloadSelectMapActivity extends ExpandableListActivity { private static ArrayList<HashMap<String, String>> downloaded_maps_childs = null; private static ArrayList<HashMap<String, String>> maps_current_position_childs = null; private static boolean currentLocationKnown = false; - private final String TAG = this.getClass().getName(); + private static final String TAG = NavitDownloadSelectMapActivity.class.getName(); @Override public void onCreate(Bundle savedInstanceState) { @@ -60,12 +60,10 @@ public class NavitDownloadSelectMapActivity extends ExpandableListActivity { setTitle(String.valueOf(getFreeSpace() / 1024 / 1024) + "MB available"); } catch (Exception e) { Log.e(TAG, "Exception " + e.getClass().getName() - + " during getFreeSpace, reporting 'no sdcard present'"); - NavitDialogs.sendDialogMessage(NavitDialogs.MSG_TOAST_LONG, null, - String.format( - (Navit.getInstance().getTstring(R.string.map_location_unavailable)), - Navit.map_filename_path), - -1, 0, 0); + + " during getFreeSpace, reporting 'no sdcard present'"); + NavitDialogs.sendDialogMessage(NavitDialogs.MSG_TOAST_LONG, null, String.format + ((Navit.getInstance().getTstring(R.string.map_location_unavailable)), + Navit.map_filename_path), -1, 0, 0); finish(); } } @@ -78,14 +76,14 @@ public class NavitDownloadSelectMapActivity extends ExpandableListActivity { private void updateDownloadedMaps() { downloaded_maps_childs.clear(); for (NavitMap map : NavitMapDownloader.getAvailableMaps()) { - HashMap<String, String> child = new HashMap<String, String>(); - child.put("map_name", map.mapName + " " + (map.size() / 1024 / 1024) + "MB"); + HashMap<String, String> child = new HashMap<>(); + child.put("map_name", map.mMapName + " " + (map.size() / 1024 / 1024) + "MB"); child.put("map_location", map.getLocation()); downloaded_maps_childs.add(child); } } - private void updateMapsForLocation(NavitMapDownloader.osm_map_values[] osm_maps) { + private void updateMapsForLocation(NavitMapDownloader.osm_map_values[] osmMaps) { Location currentLocation = NavitVehicle.lastLocation; if (maps_current_position_childs.size() == 0 || (currentLocation != null && !currentLocationKnown)) { @@ -120,14 +118,13 @@ public class NavitDownloadSelectMapActivity extends ExpandableListActivity { if (currentLocation != null) { // if this map contains data to our current position, add it to // the MapsOfCurrentLocation-list - for (int currentMapIndex = 0; currentMapIndex < osm_maps.length; + for (int currentMapIndex = 0; currentMapIndex < osmMaps.length; currentMapIndex++) { - if (osm_maps[currentMapIndex].isInMap(currentLocation)) { - HashMap<String, String> currentPositionMapChild = new HashMap<String, String>(); + if (osmMaps[currentMapIndex].isInMap(currentLocation)) { + HashMap<String, String> currentPositionMapChild = new HashMap<>(); currentPositionMapChild - .put("map_name", osm_maps[currentMapIndex].map_name + " " - + (osm_maps[currentMapIndex].est_size_bytes / 1024 / 1024) - + "MB"); + .put("map_name", osmMaps[currentMapIndex].map_name + " " + + (osmMaps[currentMapIndex].est_size_bytes / 1024 / 1024) + "MB"); currentPositionMapChild.put("map_index", String.valueOf(currentMapIndex)); maps_current_position_childs.add(currentPositionMapChild); @@ -139,45 +136,45 @@ public class NavitDownloadSelectMapActivity extends ExpandableListActivity { private SimpleExpandableListAdapter createAdapter() { - NavitMapDownloader.osm_map_values[] osm_maps = NavitMapDownloader.osm_maps; + NavitMapDownloader.osm_map_values[] osmMaps = NavitMapDownloader.osm_maps; - ArrayList<HashMap<String, String>> resultGroups = new ArrayList<HashMap<String, String>>(); + ArrayList<HashMap<String, String>> resultGroups = new ArrayList<>(); ArrayList<ArrayList<HashMap<String, String>>> resultChilds = - new ArrayList<ArrayList<HashMap<String, String>>>(); + new ArrayList<>(); // add already downloaded maps (group and empty child list - HashMap<String, String> downloaded_maps_hash = new HashMap<String, String>(); + HashMap<String, String> downloaded_maps_hash = new HashMap<>(); downloaded_maps_hash .put("category_name", Navit.getInstance().getTstring(R.string.maps_installed)); resultGroups.add(downloaded_maps_hash); - downloaded_maps_childs = new ArrayList<HashMap<String, String>>(); + downloaded_maps_childs = new ArrayList<>(); resultChilds.add(downloaded_maps_childs); - ArrayList<HashMap<String, String>> secList = new ArrayList<HashMap<String, String>>(); - maps_current_position_childs = new ArrayList<HashMap<String, String>>(); + ArrayList<HashMap<String, String>> secList = new ArrayList<>(); + maps_current_position_childs = new ArrayList<>(); // maps containing the current location - HashMap<String, String> matching_maps = new HashMap<String, String>(); + HashMap<String, String> matching_maps = new HashMap<>(); matching_maps.put("category_name", Navit.getInstance().getTstring(R.string.maps_for_current_location)); resultGroups.add(matching_maps); resultChilds.add(maps_current_position_childs); // add all maps - for (int currentMapIndex = 0; currentMapIndex < osm_maps.length; currentMapIndex++) { - if (osm_maps[currentMapIndex].level == 0) { + for (int currentMapIndex = 0; currentMapIndex < osmMaps.length; currentMapIndex++) { + if (osmMaps[currentMapIndex].level == 0) { if (secList.size() > 0) { resultChilds.add(secList); } - secList = new ArrayList<HashMap<String, String>>(); - HashMap<String, String> map_info_hash = new HashMap<String, String>(); - map_info_hash.put("category_name", osm_maps[currentMapIndex].map_name); + secList = new ArrayList<>(); + HashMap<String, String> map_info_hash = new HashMap<>(); + map_info_hash.put("category_name", osmMaps[currentMapIndex].map_name); resultGroups.add(map_info_hash); } - HashMap<String, String> child = new HashMap<String, String>(); - child.put("map_name", (osm_maps[currentMapIndex].level > 1 ? MAP_BULLETPOINT : "") - + osm_maps[currentMapIndex].map_name + " " - + (osm_maps[currentMapIndex].est_size_bytes / 1024 / 1024) + "MB"); + HashMap<String, String> child = new HashMap<>(); + child.put("map_name", (osmMaps[currentMapIndex].level > 1 ? MAP_BULLETPOINT : "") + + osmMaps[currentMapIndex].map_name + " " + + (osmMaps[currentMapIndex].est_size_bytes / 1024 / 1024) + "MB"); child.put("map_index", String.valueOf(currentMapIndex)); secList.add(child); @@ -221,27 +218,24 @@ public class NavitDownloadSelectMapActivity extends ExpandableListActivity { return true; } - private void askForMapDeletion(final String map_location) { + private void askForMapDeletion(final String mapLocation) { AlertDialog.Builder deleteMapBox = new AlertDialog.Builder(this); deleteMapBox.setTitle(Navit.getInstance().getTstring(R.string.map_delete)); deleteMapBox.setCancelable(true); - NavitMap maptoDelete = new NavitMap(map_location); - deleteMapBox.setMessage( - maptoDelete.mapName + " " + String.valueOf(maptoDelete.size() / 1024 / 1024) - + "MB"); + NavitMap maptoDelete = new NavitMap(mapLocation); + deleteMapBox.setMessage( maptoDelete.mMapName + " " + String.valueOf(maptoDelete.size() / 1024 / 1024) + "MB"); // TRANS deleteMapBox.setPositiveButton(Navit.getInstance().getTstring(R.string.yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { Log.d(TAG, "Delete Map"); - Message msg = - Message.obtain( + Message msg = Message.obtain( Navit.getInstance().getNavitGraphics().callback_handler, NavitGraphics.msg_type.CLB_DELETE_MAP.ordinal()); Bundle b = new Bundle(); - b.putString("title", map_location); + b.putString("title", mapLocation); msg.setData(b); msg.sendToTarget(); finish(); @@ -250,11 +244,11 @@ public class NavitDownloadSelectMapActivity extends ExpandableListActivity { // TRANS deleteMapBox.setNegativeButton((Navit.getInstance().getTstring(R.string.no)), - new DialogInterface.OnClickListener() { - public void onClick(DialogInterface arg0, int arg1) { - Log.d(TAG, "don't delete map"); - } - }); + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface arg0, int arg1) { + Log.d(TAG, "don't delete map"); + } + }); deleteMapBox.show(); } } |