Search in sources :

Example 1 with GroupAdapter

use of com.xwray.groupie.GroupAdapter in project PocketHub by pockethub.

the class LabelsDialogFragment method onCreateDialog.

@NonNull
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    selectedChoices = getArguments().getBooleanArray(ARG_SELECTED_CHOICES);
    ArrayList<Label> choices = getChoices();
    List<String> selected = new ArrayList<>();
    if (selectedChoices != null) {
        for (int i = 0; i < choices.size(); i++) {
            if (selectedChoices[i]) {
                selected.add(choices.get(i).name());
            }
        }
    }
    adapter = new GroupAdapter();
    for (Label label : getChoices()) {
        adapter.add(new LabelDialogItem(label, selected.contains(label.name())));
    }
    adapter.setOnItemClickListener(this);
    return createDialogBuilder().adapter(adapter, null).negativeText(R.string.cancel).neutralText(R.string.clear).positiveText(R.string.apply).onNeutral((dialog, which) -> {
        Arrays.fill(getArguments().getBooleanArray(ARG_SELECTED_CHOICES), false);
        onResult(RESULT_OK);
    }).onPositive((dialog, which) -> onResult(RESULT_OK)).build();
}
Also used : Arrays(java.util.Arrays) Bundle(android.os.Bundle) NonNull(androidx.annotation.NonNull) RESULT_OK(android.app.Activity.RESULT_OK) Dialog(android.app.Dialog) DialogFragmentHelper(com.github.pockethub.android.ui.base.DialogFragmentHelper) GroupAdapter(com.xwray.groupie.GroupAdapter) ArrayList(java.util.ArrayList) BaseActivity(com.github.pockethub.android.ui.base.BaseActivity) List(java.util.List) Item(com.xwray.groupie.Item) Label(com.meisolsson.githubsdk.model.Label) View(android.view.View) R(com.github.pockethub.android.R) OnItemClickListener(com.xwray.groupie.OnItemClickListener) LabelDialogItem(com.github.pockethub.android.ui.item.dialog.LabelDialogItem) GroupAdapter(com.xwray.groupie.GroupAdapter) Label(com.meisolsson.githubsdk.model.Label) ArrayList(java.util.ArrayList) LabelDialogItem(com.github.pockethub.android.ui.item.dialog.LabelDialogItem) NonNull(androidx.annotation.NonNull)

Example 2 with GroupAdapter

use of com.xwray.groupie.GroupAdapter in project PocketHub by pockethub.

the class RefDialogFragment method onCreateDialog.

@NonNull
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    int selected = getArguments().getInt(ARG_SELECTED_CHOICE);
    GroupAdapter adapter = new GroupAdapter();
    for (GitReference ref : getChoices()) {
        adapter.add(new RefDialogItem(ref, selected));
    }
    adapter.setOnItemClickListener(this);
    return createDialogBuilder().adapter(adapter, null).negativeText(R.string.cancel).build();
}
Also used : RefDialogItem(com.github.pockethub.android.ui.item.dialog.RefDialogItem) GroupAdapter(com.xwray.groupie.GroupAdapter) GitReference(com.meisolsson.githubsdk.model.git.GitReference) NonNull(androidx.annotation.NonNull)

Example 3 with GroupAdapter

use of com.xwray.groupie.GroupAdapter in project PocketHub by pockethub.

the class AssigneeDialogFragment method onCreateDialog.

@NonNull
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    int selected = getArguments().getInt(ARG_SELECTED_CHOICE);
    GroupAdapter adapter = new GroupAdapter();
    for (User user : getChoices()) {
        adapter.add(new AssigneeDialogItem(avatars, user, selected));
    }
    adapter.setOnItemClickListener(this);
    return createDialogBuilder().adapter(adapter, null).negativeText(R.string.cancel).neutralText(R.string.clear).onNeutral((dialog, which) -> onResult(RESULT_OK)).build();
}
Also used : Bundle(android.os.Bundle) NonNull(androidx.annotation.NonNull) RESULT_OK(android.app.Activity.RESULT_OK) Dialog(android.app.Dialog) GroupAdapter(com.xwray.groupie.GroupAdapter) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) User(com.meisolsson.githubsdk.model.User) BaseActivity(com.github.pockethub.android.ui.base.BaseActivity) Item(com.xwray.groupie.Item) SingleChoiceDialogFragment(com.github.pockethub.android.ui.SingleChoiceDialogFragment) AssigneeDialogItem(com.github.pockethub.android.ui.item.dialog.AssigneeDialogItem) View(android.view.View) R(com.github.pockethub.android.R) AvatarLoader(com.github.pockethub.android.util.AvatarLoader) User(com.meisolsson.githubsdk.model.User) GroupAdapter(com.xwray.groupie.GroupAdapter) AssigneeDialogItem(com.github.pockethub.android.ui.item.dialog.AssigneeDialogItem) NonNull(androidx.annotation.NonNull)

Aggregations

NonNull (androidx.annotation.NonNull)3 GroupAdapter (com.xwray.groupie.GroupAdapter)3 RESULT_OK (android.app.Activity.RESULT_OK)2 Dialog (android.app.Dialog)2 Bundle (android.os.Bundle)2 View (android.view.View)2 R (com.github.pockethub.android.R)2 BaseActivity (com.github.pockethub.android.ui.base.BaseActivity)2 Item (com.xwray.groupie.Item)2 ArrayList (java.util.ArrayList)2 SingleChoiceDialogFragment (com.github.pockethub.android.ui.SingleChoiceDialogFragment)1 DialogFragmentHelper (com.github.pockethub.android.ui.base.DialogFragmentHelper)1 AssigneeDialogItem (com.github.pockethub.android.ui.item.dialog.AssigneeDialogItem)1 LabelDialogItem (com.github.pockethub.android.ui.item.dialog.LabelDialogItem)1 RefDialogItem (com.github.pockethub.android.ui.item.dialog.RefDialogItem)1 AvatarLoader (com.github.pockethub.android.util.AvatarLoader)1 Label (com.meisolsson.githubsdk.model.Label)1 User (com.meisolsson.githubsdk.model.User)1 GitReference (com.meisolsson.githubsdk.model.git.GitReference)1 OnItemClickListener (com.xwray.groupie.OnItemClickListener)1