removed some unused code. visited points list will now be shown from latest to oldest
This commit is contained in:
parent
24303e8509
commit
58d1f8963c
1 changed files with 14 additions and 28 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;
|
||||||
|
@ -14,8 +12,6 @@ import android.view.ActionMode;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.widget.*;
|
import android.widget.*;
|
||||||
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
|
||||||
import com.actionbarsherlock.view.*;
|
|
||||||
import net.osmand.CallbackWithObject;
|
import net.osmand.CallbackWithObject;
|
||||||
import net.osmand.plus.*;
|
import net.osmand.plus.*;
|
||||||
import net.osmand.plus.activities.OsmandListActivity;
|
import net.osmand.plus.activities.OsmandListActivity;
|
||||||
|
@ -27,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 {
|
||||||
|
|
||||||
|
@ -39,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);
|
||||||
|
@ -106,9 +99,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 {
|
||||||
|
@ -136,12 +130,11 @@ 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(mActionModeCallback);
|
getActivity().startActionMode(mActionModeCallback);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -163,26 +156,19 @@ 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;
|
||||||
|
@ -197,11 +183,14 @@ 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++){
|
for (Integer anIndexItemsAtTheEnd : indexItemsAtTheEnd) {
|
||||||
timeOfVisits.add(plugin.getPointStatus(indexItemsAtTheEnd.get(i)));
|
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));
|
||||||
|
@ -209,16 +198,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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue