Fix of possible bugs

This commit is contained in:
androiddevkotlin 2021-02-17 23:00:23 +02:00
parent 5081ffd41d
commit 7d8886f757
2 changed files with 9 additions and 7 deletions

View file

@ -28,7 +28,6 @@ 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();
@ -43,7 +42,7 @@ 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));
timeIcon = view.findViewById(R.id.time_icon);
ImageView timeIcon = view.findViewById(R.id.time_icon);
timeIcon.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_time_moving_16));
return new TrackViewHolder(view);
}
@ -60,9 +59,10 @@ public class TrackSelectSegmentAdapter extends RecyclerView.Adapter<TrackViewHol
double distance = getDistance(segment);
long time = getSegmentTime(segment);
if (time != 1) {
holder.timeIcon.setVisibility(View.VISIBLE);
holder.time.setText(OsmAndFormatter.getFormattedDurationShort((int) (time / 1000)));
} else {
timeIcon.setVisibility(View.GONE);
holder.timeIcon.setVisibility(View.GONE);
holder.time.setText("");
}
holder.distance.setText(OsmAndFormatter.getFormattedDistance((float) distance, app));
@ -121,6 +121,7 @@ public class TrackSelectSegmentAdapter extends RecyclerView.Adapter<TrackViewHol
static class TrackViewHolder extends RecyclerView.ViewHolder {
ImageView iconSegment;
ImageView timeIcon;
TextView name;
TextView distance;
TextView time;
@ -128,6 +129,7 @@ public class TrackSelectSegmentAdapter extends RecyclerView.Adapter<TrackViewHol
TrackViewHolder(View itemView) {
super(itemView);
iconSegment = itemView.findViewById(R.id.icon);
timeIcon = itemView.findViewById(R.id.time_icon);
name = itemView.findViewById(R.id.name);
distance = itemView.findViewById(R.id.distance);
time = itemView.findViewById(R.id.time_interval);

View file

@ -722,10 +722,10 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca
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.getRoutingHelper().onSettingsChanged(true);
GPXRouteParamsBuilder paramsBuilder = app.getRoutingHelper().getCurrentGPXRoute();
if (paramsBuilder != null) {
paramsBuilder.setSelectedSegment(selectedSegment);
app.getRoutingHelper().onSettingsChanged(true);
}
updateSelectionMode(false);
}