Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
7cd732effa
1 changed files with 37 additions and 17 deletions
|
@ -65,14 +65,22 @@ public class DashFavoritesFragment extends DashBaseFragment {
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
if (getMyApplication().getFavorites().getFavouritePoints().size() > 0) {
|
|
||||||
if(!getMyApplication().getSettings().isLastKnownMapLocation()) {
|
//'location' seems actually not needed in this Fragment, as both setupFavorites and updateArrow only reference lastKnownMapLocation
|
||||||
// show first time when application ran
|
//if (getMyApplication().getFavorites().getFavouritePoints().size() > 0) {
|
||||||
location = getMyApplication().getLocationProvider().getFirstTimeRunDefaultLocation();
|
// if(!getMyApplication().getSettings().isLastKnownMapLocation()) {
|
||||||
|
// // show first time when application ran
|
||||||
|
// location = getMyApplication().getLocationProvider().getFirstTimeRunDefaultLocation();
|
||||||
|
// } else {
|
||||||
|
// location = getLocationProvider().getLastKnownLocation();
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
//This is used as origin for both Fav-list and direction arrows
|
||||||
|
if (getMyApplication().getSettings().getLastKnownMapLocation() != null) {
|
||||||
|
loc = getMyApplication().getSettings().getLastKnownMapLocation();
|
||||||
} else {
|
} else {
|
||||||
location = getLocationProvider().getLastKnownLocation();
|
loc = new LatLon(0f, 0f);
|
||||||
}
|
|
||||||
updateLocation(location);
|
|
||||||
}
|
}
|
||||||
setupFavorites();
|
setupFavorites();
|
||||||
}
|
}
|
||||||
|
@ -90,14 +98,15 @@ public class DashFavoritesFragment extends DashBaseFragment {
|
||||||
} else {
|
} else {
|
||||||
(mainView.findViewById(R.id.main_fav)).setVisibility(View.VISIBLE);
|
(mainView.findViewById(R.id.main_fav)).setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
Collections.sort(points, new Comparator<FavouritePoint>() {
|
Collections.sort(points, new Comparator<FavouritePoint>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(FavouritePoint point, FavouritePoint point2) {
|
public int compare(FavouritePoint point, FavouritePoint point2) {
|
||||||
LatLon lastKnownMapLocation = getMyApplication().getSettings().getLastKnownMapLocation();
|
//LatLon lastKnownMapLocation = getMyApplication().getSettings().getLastKnownMapLocation();
|
||||||
int dist = (int) (MapUtils.getDistance(point.getLatitude(), point.getLongitude(),
|
int dist = (int) (MapUtils.getDistance(point.getLatitude(), point.getLongitude(),
|
||||||
lastKnownMapLocation.getLatitude(), lastKnownMapLocation.getLongitude()));
|
loc.getLatitude(), loc.getLongitude()));
|
||||||
int dist2 = (int) (MapUtils.getDistance(point2.getLatitude(), point2.getLongitude(),
|
int dist2 = (int) (MapUtils.getDistance(point2.getLatitude(), point2.getLongitude(),
|
||||||
lastKnownMapLocation.getLatitude(), lastKnownMapLocation.getLongitude()));
|
loc.getLatitude(), loc.getLongitude()));
|
||||||
return (dist - dist2);
|
return (dist - dist2);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -123,9 +132,9 @@ public class DashFavoritesFragment extends DashBaseFragment {
|
||||||
arrows.add(direction);
|
arrows.add(direction);
|
||||||
name.setText(point.getName());
|
name.setText(point.getName());
|
||||||
icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(getActivity(), point.getColor()));
|
icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(getActivity(), point.getColor()));
|
||||||
LatLon lastKnownMapLocation = getMyApplication().getSettings().getLastKnownMapLocation();
|
//LatLon lastKnownMapLocation = getMyApplication().getSettings().getLastKnownMapLocation();
|
||||||
int dist = (int) (MapUtils.getDistance(point.getLatitude(), point.getLongitude(),
|
int dist = (int) (MapUtils.getDistance(point.getLatitude(), point.getLongitude(),
|
||||||
lastKnownMapLocation.getLatitude(), lastKnownMapLocation.getLongitude()));
|
loc.getLatitude(), loc.getLongitude()));
|
||||||
String distance = OsmAndFormatter.getFormattedDistance(dist, getMyApplication()) + " ";
|
String distance = OsmAndFormatter.getFormattedDistance(dist, getMyApplication()) + " ";
|
||||||
view.findViewById(R.id.navigate_to).setOnClickListener(new View.OnClickListener() {
|
view.findViewById(R.id.navigate_to).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -145,6 +154,7 @@ public class DashFavoritesFragment extends DashBaseFragment {
|
||||||
});
|
});
|
||||||
favorites.addView(view);
|
favorites.addView(view);
|
||||||
}
|
}
|
||||||
|
updateLocation(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateArrows() {
|
private void updateArrows() {
|
||||||
|
@ -175,14 +185,24 @@ public class DashFavoritesFragment extends DashBaseFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateLocation(Location location) {
|
public void updateLocation(Location location) {
|
||||||
if (location != null) {
|
//'location' seems actually not needed in this Fragment, as both setupFavorites and updateArrow only reference lastKnownMapLocation
|
||||||
|
//if (location != null) {
|
||||||
//this.location = location;
|
//this.location = location;
|
||||||
loc = new LatLon(location.getLatitude(), location.getLongitude());
|
//Next line commented out so that reference is always lastKnownMapLocation, because this is also always used as reference in setupFavorites
|
||||||
} else if (getMyApplication().getSettings().getLastKnownMapLocation() != null) {
|
// loc = new LatLon(location.getLatitude(), location.getLongitude());
|
||||||
|
//} else if (getMyApplication().getSettings().getLastKnownMapLocation() != null) {
|
||||||
|
// loc = getMyApplication().getSettings().getLastKnownMapLocation();
|
||||||
|
//} else {
|
||||||
|
// return;
|
||||||
|
//}
|
||||||
|
|
||||||
|
//This is used as origin for both Fav-list and direction arrows
|
||||||
|
if (getMyApplication().getSettings().getLastKnownMapLocation() != null) {
|
||||||
loc = getMyApplication().getSettings().getLastKnownMapLocation();
|
loc = getMyApplication().getSettings().getLastKnownMapLocation();
|
||||||
} else {
|
} else {
|
||||||
return;
|
loc = new LatLon(0f, 0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.loc = loc;
|
this.loc = loc;
|
||||||
updateArrows();
|
updateArrows();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue