forked from upstream-mirrors/OpenTracks
Bugfix: spinner adapter needed notifyDataSetChanged to reload intervals with unit when user change from km to mi and the other way around.
This commit is contained in:
@@ -44,6 +44,7 @@ public class IntervalsFragment extends Fragment {
|
|||||||
private String intervalUnit;
|
private String intervalUnit;
|
||||||
private IntervalStatisticsAdapter adapter;
|
private IntervalStatisticsAdapter adapter;
|
||||||
protected Spinner spinnerIntervals;
|
protected Spinner spinnerIntervals;
|
||||||
|
private ArrayAdapter spinnerAdapter;
|
||||||
|
|
||||||
private Track.Id trackId;
|
private Track.Id trackId;
|
||||||
|
|
||||||
@@ -52,6 +53,7 @@ public class IntervalsFragment extends Fragment {
|
|||||||
intervalUnit = PreferencesUtils.isMetricUnits(getContext()) ? getContext().getString(R.string.unit_kilometer) : getContext().getString(R.string.unit_mile);
|
intervalUnit = PreferencesUtils.isMetricUnits(getContext()) ? getContext().getString(R.string.unit_kilometer) : getContext().getString(R.string.unit_mile);
|
||||||
if (adapter != null) {
|
if (adapter != null) {
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
|
spinnerAdapter.notifyDataSetChanged();
|
||||||
intervalChanged();
|
intervalChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -93,7 +95,7 @@ public class IntervalsFragment extends Fragment {
|
|||||||
|
|
||||||
spinnerIntervals = view.findViewById(R.id.spinner_intervals);
|
spinnerIntervals = view.findViewById(R.id.spinner_intervals);
|
||||||
|
|
||||||
spinnerIntervals.setAdapter(new ArrayAdapter(getContext(), android.R.layout.simple_spinner_dropdown_item, IntervalStatisticsModel.IntervalOption.values()) {
|
spinnerAdapter = new ArrayAdapter(getContext(), android.R.layout.simple_spinner_dropdown_item, IntervalStatisticsModel.IntervalOption.values()) {
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
|
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
|
||||||
@@ -108,7 +110,8 @@ public class IntervalsFragment extends Fragment {
|
|||||||
v.setText(v.getText() + " " + intervalUnit);
|
v.setText(v.getText() + " " + intervalUnit);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
spinnerIntervals.setAdapter(spinnerAdapter);
|
||||||
|
|
||||||
spinnerIntervals.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
spinnerIntervals.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user