Fix track width card
This commit is contained in:
parent
6883bf722b
commit
a6b0b08ece
3 changed files with 30 additions and 18 deletions
|
@ -52,7 +52,6 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingStart="@dimen/content_padding"
|
||||
android:paddingTop="@dimen/content_padding"
|
||||
android:paddingEnd="@dimen/content_padding">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
|
@ -72,11 +71,20 @@
|
|||
android:layout_weight="1"
|
||||
android:gravity="end"
|
||||
android:lineSpacingExtra="@dimen/line_spacing_extra_description"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_list_text_size" />
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
tools:text="1" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.material.slider.Slider
|
||||
android:id="@+id/width_slider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/content_padding"
|
||||
android:layout_marginRight="@dimen/content_padding"
|
||||
android:stepSize="1" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -89,28 +97,23 @@
|
|||
android:id="@+id/width_value_min"
|
||||
android:layout_width="@dimen/standard_icon_size"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="start"
|
||||
android:lineSpacingExtra="@dimen/line_spacing_extra_description"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_list_text_size" />
|
||||
|
||||
<com.google.android.material.slider.Slider
|
||||
android:id="@+id/width_slider"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/content_padding"
|
||||
android:layout_marginRight="@dimen/content_padding"
|
||||
android:layout_weight="1"
|
||||
android:stepSize="1" />
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
tools:text="1" />
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/width_value_max"
|
||||
android:layout_width="@dimen/standard_icon_size"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="end"
|
||||
android:lineSpacingExtra="@dimen/line_spacing_extra_description"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_list_text_size" />
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
tools:text="24" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -633,8 +633,9 @@ public class UiUtilities {
|
|||
}
|
||||
int activeDisableColor = getColorWithAlpha(activeColor, 0.25f);
|
||||
ColorStateList activeCsl = new ColorStateList(states, new int[] {activeColor, activeDisableColor});
|
||||
int inactiveColor = ContextCompat.getColor(ctx, nightMode ? R.color.icon_color_default_dark : R.color.icon_color_secondary_light);
|
||||
ColorStateList inactiveCsl = new ColorStateList(states, new int[] {inactiveColor, inactiveColor});
|
||||
int inactiveColor = getColorWithAlpha(activeColor, 0.5f);
|
||||
int inactiveDisableColor = ContextCompat.getColor(ctx, nightMode ? R.color.icon_color_default_dark : R.color.icon_color_secondary_light);
|
||||
ColorStateList inactiveCsl = new ColorStateList(states, new int[] {inactiveColor, inactiveDisableColor});
|
||||
slider.setTrackActiveTintList(activeCsl);
|
||||
slider.setTrackInactiveTintList(inactiveCsl);
|
||||
slider.setHaloTintList(activeCsl);
|
||||
|
|
|
@ -45,6 +45,7 @@ public class TrackWidthCard extends BaseCard {
|
|||
|
||||
private GpxWidthAdapter widthAdapter;
|
||||
private View sliderContainer;
|
||||
private RecyclerView groupRecyclerView;
|
||||
|
||||
public TrackWidthCard(MapActivity mapActivity, TrackDrawInfo trackDrawInfo,
|
||||
OnNeedScrollListener onNeedScrollListener) {
|
||||
|
@ -65,9 +66,10 @@ public class TrackWidthCard extends BaseCard {
|
|||
updateCustomWidthSlider();
|
||||
|
||||
widthAdapter = new GpxWidthAdapter(appearanceItems);
|
||||
RecyclerView groupRecyclerView = view.findViewById(R.id.recycler_view);
|
||||
groupRecyclerView = view.findViewById(R.id.recycler_view);
|
||||
groupRecyclerView.setAdapter(widthAdapter);
|
||||
groupRecyclerView.setLayoutManager(new LinearLayoutManager(app, RecyclerView.HORIZONTAL, false));
|
||||
scrollMenuToSelectedItem();
|
||||
|
||||
AndroidUiHelper.updateVisibility(view.findViewById(R.id.top_divider), isShowDivider());
|
||||
}
|
||||
|
@ -155,7 +157,7 @@ public class TrackWidthCard extends BaseCard {
|
|||
}
|
||||
}
|
||||
});
|
||||
UiUtilities.setupSlider(widthSlider, nightMode, null);
|
||||
UiUtilities.setupSlider(widthSlider, nightMode, null, true);
|
||||
ScrollUtils.addOnGlobalLayoutListener(sliderContainer, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -175,6 +177,11 @@ public class TrackWidthCard extends BaseCard {
|
|||
mapActivity.refreshMap();
|
||||
}
|
||||
|
||||
private void scrollMenuToSelectedItem() {
|
||||
int position = widthAdapter.getItemPosition(selectedItem);
|
||||
groupRecyclerView.scrollToPosition(position);
|
||||
}
|
||||
|
||||
private class GpxWidthAdapter extends RecyclerView.Adapter<TrackAppearanceViewHolder> {
|
||||
|
||||
private List<AppearanceListItem> items;
|
||||
|
@ -219,6 +226,7 @@ public class TrackWidthCard extends BaseCard {
|
|||
|
||||
updateHeader();
|
||||
updateCustomWidthSlider();
|
||||
scrollMenuToSelectedItem();
|
||||
|
||||
CardListener listener = getListener();
|
||||
if (listener != null) {
|
||||
|
|
Loading…
Reference in a new issue