diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java index 08c8473b75..d2fbf5a058 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java @@ -45,6 +45,7 @@ import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.base.BaseOsmAndFragment; import net.osmand.plus.helpers.ColorDialogs; +import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter; import net.osmand.plus.widgets.FlowLayout; import net.osmand.util.Algorithms; @@ -461,26 +462,21 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment { e.printStackTrace(); } } - IconCategoriesAdapter iconCategoriesAdapter = new IconCategoriesAdapter(app); - iconCategoriesAdapter.setItems(new ArrayList<>(iconCategories.keySet())); - iconCategoriesAdapter.setListenerCategory(new IconCategoriesAdapter.IconCategoriesAdapterListener() { + HorizontalSelectionAdapter horizontalSelectionAdapter = new HorizontalSelectionAdapter(app, nightMode); + horizontalSelectionAdapter.setItems(new ArrayList<>(iconCategories.keySet())); + horizontalSelectionAdapter.setListener(new HorizontalSelectionAdapter.HorizontalSelectionAdapterListener() { @Override - public void onItemClick(String item) { + public void onItemSelected(String item) { selectedIconCategory = item; createIconForCategory(); updateIconSelector(selectedIcon, PointEditorFragmentNew.this.view); } - - @Override - public String getSelectedItem() { - return selectedIconCategory; - } }); RecyclerView iconCategoriesRecyclerView = view.findViewById(R.id.group_name_recycler_view); - iconCategoriesRecyclerView.setAdapter(iconCategoriesAdapter); + iconCategoriesRecyclerView.setAdapter(horizontalSelectionAdapter); iconCategoriesRecyclerView.setLayoutManager(new LinearLayoutManager(app, RecyclerView.HORIZONTAL, false)); - iconCategoriesAdapter.notifyDataSetChanged(); - iconCategoriesRecyclerView.smoothScrollToPosition(iconCategoriesAdapter.getItemPosition(selectedIconCategory)); + horizontalSelectionAdapter.notifyDataSetChanged(); + iconCategoriesRecyclerView.smoothScrollToPosition(horizontalSelectionAdapter.getItemPosition(selectedIconCategory)); for (String name : iconNameList) { selectIcon.addView(createIconItemView(name, selectIcon), new FlowLayout.LayoutParams(0, 0)); } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/IconCategoriesAdapter.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/HorizontalSelectionAdapter.java similarity index 62% rename from OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/IconCategoriesAdapter.java rename to OsmAnd/src/net/osmand/plus/mapcontextmenu/other/HorizontalSelectionAdapter.java index 9f53b0f49c..d7cf149eea 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/IconCategoriesAdapter.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/HorizontalSelectionAdapter.java @@ -1,7 +1,6 @@ -package net.osmand.plus.mapcontextmenu.editors; +package net.osmand.plus.mapcontextmenu.other; import android.graphics.drawable.GradientDrawable; -import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.LinearLayout; @@ -15,22 +14,25 @@ import androidx.recyclerview.widget.RecyclerView; import net.osmand.AndroidUtils; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; +import net.osmand.plus.UiUtilities; import java.util.List; import static net.osmand.util.Algorithms.capitalizeFirstLetter; -public class IconCategoriesAdapter extends RecyclerView.Adapter { +public class HorizontalSelectionAdapter extends RecyclerView.Adapter { private List items; private OsmandApplication app; private boolean nightMode; - private IconCategoriesAdapterListener listenerCategory; + private HorizontalSelectionAdapterListener listener; - public IconCategoriesAdapter(OsmandApplication app) { + private String selectedItem = ""; + + public HorizontalSelectionAdapter(OsmandApplication app, boolean nightMode) { this.app = app; - nightMode = app.getDaynightHelper().isNightModeForMapControls(); + this.nightMode = nightMode; } public void setItems(List items) { @@ -39,18 +41,18 @@ public class IconCategoriesAdapter extends RecyclerView.Adapter