Search in sources :

Example 1 with ImageSelectAdapter

use of de.westnordost.streetcomplete.view.ImageSelectAdapter in project StreetComplete by westnordost.

the class ImageListQuestAnswerFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = super.onCreateView(inflater, container, savedInstanceState);
    View contentView = setContentView(R.layout.quest_generic_list);
    valueList = contentView.findViewById(R.id.listSelect);
    GridLayoutManager lm = new GridLayoutManager(getActivity(), getItemsPerRow());
    valueList.setLayoutManager(lm);
    valueList.setNestedScrollingEnabled(false);
    showMoreButton = view.findViewById(R.id.buttonShowMore);
    showMoreButton.setOnClickListener(v -> {
        List<Item> all = Arrays.asList(getItems());
        imageSelector.addItems(all.subList(imageSelector.getItemCount(), all.size()));
        showMoreButton.setVisibility(View.GONE);
    });
    int selectableItems = getMaxSelectableItems();
    TextView selectHint = view.findViewById(R.id.selectHint);
    selectHint.setText(selectableItems == 1 ? R.string.quest_roofShape_select_one : R.string.quest_select_hint);
    imageSelector = new ImageSelectAdapter(selectableItems);
    return view;
}
Also used : Item(de.westnordost.streetcomplete.view.Item) GridLayoutManager(android.support.v7.widget.GridLayoutManager) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) ImageSelectAdapter(de.westnordost.streetcomplete.view.ImageSelectAdapter)

Aggregations

GridLayoutManager (android.support.v7.widget.GridLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 TextView (android.widget.TextView)1 ImageSelectAdapter (de.westnordost.streetcomplete.view.ImageSelectAdapter)1 Item (de.westnordost.streetcomplete.view.Item)1