Advertisement
Guest User

Untitled

a guest
Aug 25th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. private void restoreProfile() {
  2. if (!loginSubscription.isUnsubscribed()) {
  3. loginSubscription.unsubscribe();
  4. }
  5. loginSubscription = loginModel.restoreUserProfile()
  6. .subscribe(user -> {
  7. /new profile
  8. } else {
  9. if (!cleanDataSubscription.isUnsubscribed()) {
  10. cleanDataSubscription.unsubscribe();
  11. }
  12.  
  13. cleanDataSubscription = loginModel.cleanCaсhedData()
  14. .subscribe(result -> {
  15. Log.d(TAG, "restoreProfile: clean Data");
  16.  
  17. if (!restoreDataSubscription.isUnsubscribed()) {
  18. restoreDataSubscription.unsubscribe();
  19. }
  20. restoreDataSubscription = viewedDataModel.getLastBattles()
  21. .subscribe(r -> {
  22. Log.d(TAG, "restoreProfile: restore data");
  23. //write data
  24. }, throwable -> {
  25. Log.d(TAG, "restoreProfile: restore data error");
  26. });
  27. }, throwable -> {
  28. Log.w(TAG, "onLogoutClick: Failed to clear realm", throwable);
  29. });
  30. }
  31. }, throwable -> {
  32. view.showProfileRestoreError(throwable);
  33.  
  34. });
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement