Merge pull request #11289 from osmandapp/jump_group_favorite
Favorites icon groups jump after selection.
This commit is contained in:
commit
135e5024f9
1 changed files with 21 additions and 16 deletions
|
@ -619,6 +619,27 @@ 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));
|
||||
iconCategoriesRecyclerView.scrollToPosition(horizontalSelectionAdapter.getItemPositionByTitle(selectedIconCategory));
|
||||
}
|
||||
|
||||
|
||||
private void createIconList() {
|
||||
FlowLayout selectIcon = view.findViewById(R.id.select_icon);
|
||||
selectIcon.removeAllViews();
|
||||
JSONArray iconJsonArray = iconCategories.get(selectedIconCategory);
|
||||
|
@ -631,22 +652,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));
|
||||
|
|
Loading…
Reference in a new issue