Fix after review

This commit is contained in:
nazar-kutz 2021-03-09 11:45:40 +02:00
parent a6b0b08ece
commit 6d5529918c
5 changed files with 17 additions and 21 deletions

View file

@ -118,11 +118,14 @@ public class Algorithms {
return def;
}
public static String formatDoubleWithoutAdditionalZeros(double d) {
if(d == (long) d)
return String.format(Locale.US, "%d",(long)d);
else
return String.format("%s",d);
public static String formatDoubleWithoutExtraZeros(double d) {
return isInt(d) ?
String.format(Locale.US, "%d", (long) d) :
String.format("%s", d);
}
public static boolean isInt(double d) {
return (d == Math.floor(d)) && !Double.isInfinite(d);
}
public static int parseIntSilently(String input, int def) {

View file

@ -133,7 +133,7 @@ public class OsmAndFormatter {
units = app.getString(R.string.int_min);
intervalInUnits = (interval / 60f);
}
return Algorithms.formatDoubleWithoutAdditionalZeros(intervalInUnits) + " " + units;
return Algorithms.formatDoubleWithoutExtraZeros(intervalInUnits) + " " + units;
}
public static String getFormattedDistanceInterval(OsmandApplication app, double interval) {

View file

@ -1,12 +0,0 @@
package net.osmand.plus.base.bottomsheetmenu.simpleitems;
import net.osmand.plus.R;
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription;
public class LongDescriptionStandardHeightItem extends BottomSheetItemWithDescription {
public LongDescriptionStandardHeightItem(CharSequence description) {
this.description = description;
this.layoutId =R.layout.bottom_sheet_item_description_long_without_min_height;
}
}

View file

@ -22,7 +22,7 @@ import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.LongDescriptionStandardHeightItem;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.LongDescriptionItem;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.widgets.MultiStateToggleButton;
@ -96,7 +96,10 @@ public class SplitIntervalBottomSheet extends MenuBottomSheetDialogFragment {
@Override
public void createMenuItems(Bundle savedInstanceState) {
items.add(new TitleItem(getString(R.string.gpx_split_interval)));
items.add(new LongDescriptionStandardHeightItem(getString(R.string.gpx_split_interval_descr)));
items.add(new LongDescriptionItem.Builder()
.setDescription(getString(R.string.gpx_split_interval_descr))
.setLayoutId(R.layout.bottom_sheet_item_description_long_without_min_height)
.create());
LayoutInflater themedInflater = UiUtilities.getInflater(requireContext(), nightMode);
View view = themedInflater.inflate(R.layout.track_split_interval, null);

View file

@ -179,7 +179,9 @@ public class TrackWidthCard extends BaseCard {
private void scrollMenuToSelectedItem() {
int position = widthAdapter.getItemPosition(selectedItem);
groupRecyclerView.scrollToPosition(position);
if (position != -1) {
groupRecyclerView.scrollToPosition(position);
}
}
private class GpxWidthAdapter extends RecyclerView.Adapter<TrackAppearanceViewHolder> {