merge and hotfix
This commit is contained in:
commit
6582bbf42a
2 changed files with 19 additions and 25 deletions
|
@ -1,11 +1,9 @@
|
||||||
package net.osmand.plus.routepointsnavigation;
|
package net.osmand.plus.routepointsnavigation;
|
||||||
|
|
||||||
import android.annotation.TargetApi;
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.format.DateFormat;
|
import android.text.format.DateFormat;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
@ -25,6 +23,7 @@ import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Bars on 13.06.2014.
|
* Created by Bars on 13.06.2014.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public class RoutePointsActivity extends OsmandListActivity {
|
public class RoutePointsActivity extends OsmandListActivity {
|
||||||
|
|
||||||
|
@ -37,15 +36,11 @@ public class RoutePointsActivity extends OsmandListActivity {
|
||||||
|
|
||||||
private List<GPXUtilities.WptPt> sortedPointsList;
|
private List<GPXUtilities.WptPt> sortedPointsList;
|
||||||
|
|
||||||
private List<Long> pointsStatus;
|
|
||||||
|
|
||||||
//saves indexed of sorted list
|
//saves indexed of sorted list
|
||||||
private List<Integer> pointsIndex;
|
private List<Integer> pointsIndex;
|
||||||
|
|
||||||
private int selectedItemIndex;
|
private int selectedItemIndex;
|
||||||
|
|
||||||
private ActionMode actionMode;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.setContentView(R.layout.route_steps_main);
|
super.setContentView(R.layout.route_steps_main);
|
||||||
|
@ -74,6 +69,7 @@ public class RoutePointsActivity extends OsmandListActivity {
|
||||||
private void getGpx(boolean forced) {
|
private void getGpx(boolean forced) {
|
||||||
if (plugin.getGpx() != null && !forced) {
|
if (plugin.getGpx() != null && !forced) {
|
||||||
this.gpx = plugin.getGpx();
|
this.gpx = plugin.getGpx();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GpxUiHelper.selectGPXFile(this, false, false, new CallbackWithObject<GPXUtilities.GPXFile[]>() {
|
GpxUiHelper.selectGPXFile(this, false, false, new CallbackWithObject<GPXUtilities.GPXFile[]>() {
|
||||||
|
@ -95,7 +91,7 @@ public class RoutePointsActivity extends OsmandListActivity {
|
||||||
gpxName.setOnClickListener(new View.OnClickListener() {
|
gpxName.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
actionMode = getActivity().startActionMode(mGpxActionModeCallback);
|
getActivity().startActionMode(mGpxActionModeCallback);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -111,9 +107,10 @@ public class RoutePointsActivity extends OsmandListActivity {
|
||||||
ArrayList<PointItem> pointItemsList = new ArrayList<PointItem>();
|
ArrayList<PointItem> pointItemsList = new ArrayList<PointItem>();
|
||||||
for (int i = 0; i < sortedPointsList.size(); i++) {
|
for (int i = 0; i < sortedPointsList.size(); i++) {
|
||||||
String pointName = sortedPointsList.get(i).name;
|
String pointName = sortedPointsList.get(i).name;
|
||||||
if (pointsStatus.get(i) != 0) {
|
long time = plugin.getPointStatus(pointsIndex.get(i));
|
||||||
|
if (time != 0) {
|
||||||
String dateString;
|
String dateString;
|
||||||
Date date = new Date(pointsStatus.get(i));
|
Date date = new Date(time);
|
||||||
if (DateFormat.is24HourFormat(app)) {
|
if (DateFormat.is24HourFormat(app)) {
|
||||||
dateString = DateFormat.format("MM/dd k:mm", date).toString();
|
dateString = DateFormat.format("MM/dd k:mm", date).toString();
|
||||||
} else {
|
} else {
|
||||||
|
@ -141,12 +138,13 @@ public class RoutePointsActivity extends OsmandListActivity {
|
||||||
listView.setAdapter(adapter);
|
listView.setAdapter(adapter);
|
||||||
|
|
||||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
||||||
selectedItemIndex = i;
|
selectedItemIndex = i;
|
||||||
view.setSelected(true);
|
view.setSelected(true);
|
||||||
actionMode = getActivity().startActionMode(mPointActionModeCallback);
|
|
||||||
|
getActivity().startActionMode(mPointActionModeCallback);
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -168,26 +166,20 @@ public class RoutePointsActivity extends OsmandListActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Long> getAllPointsStatus() {
|
|
||||||
List<Long> pointsStatus = new ArrayList<Long>();
|
|
||||||
for (int i = 0; i < sortedPointsList.size(); i++) {
|
|
||||||
pointsStatus.add(plugin.getPointStatus(pointsIndex.get(i)));
|
|
||||||
}
|
|
||||||
|
|
||||||
return pointsStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sortPoints() {
|
private void sortPoints() {
|
||||||
sortedPointsList = plugin.getPoints();
|
sortedPointsList = plugin.getPoints();
|
||||||
List<GPXUtilities.WptPt> listToSort = new ArrayList<GPXUtilities.WptPt>();
|
List<GPXUtilities.WptPt> listToSort = new ArrayList<GPXUtilities.WptPt>();
|
||||||
List<Integer> indexItemsAtTheEnd = new ArrayList<Integer>();
|
List<Integer> indexItemsAtTheEnd = new ArrayList<Integer>();
|
||||||
pointsIndex = new ArrayList<Integer>();
|
pointsIndex = new ArrayList<Integer>();
|
||||||
int curPointInd = plugin.getCurrentPointIndex();
|
int curPointInd = plugin.getCurrentPointIndex();
|
||||||
|
|
||||||
|
//current item should be first if it's exists
|
||||||
if (curPointInd != -1) {
|
if (curPointInd != -1) {
|
||||||
pointsIndex.add(curPointInd);
|
pointsIndex.add(curPointInd);
|
||||||
listToSort.add(plugin.getCurrentPoint());
|
listToSort.add(plugin.getCurrentPoint());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//all not visited points should be at the top
|
||||||
for (int i = 0; i < sortedPointsList.size(); i++) {
|
for (int i = 0; i < sortedPointsList.size(); i++) {
|
||||||
if (i == curPointInd) {
|
if (i == curPointInd) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -202,11 +194,15 @@ public class RoutePointsActivity extends OsmandListActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Long> timeOfVisits = new ArrayList<Long>();
|
List<Long> timeOfVisits = new ArrayList<Long>();
|
||||||
for (int i = 0; i < indexItemsAtTheEnd.size(); i++) {
|
|
||||||
timeOfVisits.add(plugin.getPointStatus(indexItemsAtTheEnd.get(i)));
|
for (Integer anIndexItemsAtTheEnd : indexItemsAtTheEnd) {
|
||||||
|
timeOfVisits.add(plugin.getPointStatus(anIndexItemsAtTheEnd));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//sorting visited point from earliest to latest
|
||||||
quickSort(timeOfVisits, indexItemsAtTheEnd, 0, indexItemsAtTheEnd.size());
|
quickSort(timeOfVisits, indexItemsAtTheEnd, 0, indexItemsAtTheEnd.size());
|
||||||
|
//reverting items so they will be from latest to earliest
|
||||||
|
Collections.reverse(indexItemsAtTheEnd);
|
||||||
|
|
||||||
for (int i : indexItemsAtTheEnd) {
|
for (int i : indexItemsAtTheEnd) {
|
||||||
listToSort.add(sortedPointsList.get(i));
|
listToSort.add(sortedPointsList.get(i));
|
||||||
|
@ -214,16 +210,13 @@ public class RoutePointsActivity extends OsmandListActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
sortedPointsList = listToSort;
|
sortedPointsList = listToSort;
|
||||||
pointsStatus = getAllPointsStatus();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class PointItemAdapter extends ArrayAdapter<PointItem> {
|
private class PointItemAdapter extends ArrayAdapter<PointItem> {
|
||||||
private RoutePointsActivity ctx;
|
|
||||||
private ArrayList<PointItem> pointsList;
|
private ArrayList<PointItem> pointsList;
|
||||||
|
|
||||||
public PointItemAdapter(Context context, int textViewResourceId, ArrayList<PointItem> pointsList) {
|
public PointItemAdapter(Context context, int textViewResourceId, ArrayList<PointItem> pointsList) {
|
||||||
super(context, textViewResourceId, pointsList);
|
super(context, textViewResourceId, pointsList);
|
||||||
ctx = (RoutePointsActivity) context;
|
|
||||||
this.pointsList = new ArrayList<PointItem>();
|
this.pointsList = new ArrayList<PointItem>();
|
||||||
this.pointsList.addAll(pointsList);
|
this.pointsList.addAll(pointsList);
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,6 +105,7 @@ public class RoutePointsPlugin extends OsmandPlugin {
|
||||||
currentRoute = gpx.routes.get(0);
|
currentRoute = gpx.routes.get(0);
|
||||||
pointsList = currentRoute.points;
|
pointsList = currentRoute.points;
|
||||||
refreshPointsStatus();
|
refreshPointsStatus();
|
||||||
|
getCurrentPoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerLayers(MapActivity activity) {
|
public void registerLayers(MapActivity activity) {
|
||||||
|
|
Loading…
Reference in a new issue