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 UiUtilities iconsCache;
private final List<TrkSegment> segments; private final List<TrkSegment> segments;
private OnItemClickListener onItemClickListener; private OnItemClickListener onItemClickListener;
private ImageView timeIcon;
public TrackSelectSegmentAdapter(Context ctx, List<TrkSegment> segments) { public TrackSelectSegmentAdapter(Context ctx, List<TrkSegment> segments) {
app = (OsmandApplication) ctx.getApplicationContext(); 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); View view = themedInflater.inflate(R.layout.gpx_segment_list_item, parent, false);
ImageView distanceIcon = view.findViewById(R.id.distance_icon); ImageView distanceIcon = view.findViewById(R.id.distance_icon);
distanceIcon.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_split_interval)); 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)); timeIcon.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_time_moving_16));
return new TrackViewHolder(view); return new TrackViewHolder(view);
} }
@ -60,9 +59,10 @@ public class TrackSelectSegmentAdapter extends RecyclerView.Adapter<TrackViewHol
double distance = getDistance(segment); double distance = getDistance(segment);
long time = getSegmentTime(segment); long time = getSegmentTime(segment);
if (time != 1) { if (time != 1) {
holder.timeIcon.setVisibility(View.VISIBLE);
holder.time.setText(OsmAndFormatter.getFormattedDurationShort((int) (time / 1000))); holder.time.setText(OsmAndFormatter.getFormattedDurationShort((int) (time / 1000)));
} else { } else {
timeIcon.setVisibility(View.GONE); holder.timeIcon.setVisibility(View.GONE);
holder.time.setText(""); holder.time.setText("");
} }
holder.distance.setText(OsmAndFormatter.getFormattedDistance((float) distance, app)); 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 { static class TrackViewHolder extends RecyclerView.ViewHolder {
ImageView iconSegment; ImageView iconSegment;
ImageView timeIcon;
TextView name; TextView name;
TextView distance; TextView distance;
TextView time; TextView time;
@ -128,6 +129,7 @@ public class TrackSelectSegmentAdapter extends RecyclerView.Adapter<TrackViewHol
TrackViewHolder(View itemView) { TrackViewHolder(View itemView) {
super(itemView); super(itemView);
iconSegment = itemView.findViewById(R.id.icon); iconSegment = itemView.findViewById(R.id.icon);
timeIcon = itemView.findViewById(R.id.time_icon);
name = itemView.findViewById(R.id.name); name = itemView.findViewById(R.id.name);
distance = itemView.findViewById(R.id.distance); distance = itemView.findViewById(R.id.distance);
time = itemView.findViewById(R.id.time_interval); time = itemView.findViewById(R.id.time_interval);