Review
After changing segments using "Select another track" without closing RP, the last point of the previously selected segment will be added as a destination point. @androiddevkotlin Don't show route points quantity, on the second line we show only waypoints quantity @androiddevkotlin
This commit is contained in:
parent
bf5b797aaa
commit
5081ffd41d
5 changed files with 24 additions and 9 deletions
|
@ -28,6 +28,7 @@ public class TrackSelectSegmentAdapter extends RecyclerView.Adapter<TrackViewHol
|
|||
private final UiUtilities iconsCache;
|
||||
private final List<TrkSegment> segments;
|
||||
private OnItemClickListener onItemClickListener;
|
||||
private ImageView timeIcon;
|
||||
|
||||
public TrackSelectSegmentAdapter(Context ctx, List<TrkSegment> segments) {
|
||||
app = (OsmandApplication) ctx.getApplicationContext();
|
||||
|
@ -42,14 +43,14 @@ public class TrackSelectSegmentAdapter extends RecyclerView.Adapter<TrackViewHol
|
|||
View view = themedInflater.inflate(R.layout.gpx_segment_list_item, parent, false);
|
||||
ImageView distanceIcon = view.findViewById(R.id.distance_icon);
|
||||
distanceIcon.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_split_interval));
|
||||
ImageView timeIcon = view.findViewById(R.id.time_icon);
|
||||
timeIcon = view.findViewById(R.id.time_icon);
|
||||
timeIcon.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_time_moving_16));
|
||||
return new TrackViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull final TrackViewHolder holder, int position) {
|
||||
holder.icon.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_split_interval));
|
||||
holder.iconSegment.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_split_interval));
|
||||
|
||||
TrkSegment segment = segments.get(position);
|
||||
|
||||
|
@ -61,6 +62,7 @@ public class TrackSelectSegmentAdapter extends RecyclerView.Adapter<TrackViewHol
|
|||
if (time != 1) {
|
||||
holder.time.setText(OsmAndFormatter.getFormattedDurationShort((int) (time / 1000)));
|
||||
} else {
|
||||
timeIcon.setVisibility(View.GONE);
|
||||
holder.time.setText("");
|
||||
}
|
||||
holder.distance.setText(OsmAndFormatter.getFormattedDistance((float) distance, app));
|
||||
|
@ -118,14 +120,14 @@ public class TrackSelectSegmentAdapter extends RecyclerView.Adapter<TrackViewHol
|
|||
|
||||
static class TrackViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
ImageView icon;
|
||||
ImageView iconSegment;
|
||||
TextView name;
|
||||
TextView distance;
|
||||
TextView time;
|
||||
|
||||
TrackViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
icon = itemView.findViewById(R.id.icon);
|
||||
iconSegment = itemView.findViewById(R.id.icon);
|
||||
name = itemView.findViewById(R.id.name);
|
||||
distance = itemView.findViewById(R.id.distance);
|
||||
time = itemView.findViewById(R.id.time_interval);
|
||||
|
|
|
@ -720,11 +720,11 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca
|
|||
|
||||
@Override
|
||||
public void onSegmentSelect(GPXFile gpxFile, int selectedSegment) {
|
||||
app.getSettings().GPX_ROUTE_SEGMENT.set(selectedSegment);
|
||||
selectTrackToFollow(gpxFile);
|
||||
GPXRouteParamsBuilder paramsBuilder = app.getRoutingHelper().getCurrentGPXRoute();
|
||||
if (paramsBuilder != null) {
|
||||
paramsBuilder.setSelectedSegment(selectedSegment);
|
||||
app.getSettings().GPX_ROUTE_SEGMENT.set(selectedSegment);
|
||||
app.getRoutingHelper().onSettingsChanged(true);
|
||||
}
|
||||
updateSelectionMode(false);
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package net.osmand.plus.routepreparationmenu.cards;
|
||||
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.opengl.Visibility;
|
||||
import android.view.View;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
@ -22,6 +24,7 @@ import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder;
|
|||
import net.osmand.util.Algorithms;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TrackEditCard extends BaseCard {
|
||||
|
@ -83,19 +86,22 @@ public class TrackEditCard extends BaseCard {
|
|||
if (gpxFile.getNonEmptySegmentsCount() > 1 && routeParams != null && routeParams.getSelectedSegment() != -1) {
|
||||
TextView distanceView = view.findViewById(R.id.distance);
|
||||
TextView timeView = view.findViewById(R.id.time);
|
||||
ImageView timeIcon = view.findViewById(R.id.time_icon);
|
||||
TextView pointsView = view.findViewById(R.id.points_count);
|
||||
ImageView pointsIcon = view.findViewById(R.id.points_icon);
|
||||
pointsView.setVisibility(View.GONE);
|
||||
pointsIcon.setVisibility(View.GONE);
|
||||
List<GPXUtilities.TrkSegment> segments = gpxFile.getNonEmptyTrkSegments(false);
|
||||
GPXUtilities.TrkSegment segment = segments.get(routeParams.getSelectedSegment());
|
||||
int point = segment.points.size();
|
||||
double distance = TrackSelectSegmentAdapter.getDistance(segment);
|
||||
long time = TrackSelectSegmentAdapter.getSegmentTime(segment);
|
||||
if (time != 1) {
|
||||
timeView.setText(OsmAndFormatter.getFormattedDurationShort((int) (time / 1000)));
|
||||
} else {
|
||||
timeIcon.setVisibility(View.GONE);
|
||||
timeView.setText("");
|
||||
}
|
||||
distanceView.setText(OsmAndFormatter.getFormattedDistance((float) distance, app));
|
||||
pointsView.setText(String.valueOf(point));
|
||||
}
|
||||
|
||||
ImageButton editButton = view.findViewById(R.id.show_on_map);
|
||||
|
|
|
@ -1090,10 +1090,10 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
|||
|
||||
@Override
|
||||
public void onSegmentSelect(GPXFile gpxFile, int selectedSegment) {
|
||||
app.getSettings().GPX_ROUTE_SEGMENT.set(selectedSegment);
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
startNavigationForGPX(gpxFile, mapActivity.getMapActions());
|
||||
app.getSettings().GPX_ROUTE_SEGMENT.set(selectedSegment);
|
||||
RouteProvider.GPXRouteParamsBuilder paramsBuilder = app.getRoutingHelper().getCurrentGPXRoute();
|
||||
if (paramsBuilder != null) {
|
||||
paramsBuilder.setSelectedSegment(selectedSegment);
|
||||
|
|
|
@ -81,6 +81,7 @@ public class TrackSelectSegmentBottomSheet extends MenuBottomSheetDialogFragment
|
|||
TextView distance = gpxTrackContainer.findViewById(R.id.distance);
|
||||
TextView pointsCount = gpxTrackContainer.findViewById(R.id.points_count);
|
||||
TextView time = gpxTrackContainer.findViewById(R.id.time);
|
||||
ImageView timeIcon = gpxTrackContainer.findViewById(R.id.time_icon);
|
||||
LinearLayout container = gpxTrackContainer.findViewById(R.id.container);
|
||||
LinearLayout containerNameAndReadSection = gpxTrackContainer.findViewById(R.id.name_and_read_section_container);
|
||||
container.setPadding(sidePadding, 0, 0, 0);
|
||||
|
@ -93,7 +94,13 @@ public class TrackSelectSegmentBottomSheet extends MenuBottomSheetDialogFragment
|
|||
pointsCount.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
|
||||
pointsCount.setText(String.valueOf(analysis.wptPoints));
|
||||
time.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
|
||||
time.setText(analysis.isTimeSpecified() ? Algorithms.formatDuration((int) (analysis.timeSpan / 1000), app.accessibilityEnabled()) : "");
|
||||
if (analysis.isTimeSpecified()) {
|
||||
time.setText(Algorithms.formatDuration((int) (analysis.timeSpan / 1000),
|
||||
app.accessibilityEnabled()));
|
||||
} else {
|
||||
time.setText("");
|
||||
timeIcon.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
RecyclerView recyclerView = itemView.findViewById(R.id.gpx_segment_list);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
|
|
Loading…
Reference in a new issue