Fix location issue and fix download issue

This commit is contained in:
Victor Shcherb 2013-06-06 23:04:25 +02:00
parent 93e2cd2e2e
commit 6ec7c0b33e
6 changed files with 33 additions and 33 deletions

View file

@ -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);
}

View file

@ -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) {

View file

@ -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<String, String> indexActivatedFileNames, Map<String, String> indexFileNames) {
this.indexFileNames = indexFileNames;
this.indexActivatedFileNames = indexActivatedFileNames;
notifyDataSetInvalidated();
}
public void collapseTrees(final CharSequence constraint) {
@ -93,11 +82,11 @@ public class DownloadIndexAdapter extends OsmandBaseExpandableListAdapter implem
}
public synchronized void setIndexFiles(List<IndexItem> indexFiles, Collection<? extends IndexItemCategory> cats) {
public void setIndexFiles(List<IndexItem> indexFiles, Collection<? extends IndexItemCategory> cats) {
this.indexFiles.clear();
this.indexFiles.addAll(indexFiles);
list.clear();
list.addAll(cats);
list.clear();
list.addAll(cats);
notifyDataSetChanged();
}

View file

@ -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<BasicProgressAsyncTask<?, ?, ?> > currentRunningTask = Collections.synchronizedList(new ArrayList<BasicProgressAsyncTask<?, ?, ?>>());
private Map<String, String> indexFileNames = new LinkedHashMap<String, String>();
private Map<String, String> indexActivatedFileNames = new LinkedHashMap<String, String>();
public DownloadIndexesThread(Context ctx) {
this.ctx = ctx;
@ -83,6 +86,20 @@ public class DownloadIndexesThread {
return indexFiles != null ? indexFiles.getIndexFiles() : null;
}
public void updateLoadedFiles() {
Map<String, String> indexActivatedFileNames = app.getResourceManager().getIndexFileNames();
DownloadIndexActivity.listWithAlternatives(app.getAppPath(""),
IndexConstants.EXTRA_EXT, indexActivatedFileNames);
Map<String, String> 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<IndexItem> doInBackground(Void... params) {
final List<IndexItem> filtered = getFilteredByType();
cats = IndexItemCategory.categorizeIndexItems(app, filtered);
updateLoadedFiles();
return filtered;
};
@ -499,6 +510,7 @@ public class DownloadIndexesThread {
protected void onPostExecute(List<IndexItem> filtered) {
if (uiActivity != null) {
DownloadIndexAdapter a = ((DownloadIndexAdapter) uiActivity.getExpandableListAdapter());
a.setLoadedFiles(indexActivatedFileNames, indexFileNames);
a.setIndexFiles(filtered, cats);
a.notifyDataSetChanged();
a.getFilter().filter(uiActivity.getFilterText());

View file

@ -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)) {

View file

@ -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;