Esempio n. 1
0
  public static void adaptFragmentLifecycle(Observable<FragmentEvent> lifecycle, MediaView view) {
    lifecycle
        .compose(bindView(view))
        .subscribe(
            event -> {
              if (event == FragmentEvent.RESUME) view.onResume();

              if (event == FragmentEvent.PAUSE) view.onPause();
            });
  }
Esempio n. 2
0
  private void onDeleteClicked() {
    String reason = customReasonText.getText().toString();
    boolean notifyUser = this.notifyUser.isChecked();
    boolean ban = blockUser.isChecked();

    Observable<Void> response = deleteItem(reason, notifyUser, ban);
    response
        .compose(bindToLifecycle())
        .lift(BusyDialogFragment.busyDialog(this))
        .subscribe(event -> dismiss(), defaultOnError());
  }
Esempio n. 3
0
 private void onClickStartStopTimer(View view) {
   if (!isRunning) {
     Toast.makeText(this, "Started timer", Toast.LENGTH_SHORT).show();
     isRunning = true;
     startStop.setImageDrawable(alarmOffDrawable);
     timerObservable
         .compose(observableGroup.<Long>transform(OBSERVABLE_TAG))
         .observeOn(AndroidSchedulers.mainThread())
         .onBackpressureBuffer()
         .subscribe(observer);
   } else {
     Toast.makeText(this, "Stopped timer", Toast.LENGTH_SHORT).show();
     isRunning = false;
     startStop.setImageDrawable(alarmDrawable);
     observableGroup.cancelAndRemove(OBSERVABLE_TAG);
   }
 }
Esempio n. 4
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();
    }
  }