Search in sources :

Example 6 with MetricsConstants

use of net.osmand.plus.OsmandSettings.MetricsConstants in project Osmand by osmandapp.

the class GpxSelectionHelper method formatSplitName.

private static String formatSplitName(double metricEnd, GpxDisplayGroup group, OsmandApplication app) {
    if (group.isSplitDistance()) {
        MetricsConstants mc = app.getSettings().METRIC_SYSTEM.get();
        if (mc == MetricsConstants.KILOMETERS_AND_METERS) {
            final double sd = group.getSplitDistance();
            int digits = sd < 100 ? 2 : (sd < 1000 ? 1 : 0);
            int rem1000 = (int) (metricEnd + 0.5) % 1000;
            if (rem1000 > 1 && digits < 1) {
                digits = 1;
            }
            int rem100 = (int) (metricEnd + 0.5) % 100;
            if (rem100 > 1 && digits < 2) {
                digits = 2;
            }
            return OsmAndFormatter.getFormattedRoundDistanceKm((float) metricEnd, digits, app);
        } else {
            return OsmAndFormatter.getFormattedDistance((float) metricEnd, app);
        }
    } else {
        return Algorithms.formatDuration((int) metricEnd, app.accessibilityEnabled());
    }
}
Also used : MetricsConstants(net.osmand.plus.OsmandSettings.MetricsConstants)

Aggregations

MetricsConstants (net.osmand.plus.OsmandSettings.MetricsConstants)6 InvalidTheoryException (alice.tuprolog.InvalidTheoryException)1 Number (alice.tuprolog.Number)1 Struct (alice.tuprolog.Struct)1 Term (alice.tuprolog.Term)1 Theory (alice.tuprolog.Theory)1 DialogInterface (android.content.DialogInterface)1 OnClickListener (android.content.DialogInterface.OnClickListener)1 CheckBoxPreference (android.preference.CheckBoxPreference)1 EditTextPreference (android.preference.EditTextPreference)1 ListPreference (android.preference.ListPreference)1 Preference (android.preference.Preference)1 OnPreferenceClickListener (android.preference.Preference.OnPreferenceClickListener)1 NonNull (android.support.annotation.NonNull)1 AlertDialog (android.support.v7.app.AlertDialog)1 AppCompatCheckedTextView (android.support.v7.widget.AppCompatCheckedTextView)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 ArrayAdapter (android.widget.ArrayAdapter)1