Java Code Examples for rx.functions.Action1

The following examples show how to use rx.functions.Action1. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: android   Source File: QiblaPresenter.java    License: Apache License 2.0 6 votes vote down vote up
public void getAzimuth() {
    Subscription s = mLocationRepository.getLocation()
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .doOnSubscribe(new Action0() {
                @Override
                public void call() {
                    showLoading();
                }
            })
            .subscribe(new Action1<Location>() {
                @Override
                public void call(Location location) {
                    showAzimuth(location);
                }
            }, new Action1<Throwable>() {
                @Override
                public void call(Throwable throwable) {
                    showError(throwable);
                }
            });

    mSubscription.add(s);
}
 
Example 2
Source Project: talk-android   Source File: ChatActivity.java    License: MIT License 6 votes vote down vote up
@Override
public void editMessage(Message msg, String text) {
    if (msg.getStatus() == MessageDataProcess.Status.NONE.ordinal()) {
        presenter.updateMessage(msg.get_id(), text);
    } else {
        msg.setBody(text);
        MessageRealm.getInstance().addOrUpdate(msg)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Action1<Message>() {
                    @Override
                    public void call(Message message) {
                        BusProvider.getInstance().post(new NewMessageEvent(message));
                    }
                }, new RealmErrorAction());
        adapter.updateOne(msg.get_id(), RowFactory.getInstance()
                .makeRows(msg, ChatActivity.this, messageActionCallback, retriever));
    }
}
 
Example 3
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_use_rxjava_right_way);
    tvContent = (TextView) findViewById(R.id.tv_content);
    subscriptionForUser = userApi.getUserInfo()
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Action1<Response>() {
                @Override
                public void call(Response response) {
                    String content = new String(((TypedByteArray) response.getBody()).getBytes());
                    tvContent.setText("receiver data : " + content);
                }
            }, new Action1<Throwable>() {
                @Override
                public void call(Throwable throwable) {
                    tvContent.setText("receiver error : " + throwable.getMessage());
                }
            });

    compositeSubscription.add(subscriptionForUser);

}
 
Example 4
Source Project: talk-android   Source File: ResetPasswordFragment.java    License: MIT License 6 votes vote down vote up
@OnClick({R.id.btn_reset})
public void onClick(View view) {
    if (view.getId() == R.id.btn_reset) {
        String passwordStr = etPassword.getText().toString();
        String passwordStr2 = etEtPassword2.getText().toString();
        if (StringUtil.isBlank(passwordStr)) {
            Toast.makeText(getActivity(), R.string.password_required, Toast.LENGTH_SHORT).show();
            return;
        }
        if (!passwordStr.equals(passwordStr2)) {
            Toast.makeText(getActivity(), R.string.password_not_equal, Toast.LENGTH_SHORT).show();
            return;
        }

        TalkClient.getInstance().getAccountApi()
                .resetPassword(passwordStr)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Action1<User>() {
                    @Override
                    public void call(User user) {
                        RegisterActivity.initUserData(getActivity(), user);
                        TransactionUtil.goTo(getActivity(), ChooseTeamActivity.class, true);
                    }
                }, new ApiErrorAction());
    }
}
 
Example 5
Source Project: TLint   Source File: AccountPresenter.java    License: Apache License 2.0 6 votes vote down vote up
private void loadUserList() {
    mSubscription = Observable.create(new Observable.OnSubscribe<List<User>>() {
        @Override
        public void call(Subscriber<? super List<User>> subscriber) {
            subscriber.onNext(mUserDao.queryBuilder().list());
        }
    })
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Action1<List<User>>() {
                @Override
                public void call(List<User> users) {
                    mAccountView.renderUserList(users);
                }
            });
}
 
Example 6
Source Project: AnDevCon-RxPatterns   Source File: Example11.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
    TextView tv = (TextView) view.findViewById(R.id.hiddenIdTextView);
    if (tv!=null) {
        String gistName = tv.getText().toString();
        mGitHubClient.gist(gistName)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Action1<GistDetail>() {
                    @Override
                    public void call(GistDetail gistDetail) {
                        displayFileList(gistDetail);
                    }
                }, new Action1<Throwable>() {
                    @Override
                    public void call(Throwable throwable) {
                        throwable.printStackTrace();
                    }
                });

        mGistVisible = gistName;
        displayHomeAsUp(true); // just hacking everything together with a single activity for simplicity
    }
}
 
Example 7
Source Project: ZZShow   Source File: NewsFragment.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (getArguments() != null) {
        mParam1 = getArguments().getString(ARG_PARAM1);
        mParam2 = getArguments().getString(ARG_PARAM2);
    }
    mSubscription = RxBus.getInstance().toObservable(ChannelChangeEvent.class)
            .subscribe(new Action1<ChannelChangeEvent>() {
                @Override
                public void call(ChannelChangeEvent channelChangeEvent) {
                    KLog.d("NewsChannelPresenterImpl","GET ---------------");
                    if(channelChangeEvent.isChannelChanged()) {
                        mPresenter.loadNewsChannels();
                        if(channelChangeEvent.getChannelName() != null) {
                            mCurrentViewPagerName = channelChangeEvent.getChannelName();
                        }
                    }else{
                        if(channelChangeEvent.getChannelName() != null) {
                            mCurrentViewPagerName = channelChangeEvent.getChannelName();
                            mViewPager.setCurrentItem(getCurrentViewPagerPosition());
                        }
                    }
                }
            });
}
 
Example 8
Source Project: talk-android   Source File: FavoritesPresenter.java    License: MIT License 6 votes vote down vote up
public void getFavorites(String teamId, String maxId) {
    favoritesView.showProgressBar();
    Observable<List<Message>> observable = StringUtil.isBlank(maxId) ? talkApi.getFavorites(teamId)
            : talkApi.getFavorites(teamId, maxId);
    observable.observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Action1<List<Message>>() {
                @Override
                public void call(List<Message> favorites) {
                    favoritesView.dismissProgressBar();
                    favoritesView.showFavorites(favorites);
                }
            }, new Action1<Throwable>() {
                @Override
                public void call(Throwable e) {
                    favoritesView.dismissProgressBar();
                    Logger.e(TAG, "get favorites error", e);
                }
            });
}
 
Example 9
Source Project: ZhihuDailyFluxRRD   Source File: Dispatcher.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 订阅action
 *
 * @param store BaseStore
 */
public void register(final BaseStore store) {
    if (null == store) {
        throw new IllegalArgumentException("the store can't be null");
    }

    final int uniqueId = System.identityHashCode(store);
    if (mStoreSubscriptionHashMap.containsKey(uniqueId)) {
        Subscription subscription = mStoreSubscriptionHashMap.get(uniqueId);
        if (subscription.isUnsubscribed()) {
            mStoreSubscriptionHashMap.remove(uniqueId);
        } else {
            return;
        }
    }

    //将subscription缓存下来,以便之后取消订阅
    mStoreSubscriptionHashMap.put(uniqueId, Apollo.get().toObservable(BaseAction.class.getCanonicalName(), BaseAction.class)
            .subscribe(new Action1<BaseAction>() {
                @Override
                public void call(BaseAction action) {
                    store.onAction(action);
                }
            }));
}
 
Example 10
Source Project: talk-android   Source File: Oauth2Activity.java    License: MIT License 6 votes vote down vote up
private void checkIsNew(User user) {
    if (user.wasNew()) {
        this.user = user;
        MainApp.IMAGE_LOADER.displayImage(user.getAvatarUrl(), dialogAvatar,
                ImageLoaderConfig.AVATAR_OPTIONS);
        TalkClient.getInstance().getTalkApi().getStrikerToken().observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Action1<StrikerTokenResponseData>() {
                    @Override
                    public void call(StrikerTokenResponseData responseData) {
                        if (responseData != null) {
                            MainApp.PREF_UTIL.putString(Constant.STRIKER_TOKEN, responseData.getToken());
                            userDialog.show();
                        }
                    }
                }, new Action1<Throwable>() {
                    @Override
                    public void call(Throwable throwable) {
                        Logger.e("Oauth2Activity", "fail to get file auth key", throwable);
                    }
                });
    } else {
        TransactionUtil.goTo(this, ChooseTeamActivity.class, true);
    }
}
 
Example 11
public <T extends BaseV7EndlessResponse> EndlessRecyclerOnScrollListener(BaseAdapter baseAdapter,
    V7<T, ? extends Endless> v7request, Action1<T> successRequestListener,
    ErrorRequestListener errorRequestListener, int visibleThreshold, boolean bypassCache,
    BooleanAction<T> onFirstLoadListener, Action0 onEndOfListReachedListener) {
  this.multiLangPatch = new MultiLangPatch();
  this.onEndlessFinishList = new LinkedList<>();
  this.adapter = baseAdapter;
  this.v7request = v7request;
  this.successRequestListener = successRequestListener;
  this.errorRequestListener = errorRequestListener;
  this.visibleThreshold = visibleThreshold;
  this.bypassCache = bypassCache;
  this.onFirstLoadListener = onFirstLoadListener;
  this.onEndOfListReachedListener = onEndOfListReachedListener;
  this.endCallbackCalled = false;
  this.firstCallbackCalled = false;
  bypassServerCache = false;
}
 
Example 12
Source Project: autorest-clientruntime-for-java   Source File: ServiceFuture.java    License: MIT License 6 votes vote down vote up
/**
 * Creates a ServiceCall from an observable object and a callback.
 *
 * @param observable the observable to create from
 * @param callback the callback to call when events happen
 * @param <T> the type of the response
 * @return the created ServiceCall
 */
public static <T> ServiceFuture<T> fromResponse(final Observable<ServiceResponse<T>> observable, final ServiceCallback<T> callback) {
    final ServiceFuture<T> serviceFuture = new ServiceFuture<>();
    serviceFuture.subscription = observable
            .last()
            .subscribe(new Action1<ServiceResponse<T>>() {
                @Override
                public void call(ServiceResponse<T> t) {
                    if (callback != null) {
                        callback.success(t.body());
                    }
                    serviceFuture.valueSet = serviceFuture.set(t.body());
                }
            }, new Action1<Throwable>() {
                @Override
                public void call(Throwable throwable) {
                    if (callback != null) {
                        callback.failure(throwable);
                    }
                    serviceFuture.setException(throwable);
                }
            });
    return serviceFuture;
}
 
Example 13
Source Project: mantis   Source File: MergedObservableTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testSingleRemoteObservableMerge() {
    // setup
    Observable<Integer> os = Observable.range(0, 101);
    // serve
    PortSelectorWithinRange portSelector = new PortSelectorWithinRange(8000, 9000);
    int serverPort = portSelector.acquirePort();
    RemoteRxServer server = RemoteObservable.serve(serverPort, os, Codecs.integer());
    server.start();
    // connect
    Observable<Integer> ro = RemoteObservable.connect("localhost", serverPort, Codecs.integer());

    MergedObservable<Integer> merged = MergedObservable.createWithReplay(1);
    merged.mergeIn("t1", ro);

    // assert
    MathObservable.sumInteger(Observable.merge(merged.get()))
            .toBlocking().forEach(new Action1<Integer>() {
        @Override
        public void call(Integer t1) {
            Assert.assertEquals(5050, t1.intValue()); // sum of number 0-100
        }
    });
}
 
Example 14
Source Project: AppPlus   Source File: AppListFragment.java    License: MIT License 6 votes vote down vote up
private void subscribeEvents() {
    RxBus.getInstance()
            .toObservable()
            .subscribe(new Action1() {
                @Override
                public void call(Object o) {
                    if(o instanceof RxEvent){
                        RxEvent msg = (RxEvent) o;
                        List<AppEntity> list = new ArrayList<AppEntity>();
                        if(mAdapter!=null){
                            list = mAdapter.getListData();
                        }
                        dealRxEvent(msg, list);
                    }
                }
            });
}
 
Example 15
Source Project: nono-android   Source File: NoteController.java    License: GNU General Public License v3.0 6 votes vote down vote up
public static void saveNoteZipAsync(final SaveNoteListener l){
    Observable.create(new Observable.OnSubscribe<String>() {
        @Override
        public void call(Subscriber<? super String> subscriber) {
            String zipFilePath =  NotePersistenceController.saveNoteFiles();
            subscriber.onNext(zipFilePath);
            subscriber.onCompleted();
        }
    }).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
            .subscribe(
                    new Action1<String>() {
                        @Override
                        public void call(String path) {
                            l.onZipPath(path);
                        }
                    });
}
 
Example 16
Source Project: AnDevCon-RxPatterns   Source File: Example6.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onStart() {
    super.onStart();

    startSub = exampleObservable
            .doOnUnsubscribe(new Action0() {
                @Override
                public void call() {
                    Log.d(TAG, "Called unsubscribe OnStop()");
                }
            })
            .subscribe(new Action1<Integer>() {
                @Override
                public void call(Integer i) {
                    mOutputTextView2.setText(Integer.toString(i) + " OnStart()");
                }
            }, errorHandler);
}
 
Example 17
Source Project: goro   Source File: TestActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  GoroService.setup(this, Goro.create());

  Scheduler scheduler = new RxGoro(goro).scheduler("test-queue");
  Observable.just("ok")
      .subscribeOn(scheduler)
      .subscribe(new Action1<String>() {
        @Override
        public void call(String s) {
          result = "ok";
          resultSync.countDown();
        }
      });

  Observable.error(new RuntimeException("test error"))
      .subscribeOn(scheduler)
      .subscribe(Actions.empty(), new Action1<Throwable>() {
        @Override
        public void call(Throwable throwable) {
          error = throwable;
          errorSync.countDown();
        }
      });
}
 
Example 18
Source Project: azure-libraries-for-java   Source File: KeyVaultFutures.java    License: MIT License 6 votes vote down vote up
ServiceFuture<T> toFuture(final ServiceCallback<T> callback) {
    final KeyVaultFuture<T> future = new KeyVaultFuture<>();
    Observable.from(callAsync())
            .subscribe(new Action1<TInner>() {
                @Override
                public void call(TInner inner) {
                    T fluent = wrapModel(inner);
                    if (callback != null) {
                        callback.success(fluent);
                    }
                    future.success(fluent);
                }
            }, new Action1<Throwable>() {
                @Override
                public void call(Throwable throwable) {
                    if (callback != null) {
                        callback.failure(throwable);
                    }
                    future.failure(throwable);
                }
            });
    return future;
}
 
Example 19
Source Project: MVPExamples   Source File: MainPresenter.java    License: MIT License 6 votes vote down vote up
public MainPresenter() {
    App.getServerAPI()
        .getItems(DEFAULT_NAME.split("\\s+")[0], DEFAULT_NAME.split("\\s+")[1])
        .delay(1, TimeUnit.SECONDS)
        .observeOn(AndroidSchedulers.mainThread())
        .subscribe(new Action1<ServerAPI.Response>() {
            @Override
            public void call(ServerAPI.Response response) {
                items = response.items;
                publish();
            }
        }, new Action1<Throwable>() {
            @Override
            public void call(Throwable throwable) {
                error = throwable;
                publish();
            }
        });
}
 
Example 20
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_leaking_subject);

    // This should leak because it's constantly looping on itself
    mSubject
        .delay(1, TimeUnit.SECONDS)
        .subscribe(new Action1<Long>() {
            @Override public void call(Long aLong) {
                Timber.d("LeakingSubjectActivity received: " + aLong);
                mSubject.onNext(aLong + 1);
            }
        });
}
 
Example 21
Source Project: TLint   Source File: PmDetailPresenter.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void block() {
    mGameApi.blockPm(uid, isBlock ? 0 : 1)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(new Action1<BaseData>() {
                @Override
                public void call(BaseData baseData) {
                    ToastUtil.showToast(isBlock ? "取消屏蔽成功" : "屏蔽成功");
                    isBlock = !isBlock;
                    mPmDetailView.isBlock(isBlock);
                }
            }, new Action1<Throwable>() {
                @Override
                public void call(Throwable throwable) {
                    ToastUtil.showToast(isBlock ? "取消屏蔽失败,请检查网络后重试" : "屏蔽失败,请检查网络后重试");
                }
            });
}
 
Example 22
Source Project: java-dcp-client   Source File: SessionState.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Recovers the session state from persisted JSON.
 *
 * @param persisted the persisted JSON format.
 */
public void setFromJson(final byte[] persisted) {
  try {
    SessionState decoded = JACKSON.readValue(persisted, SessionState.class);
    decoded.foreachPartition(new Action1<PartitionState>() {
      int i = 0;

      @Override
      public void call(PartitionState dps) {
        partitionStates.set(i++, dps);
      }
    });
  } catch (Exception ex) {
    throw new RuntimeException("Could not decode SessionState from JSON.", ex);
  }
}
 
Example 23
Source Project: Hews   Source File: PostPresenter.java    License: MIT License 6 votes vote down vote up
void loadSummary(final Post post) {
    mCompositeSubscription.add(mDataManager.getSummary(post.getKids())
        .subscribeOn(Schedulers.io())
        .observeOn(AndroidSchedulers.mainThread())
        .subscribe(new Action1<Comment>() {
            @Override
            public void call(Comment comment) {
                if (comment != null) {
                    post.setSummary(mUtils.convertHtmlToString(
                        comment.getText().replace("<p>", "<br /><br />").replace("\n", "<br />")));
                    mPostView.showSummary(post.getIndex());
                } else {
                    post.setSummary(null);
                }
            }
        }, new Action1<Throwable>() {
            @Override
            public void call(Throwable throwable) {
                mPostView.showErrorLog("loadSummary: " + String.valueOf(post.getId()),
                    throwable.toString());
            }
        }));
}
 
Example 24
Source Project: BookReader   Source File: RxUtil.java    License: Apache License 2.0 6 votes vote down vote up
public static <T> Observable.Transformer<T, T> rxCacheBeanHelper(final String key) {
    return new Observable.Transformer<T, T>() {
        @Override
        public Observable<T> call(Observable<T> observable) {
            return observable
                    .subscribeOn(Schedulers.io())//指定doOnNext执行线程是新线程
                    .doOnNext(new Action1<T>() {
                        @Override
                        public void call(final T data) {
                            Schedulers.io().createWorker().schedule(new Action0() {
                                @Override
                                public void call() {
                                    LogUtils.d("get data from network finish ,start cache...");
                                    ACache.get(ReaderApplication.getsInstance())
                                            .put(key, new Gson().toJson(data, data.getClass()));
                                    LogUtils.d("cache finish");
                                }
                            });
                        }
                    })
                    .observeOn(AndroidSchedulers.mainThread());
        }
    };
}
 
Example 25
Source Project: AndroidRxJavaSample   Source File: TryWhenFragment.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onClick(View v) {
    super.onClick(v);
    switch (v.getId()) {
        case R.id.btn_operator:
            tvLogs.setText("");
            userApi.getUserInfoNoToken()
                    .retryWhen(new RetryWithDelay(3, 3000))
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribeOn(Schedulers.io())
                    .subscribe(new Action1<Response>() {
                        @Override
                        public void call(Response response) {
                            String content = new String(((TypedByteArray) response.getBody()).getBytes());
                            printLog(tvLogs, "", content);
                        }
                    }, new Action1<Throwable>() {
                        @Override
                        public void call(Throwable throwable) {
                            throwable.printStackTrace();
                        }
                    });
    }
}
 
Example 26
Source Project: DoingDaily   Source File: CommonRemoteDataSource.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void getGankPictures(int pageIndex, @NonNull final GankPictureCallback callback) {

    NetworkManager.getGankAPI().getPictures(pageIndex).subscribeOn(Schedulers.newThread())//子线程访问网络
            .observeOn(AndroidSchedulers.mainThread())//回调到主线程
            .subscribe(new Action1<PictureGankBean>() {
                @Override
                public void call(PictureGankBean bean) {
                    callback.onPicturesLoaded(bean);
                }
            }, new Action1<Throwable>() {
                @Override
                public void call(Throwable throwable) {
                    callback.onDataNotAvailable();
                }
            });
}
 
Example 27
Source Project: mantis   Source File: PushTrigger.java    License: Apache License 2.0 5 votes vote down vote up
public PushTrigger(Action1<MonitoredQueue<T>> doOnStart,
                   Action1<MonitoredQueue<T>> doOnStop,
                   Metrics metrics) {
    this.doOnStart = doOnStart;
    this.doOnStop = doOnStop;
    this.metrics = metrics;
}
 
Example 28
Source Project: ResearchStack   Source File: ProgressChartCard.java    License: Apache License 2.0 5 votes vote down vote up
public void setFinishAction(Action1<Object> action) {
    finishView.setVisibility(action == null ? View.GONE : View.VISIBLE);

    if (finishSub != null) {
        finishSub.unsubscribe();
    }

    if (action != null) {
        finishSub = RxView.clicks(finishView).subscribe(action);
    }
}
 
Example 29
Source Project: mantis   Source File: ObservableTrigger.java    License: Apache License 2.0 5 votes vote down vote up
public static <K, V> PushTrigger<KeyValuePair<K, V>> oomgo(String name, final Observable<Observable<MantisGroup<K, V>>> oo,
                                                           Action0 doOnComplete,
                                                           Action1<Throwable> doOnError,
                                                           long groupExpirySeconds,
                                                           final Func1<K, byte[]> keyEncoder,
                                                           HashFunction hashFunction) {
    return mantisGroupTrigger(name, Observable.merge(oo), doOnComplete, doOnError, groupExpirySeconds, keyEncoder, hashFunction);
}
 
Example 30
Source Project: talk-android   Source File: MessageDataProcess.java    License: MIT License 5 votes vote down vote up
public void updateUnreadNum(final Message message) {
    if (message == null) return;
    if (StringUtil.isNotBlank(message.getForeignId()) && !BizLogic.isMe(message.get_creatorId())) {
        Observable.create(new Observable.OnSubscribe<Object>() {
            @Override
            public void call(Subscriber<? super Object> subscriber) {
                if (MainApp.globalMembers.containsKey(message.getForeignId())) {
                    Member member = MainApp.globalMembers.get(message.getForeignId());
                    member.setUnread(member.getUnread() + 1);
                    MemberRealm.getInstance().addOrUpdateWithCurrentThread(member);
                    MainApp.IS_MEMBER_CHANGED = true;
                    MainApp.globalMembers.put(message.getForeignId(), member);
                }
                if (MainApp.globalRooms.containsKey(message.getForeignId())) {
                    Room room = MainApp.globalRooms.get(message.getForeignId());
                    room.setUnread(room.getUnread() + 1);
                    RoomRealm.getInstance().addOrUpdateWithCurrentThread(room);
                    MainApp.IS_ROOM_CHANGED = true;
                    MainApp.globalRooms.put(message.getForeignId(), room);
                }
            }
        }).subscribeOn(Schedulers.computation())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Action1<Object>() {
                    @Override
                    public void call(Object o) {
                        BusProvider.getInstance().post(new UpdateRoomEvent());
                        BusProvider.getInstance().post(new UpdateMemberEvent());
                    }
                });
    }
}