Search in sources :

Example 1 with Item

use of de.westnordost.streetcomplete.view.Item 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)

Example 2 with Item

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

the class PriorityList method buildList.

public static List<Item> buildList(List<Item> allItems, List<String> popularNames) {
    // in reverse because the first element in the list should be first in religionsList
    for (int i = popularNames.size() - 1; i >= 0; --i) {
        String popularReligionName = popularNames.get(i);
        for (int j = 0; j < allItems.size(); ++j) {
            Item processed = allItems.get(j);
            if (processed.value.equals(popularReligionName)) {
                // shuffle to start of list
                allItems.remove(j);
                allItems.add(0, processed);
                break;
            }
        }
    }
    return allItems;
}
Also used : Item(de.westnordost.streetcomplete.view.Item)

Example 3 with Item

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

the class AddRoadSurfaceForm method onClickOk.

@Override
protected void onClickOk() {
    final Bundle answer = new Bundle();
    Item surface = getSelectedItem();
    if (surface != null) {
        answer.putString(SURFACE, surface.value);
        if (surface.isGroup()) {
            new AlertDialogBuilder(getContext()).setMessage(R.string.quest_surface_generic_surface_confirmation).setNegativeButton(R.string.quest_generic_confirmation_no, null).setPositiveButton(R.string.quest_generic_confirmation_yes, (dialog, which) -> applyFormAnswer(answer)).show();
            return;
        }
    }
    applyFormAnswer(answer);
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) Arrays(java.util.Arrays) Bundle(android.os.Bundle) GroupedImageSelectAdapter(de.westnordost.streetcomplete.view.GroupedImageSelectAdapter) AlertDialogBuilder(de.westnordost.streetcomplete.view.dialogs.AlertDialogBuilder) LayoutInflater(android.view.LayoutInflater) ViewGroup(android.view.ViewGroup) Item(de.westnordost.streetcomplete.view.Item) RecyclerView(android.support.v7.widget.RecyclerView) R(de.westnordost.streetcomplete.R) AbstractQuestFormAnswerFragment(de.westnordost.streetcomplete.quests.AbstractQuestFormAnswerFragment) View(android.view.View) Button(android.widget.Button) Item(de.westnordost.streetcomplete.view.Item) AlertDialogBuilder(de.westnordost.streetcomplete.view.dialogs.AlertDialogBuilder) Bundle(android.os.Bundle)

Aggregations

Item (de.westnordost.streetcomplete.view.Item)3 GridLayoutManager (android.support.v7.widget.GridLayoutManager)2 RecyclerView (android.support.v7.widget.RecyclerView)2 View (android.view.View)2 Bundle (android.os.Bundle)1 LayoutInflater (android.view.LayoutInflater)1 ViewGroup (android.view.ViewGroup)1 Button (android.widget.Button)1 TextView (android.widget.TextView)1 R (de.westnordost.streetcomplete.R)1 AbstractQuestFormAnswerFragment (de.westnordost.streetcomplete.quests.AbstractQuestFormAnswerFragment)1 GroupedImageSelectAdapter (de.westnordost.streetcomplete.view.GroupedImageSelectAdapter)1 ImageSelectAdapter (de.westnordost.streetcomplete.view.ImageSelectAdapter)1 AlertDialogBuilder (de.westnordost.streetcomplete.view.dialogs.AlertDialogBuilder)1 Arrays (java.util.Arrays)1