Updated functionality of get current point.
This commit is contained in:
parent
6cb62a3a86
commit
03ca94315d
3 changed files with 35 additions and 10 deletions
|
@ -3,13 +3,19 @@
|
|||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical" >
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content">
|
||||
<TextView android:id="@+id/gpx_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" android:padding="10dp"
|
||||
android:text="@string/all_route_points" android:textSize="20sp" />
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="10dp"
|
||||
android:textSize="20sp"/>
|
||||
|
||||
<TextView android:id="@+id/points_count"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<Button android:id="@+id/done"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_marginRight="6dp"
|
||||
|
@ -20,8 +26,7 @@
|
|||
|
||||
<ListView android:id="@+id/pointsListView"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent" />
|
||||
|
||||
android:layout_height="fill_parent"/>
|
||||
|
||||
|
||||
</LinearLayout>
|
|
@ -35,8 +35,10 @@ public class RoutePointsActivity extends SherlockFragmentActivity {
|
|||
private List<GPXUtilities.WptPt> pointsList;
|
||||
|
||||
private List<Long> pointsStatus;
|
||||
|
||||
//saves indexed of sorted list
|
||||
private List<Integer> pointsIndex;
|
||||
|
||||
//needed to save user selection
|
||||
private List<Boolean> pointsChangedState;
|
||||
private List<Boolean> pointsStartState;
|
||||
|
@ -45,6 +47,8 @@ public class RoutePointsActivity extends SherlockFragmentActivity {
|
|||
|
||||
private int selectedItemIndex;
|
||||
|
||||
private ListView listView;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -103,6 +107,9 @@ public class RoutePointsActivity extends SherlockFragmentActivity {
|
|||
String fileName = gpx.path.substring(gpx.path.lastIndexOf("/") + 1,gpx.path.lastIndexOf("."));
|
||||
gpxName.setText(fileName);
|
||||
|
||||
TextView visited = (TextView) findViewById(R.id.points_count);
|
||||
visited.setText(plugin.getVisitedAllString());
|
||||
|
||||
loadCurrentRoute();
|
||||
pointsList = currentRoute.points;
|
||||
sortPoints();
|
||||
|
@ -125,7 +132,7 @@ public class RoutePointsActivity extends SherlockFragmentActivity {
|
|||
}
|
||||
|
||||
PointItemAdapter adapter = new PointItemAdapter(this, R.layout.route_point_info, pointItemsList);
|
||||
final ListView listView = (ListView) findViewById(R.id.pointsListView);
|
||||
listView = (ListView) findViewById(R.id.pointsListView);
|
||||
listView.setAdapter(adapter);
|
||||
|
||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
|
@ -150,7 +157,9 @@ public class RoutePointsActivity extends SherlockFragmentActivity {
|
|||
app.getSettings().setMapLocationToShow(point.lat, point.lon, app.getSettings().getMapZoomToShow());
|
||||
finish();
|
||||
} else {
|
||||
|
||||
//inverts selection state of item
|
||||
boolean state = pointsChangedState.get(selectedItemIndex);
|
||||
pointsChangedState.set(selectedItemIndex,!state);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -77,7 +77,16 @@ public class RoutePointsPlugin extends OsmandPlugin {
|
|||
return true;
|
||||
}
|
||||
|
||||
public GPXUtilities.WptPt getCurrentPoint(){return currentPoint;}
|
||||
public GPXUtilities.WptPt getCurrentPoint(){
|
||||
if (currentPoint == null){
|
||||
for (int i =0; i< pointsList.size(); i++){
|
||||
if (getPointStatus(i) == 0){
|
||||
currentPoint = pointsList.get(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
return currentPoint;
|
||||
}
|
||||
|
||||
public GPXUtilities.GPXFile getGpx(){ return gpx;}
|
||||
|
||||
|
@ -101,7 +110,7 @@ public class RoutePointsPlugin extends OsmandPlugin {
|
|||
private void registerWidget(MapActivity activity) {
|
||||
MapInfoLayer mapInfoLayer = activity.getMapLayers().getMapInfoLayer();
|
||||
if (mapInfoLayer != null) {
|
||||
routeStepsControl = createRouteStepsInfoControl(activity, mapInfoLayer.getPaintText(), mapInfoLayer.getPaintText());
|
||||
routeStepsControl = createRouteStepsInfoControl(activity, mapInfoLayer.getPaintSubText(), mapInfoLayer.getPaintSubText());
|
||||
mapInfoLayer.getMapInfoControls().registerSideWidget(routeStepsControl,
|
||||
R.drawable.widget_parking, R.string.map_widget_route_steps, "route_steps", false, 8);
|
||||
mapInfoLayer.recreateControls();
|
||||
|
@ -139,6 +148,8 @@ public class RoutePointsPlugin extends OsmandPlugin {
|
|||
}
|
||||
}
|
||||
|
||||
public String getVisitedAllString(){ return String.valueOf(visitedCount) + "/" + String.valueOf(pointsList.size());}
|
||||
|
||||
private TextInfoWidget createRouteStepsInfoControl(final MapActivity map, Paint paintText, Paint paintSubText) {
|
||||
TextInfoWidget routeStepsControl = new TextInfoWidget(map, 0, paintText, paintSubText) {
|
||||
|
||||
|
|
Loading…
Reference in a new issue