Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. private void initLogout() {
  2. RxNavi.observe(naviComponent, Event.VIEW_CREATED)
  3. .filter(viewCreated -> accountPresenter.isLoggedIn(getContext()))
  4. .observeOn(AndroidSchedulers.mainThread())
  5. .doOnNext(viewCreated -> viewCreated.view()
  6. .findViewById(R.id.account_divider_logout).setVisibility(View.VISIBLE))
  7. .map(viewCreated -> {
  8. View logoutButton = viewCreated.view().findViewById(R.id.account_logout);
  9. logoutButton.setVisibility(View.VISIBLE);
  10. return logoutButton;
  11. })
  12. .flatMap(RxView::clicks)
  13. .switchMap(aVoid -> getLogoutConfirmationObservable())
  14. .filter(confirmed -> confirmed)
  15. .doOnNext(aVoid -> showProgressDialog(false))
  16. .observeOn(Schedulers.io())
  17. .flatMap(aVoid -> accountPresenter.onLogoutConfirmedObservable(getContext()))
  18. .observeOn(AndroidSchedulers.mainThread())
  19. .doOnNext(confirmed -> hideProgressDialog())
  20. .takeUntil(RxNavi.observe(naviComponent, Event.DESTROY))
  21. .subscribe(
  22. confirmed -> {
  23. SkyfishUi.lure().launchSfeLoginForm(getContext());
  24. },
  25. throwable -> {
  26. LogUtils.error(TAG, "Error in initLogout", throwable);
  27.  
  28. accountPresenter.handleErrorGenerally(throwable, baseActivity);
  29. }
  30. );
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement