diff --git a/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java b/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java index bec94345cd..0cc015bb25 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java +++ b/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java @@ -307,7 +307,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper { newSegment = true; } else { float[] lastInterval = new float[1]; - Location.distanceBetween(lat, lon, lastPoint.getLatitude(), lastPoint.getLongitude(), lastInterval); + net.osmand.Location.distanceBetween(lat, lon, lastPoint.getLatitude(), lastPoint.getLongitude(), lastInterval); distance += lastInterval[0]; lastPoint = new LatLon(lat, lon); } diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java index 4431b4db35..488a7093dd 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java @@ -686,7 +686,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa if(loc != null){ mes = new float[2]; LatLon l = amenity.getLocation(); - Location.distanceBetween(l.getLatitude(), l.getLongitude(), loc.getLatitude(), loc.getLongitude(), mes); + net.osmand.Location.distanceBetween(l.getLatitude(), l.getLongitude(), loc.getLatitude(), loc.getLongitude(), mes); } int opened = -1; if (amenity.getOpeningHours() != null) { diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadIndexAdapter.java b/OsmAnd/src/net/osmand/plus/download/DownloadIndexAdapter.java index a447d86a46..d346d96739 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadIndexAdapter.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadIndexAdapter.java @@ -44,7 +44,6 @@ public class DownloadIndexAdapter extends OsmandBaseExpandableListAdapter implem list.clear(); list.addAll(cats); } - updateLoadedFiles(); okColor = downloadActivity.getResources().getColor(R.color.color_ok); TypedArray ta = downloadActivity.getTheme().obtainStyledAttributes(new int[]{android.R.attr.textColorPrimary}); defaultColor = ta.getColor(0, downloadActivity.getResources().getColor(R.color.color_unknown)); @@ -52,20 +51,10 @@ public class DownloadIndexAdapter extends OsmandBaseExpandableListAdapter implem updateColor = downloadActivity.getResources().getColor(R.color.color_update); } - public void updateLoadedFiles() { - indexActivatedFileNames = getMyApplication().getResourceManager().getIndexFileNames(); - DownloadIndexActivity.listWithAlternatives(getMyApplication().getAppPath(""), - IndexConstants.EXTRA_EXT, indexActivatedFileNames); - indexFileNames = getMyApplication().getResourceManager().getIndexFileNames(); - DownloadIndexActivity.listWithAlternatives(getMyApplication().getAppPath(""), - IndexConstants.EXTRA_EXT, indexFileNames); - DownloadIndexActivity.listWithAlternatives(getMyApplication().getAppPath(IndexConstants.TILES_INDEX_DIR), - IndexConstants.SQLITE_EXT, indexFileNames); - getMyApplication().getResourceManager().getBackupIndexes(indexFileNames); - } - - private OsmandApplication getMyApplication() { - return (OsmandApplication) downloadActivity.getApplication(); + public void setLoadedFiles(Map indexActivatedFileNames, Map indexFileNames) { + this.indexFileNames = indexFileNames; + this.indexActivatedFileNames = indexActivatedFileNames; + notifyDataSetInvalidated(); } public void collapseTrees(final CharSequence constraint) { @@ -93,14 +82,14 @@ public class DownloadIndexAdapter extends OsmandBaseExpandableListAdapter implem } - public synchronized void setIndexFiles(List indexFiles, Collection cats) { + public void setIndexFiles(List indexFiles, Collection cats) { this.indexFiles.clear(); this.indexFiles.addAll(indexFiles); - list.clear(); - list.addAll(cats); + list.clear(); + list.addAll(cats); notifyDataSetChanged(); } - + @Override public Filter getFilter() { if (myFilter == null) { diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java b/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java index 564008e1bf..631037da2e 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java @@ -8,6 +8,7 @@ import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -58,6 +59,8 @@ public class DownloadIndexesThread { private final static Log log = PlatformUtil.getLog(DownloadIndexesThread.class); private DownloadFileHelper downloadFileHelper; private List > currentRunningTask = Collections.synchronizedList(new ArrayList>()); + private Map indexFileNames = new LinkedHashMap(); + private Map indexActivatedFileNames = new LinkedHashMap(); public DownloadIndexesThread(Context ctx) { this.ctx = ctx; @@ -82,6 +85,20 @@ public class DownloadIndexesThread { public List getCachedIndexFiles() { return indexFiles != null ? indexFiles.getIndexFiles() : null; } + + public void updateLoadedFiles() { + Map indexActivatedFileNames = app.getResourceManager().getIndexFileNames(); + DownloadIndexActivity.listWithAlternatives(app.getAppPath(""), + IndexConstants.EXTRA_EXT, indexActivatedFileNames); + Map indexFileNames = app.getResourceManager().getIndexFileNames(); + DownloadIndexActivity.listWithAlternatives(app.getAppPath(""), + IndexConstants.EXTRA_EXT, indexFileNames); + DownloadIndexActivity.listWithAlternatives(app.getAppPath(IndexConstants.TILES_INDEX_DIR), + IndexConstants.SQLITE_EXT, indexFileNames); + app.getResourceManager().getBackupIndexes(indexFileNames); + this.indexFileNames = indexFileNames; + this.indexActivatedFileNames = indexActivatedFileNames; + } public boolean isDownloadedFromInternet() { return indexFiles != null && indexFiles.isDownloadedFromInternet(); @@ -150,10 +167,9 @@ public class DownloadIndexesThread { if (mainView != null) { mainView.setKeepScreenOn(false); } - updateLoadedFiles(); DownloadIndexAdapter adapter = ((DownloadIndexAdapter) uiActivity.getExpandableListAdapter()); if (adapter != null) { - adapter.notifyDataSetInvalidated(); + adapter.setLoadedFiles(indexActivatedFileNames, indexFileNames); } } currentRunningTask.remove(this); @@ -163,13 +179,6 @@ public class DownloadIndexesThread { } - private void updateLoadedFiles() { - if (uiActivity != null) { - ((DownloadIndexAdapter) uiActivity.getExpandableListAdapter()).notifyDataSetInvalidated(); - ((DownloadIndexAdapter) uiActivity.getExpandableListAdapter()).updateLoadedFiles(); - } - } - @Override protected String doInBackground(IndexItem... filesToDownload) { try { @@ -242,6 +251,7 @@ public class DownloadIndexesThread { warn = breakDownloadMessage; } } + updateLoadedFiles(); return warn; } catch (InterruptedException e) { log.info("Download Interrupted"); @@ -452,6 +462,7 @@ public class DownloadIndexesThread { protected List doInBackground(Void... params) { final List filtered = getFilteredByType(); cats = IndexItemCategory.categorizeIndexItems(app, filtered); + updateLoadedFiles(); return filtered; }; @@ -499,6 +510,7 @@ public class DownloadIndexesThread { protected void onPostExecute(List filtered) { if (uiActivity != null) { DownloadIndexAdapter a = ((DownloadIndexAdapter) uiActivity.getExpandableListAdapter()); + a.setLoadedFiles(indexActivatedFileNames, indexFileNames); a.setIndexFiles(filtered, cats); a.notifyDataSetChanged(); a.getFilter().filter(uiActivity.getFilterText()); diff --git a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java index 8527c997dc..471e2d0502 100644 --- a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java +++ b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java @@ -450,7 +450,7 @@ public class ParkingPositionPlugin extends OsmandPlugin { OsmandMapTileView view = map.getMapView(); int d = 0; if (d == 0) { - Location.distanceBetween(view.getLatitude(), view.getLongitude(), parkingPoint.getLatitude(), parkingPoint.getLongitude(), calculations); + net.osmand.Location.distanceBetween(view.getLatitude(), view.getLongitude(), parkingPoint.getLatitude(), parkingPoint.getLongitude(), calculations); d = (int) calculations[0]; } if (distChanged(cachedMeters, d)) { diff --git a/OsmAnd/src/net/osmand/plus/views/PointNavigationLayer.java b/OsmAnd/src/net/osmand/plus/views/PointNavigationLayer.java index 547a98efe3..82809af9bd 100644 --- a/OsmAnd/src/net/osmand/plus/views/PointNavigationLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/PointNavigationLayer.java @@ -20,7 +20,6 @@ import android.graphics.Paint.Align; import android.graphics.Paint.Style; import android.graphics.PointF; import android.graphics.RectF; -import android.location.Location; import android.util.DisplayMetrics; import android.view.WindowManager; @@ -115,7 +114,7 @@ public class PointNavigationLayer extends OsmandMapLayer implements IContextMenu canvas.rotate(-view.getRotate(), locationX, locationY); canvas.drawBitmap(targetPoint, locationX - marginX, locationY - marginY, bitmapPaint); } else if (pointToNavigate != null && view.getSettings().SHOW_DESTINATION_ARROW.get()) { - Location.distanceBetween(view.getLatitude(), view.getLongitude(), pointToNavigate.getLatitude(), + net.osmand.Location.distanceBetween(view.getLatitude(), view.getLongitude(), pointToNavigate.getLatitude(), pointToNavigate.getLongitude(), calculations); float bearing = calculations[1] - 90; float radiusBearing = DIST_TO_SHOW * dm.density;