Beispiel #1
0
  @NonNull
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    ContextThemeWrapper context =
        new ContextThemeWrapper(getActivity(), R.style.Theme_AppCompat_Light_Dialog);

    inputView =
        (TextInputLayout) LayoutInflater.from(context).inflate(R.layout.search_user_dialog, null);

    return DialogBuilder.start(context)
        .content(inputView)
        .fullWidth()
        .positive(R.string.action_search, di -> onSearchClicked())
        .negative(R.string.cancel, Dialog::dismiss)
        .noAutoDismiss()
        .build();
  }
Beispiel #2
0
  @Override
  public void onCommentMarkAsFavoriteClicked(Comment comment, boolean markAsFavorite) {
    Observable<Void> result;
    if (markAsFavorite) {
      result =
          favedCommentService.save(
              ImmutableFavedComment.builder()
                  .id(comment.getId())
                  .name(comment.getName())
                  .content(comment.getContent())
                  .created(comment.getCreated())
                  .up(comment.getUp())
                  .down(comment.getDown())
                  .mark(comment.getMark())
                  .thumb(feedItem.getThumb())
                  .itemId(feedItem.getId())
                  .flags(feedItem.getFlags())
                  .build());
    } else {
      result = favedCommentService.delete(comment.getId());
    }

    result
        .compose(bindUntilEvent(FragmentEvent.DESTROY_VIEW))
        .subscribe(Actions.empty(), defaultOnError());

    if (singleShotService.isFirstTime("kfav-userscript-hint")) {
      DialogBuilder.start(getContext())
          .content(R.string.hint_kfav_userscript)
          .positive(
              R.string.open_website,
              di -> {
                Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://goo.gl/py7xNW"));
                getContext().startActivity(intent);
              })
          .negative(R.string.ignore)
          .show();
    }
  }