From 8fe9fc99d3bf2d000f8d9558452921e6f232fe57 Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Tue, 30 Mar 2021 14:39:35 +0300 Subject: [PATCH 1/2] Favorites icon groups jump after selection. --- .../editors/PointEditorFragmentNew.java | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java index b8fb261f09..464e8b6375 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java @@ -619,6 +619,26 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment implemen } private void createIconForCategory() { + createIconList(); + final HorizontalSelectionAdapter horizontalSelectionAdapter = new HorizontalSelectionAdapter(app, nightMode); + horizontalSelectionAdapter.setTitledItems(new ArrayList<>(iconCategories.keySet())); + horizontalSelectionAdapter.setSelectedItemByTitle(selectedIconCategory); + horizontalSelectionAdapter.setListener(new HorizontalSelectionAdapter.HorizontalSelectionAdapterListener() { + @Override + public void onItemSelected(HorizontalSelectionAdapter.HorizontalSelectionItem item) { + selectedIconCategory = item.getTitle(); + createIconList(); + updateIconSelector(selectedIcon, PointEditorFragmentNew.this.view); + horizontalSelectionAdapter.notifyDataSetChanged(); + } + }); + RecyclerView iconCategoriesRecyclerView = view.findViewById(R.id.group_name_recycler_view); + iconCategoriesRecyclerView.setAdapter(horizontalSelectionAdapter); + iconCategoriesRecyclerView.setLayoutManager(new LinearLayoutManager(app, RecyclerView.HORIZONTAL, false)); + } + + + private void createIconList() { FlowLayout selectIcon = view.findViewById(R.id.select_icon); selectIcon.removeAllViews(); JSONArray iconJsonArray = iconCategories.get(selectedIconCategory); @@ -631,22 +651,6 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment implemen e.printStackTrace(); } } - HorizontalSelectionAdapter horizontalSelectionAdapter = new HorizontalSelectionAdapter(app, nightMode); - horizontalSelectionAdapter.setTitledItems(new ArrayList<>(iconCategories.keySet())); - horizontalSelectionAdapter.setSelectedItemByTitle(selectedIconCategory); - horizontalSelectionAdapter.setListener(new HorizontalSelectionAdapter.HorizontalSelectionAdapterListener() { - @Override - public void onItemSelected(HorizontalSelectionAdapter.HorizontalSelectionItem item) { - selectedIconCategory = item.getTitle(); - createIconForCategory(); - updateIconSelector(selectedIcon, PointEditorFragmentNew.this.view); - } - }); - RecyclerView iconCategoriesRecyclerView = view.findViewById(R.id.group_name_recycler_view); - iconCategoriesRecyclerView.setAdapter(horizontalSelectionAdapter); - iconCategoriesRecyclerView.setLayoutManager(new LinearLayoutManager(app, RecyclerView.HORIZONTAL, false)); - horizontalSelectionAdapter.notifyDataSetChanged(); - iconCategoriesRecyclerView.smoothScrollToPosition(horizontalSelectionAdapter.getItemPositionByTitle(selectedIconCategory)); for (String name : iconNameList) { int minimalPaddingBetweenIcon = app.getResources().getDimensionPixelSize(R.dimen.favorites_select_icon_button_right_padding); selectIcon.addView(createIconItemView(name, selectIcon), new FlowLayout.LayoutParams(minimalPaddingBetweenIcon, 0)); From 69d4c717654140587eb28989684a3c917361bd9e Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Tue, 30 Mar 2021 15:06:07 +0300 Subject: [PATCH 2/2] Fix scroll after open edit favorite point --- .../plus/mapcontextmenu/editors/PointEditorFragmentNew.java | 1 + 1 file changed, 1 insertion(+) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java index 464e8b6375..b00ff19efd 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java @@ -635,6 +635,7 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment implemen RecyclerView iconCategoriesRecyclerView = view.findViewById(R.id.group_name_recycler_view); iconCategoriesRecyclerView.setAdapter(horizontalSelectionAdapter); iconCategoriesRecyclerView.setLayoutManager(new LinearLayoutManager(app, RecyclerView.HORIZONTAL, false)); + iconCategoriesRecyclerView.scrollToPosition(horizontalSelectionAdapter.getItemPositionByTitle(selectedIconCategory)); }