private void updateLocalVersions() { if (NavigineApp.Navigation == null) return; for (int i = 0; i < mInfoList.size(); ++i) { LocationInfo info = mInfoList.get(i); String versionStr = LocationLoader.getLocalVersion(NavigineApp.AppContext, info.title); if (versionStr != null) { // Log.d(TAG, info.title + ": " + versionStr); info.localModified = versionStr.endsWith("+"); if (info.localModified) versionStr = versionStr.substring(0, versionStr.length() - 1); try { info.localVersion = Integer.parseInt(versionStr); } catch (Throwable e) { } } else { info.localVersion = -1; String mapFile = NavigineApp.Settings.getString("map_file", ""); if (mapFile.equals(info.archiveFile)) { NavigineApp.Navigation.loadArchive(null); SharedPreferences.Editor editor = NavigineApp.Settings.edit(); editor.putString("map_file", ""); editor.commit(); } } } mAdapter.updateList(); }
private void deleteLocation(LocationInfo info) { if (NavigineApp.Navigation == null) return; if (info != null) { try { (new File(info.archiveFile)).delete(); info.localVersion = -1; info.localModified = false; String locationDir = LocationLoader.getLocationDir(mContext, info.title); File dir = new File(locationDir); File[] files = dir.listFiles(); for (int i = 0; i < files.length; ++i) files[i].delete(); dir.delete(); String mapFile = NavigineApp.Settings.getString("map_file", ""); if (mapFile.equals(info.archiveFile)) { NavigineApp.Navigation.loadArchive(null); SharedPreferences.Editor editor = NavigineApp.Settings.edit(); editor.putString("map_file", ""); editor.commit(); } mAdapter.updateList(); } catch (Throwable e) { Log.e(TAG, Log.getStackTraceString(e)); } } }