Search in sources :

Example 1 with RESULT_OK

use of android.app.Activity.RESULT_OK 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 : DialogFragmentHelper(com.github.pockethub.android.ui.DialogFragmentHelper) Arrays(java.util.Arrays) Bundle(android.os.Bundle) BaseActivity(com.github.pockethub.android.ui.BaseActivity) RESULT_OK(android.app.Activity.RESULT_OK) Collection(java.util.Collection) Dialog(android.app.Dialog) NonNull(android.support.annotation.NonNull) GroupAdapter(com.xwray.groupie.GroupAdapter) ArrayList(java.util.ArrayList) List(java.util.List) Item(com.xwray.groupie.Item) Label(com.meisolsson.githubsdk.model.Label) View(android.view.View) Observable(io.reactivex.Observable) 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(android.support.annotation.NonNull)

Example 2 with RESULT_OK

use of android.app.Activity.RESULT_OK 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));
    }
    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) BaseActivity(com.github.pockethub.android.ui.BaseActivity) RESULT_OK(android.app.Activity.RESULT_OK) Dialog(android.app.Dialog) NonNull(android.support.annotation.NonNull) GroupAdapter(com.xwray.groupie.GroupAdapter) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) User(com.meisolsson.githubsdk.model.User) 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(android.support.annotation.NonNull)

Aggregations

RESULT_OK (android.app.Activity.RESULT_OK)2 Dialog (android.app.Dialog)2 Bundle (android.os.Bundle)2 NonNull (android.support.annotation.NonNull)2 View (android.view.View)2 R (com.github.pockethub.android.R)2 BaseActivity (com.github.pockethub.android.ui.BaseActivity)2 GroupAdapter (com.xwray.groupie.GroupAdapter)2 Item (com.xwray.groupie.Item)2 ArrayList (java.util.ArrayList)2 DialogFragmentHelper (com.github.pockethub.android.ui.DialogFragmentHelper)1 SingleChoiceDialogFragment (com.github.pockethub.android.ui.SingleChoiceDialogFragment)1 AssigneeDialogItem (com.github.pockethub.android.ui.item.dialog.AssigneeDialogItem)1 LabelDialogItem (com.github.pockethub.android.ui.item.dialog.LabelDialogItem)1 AvatarLoader (com.github.pockethub.android.util.AvatarLoader)1 Label (com.meisolsson.githubsdk.model.Label)1 User (com.meisolsson.githubsdk.model.User)1 OnItemClickListener (com.xwray.groupie.OnItemClickListener)1 Observable (io.reactivex.Observable)1 Arrays (java.util.Arrays)1