use of io.reactivex.disposables.Disposable in project simple-stack by Zhuinden.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
defaultStateChanger = DefaultStateChanger.create(this, root);
Backstack backstack = Navigator.configure().setStateChanger(new NoOpStateChanger()).setDeferredInitialization(true).install(this, root, HistoryBuilder.single(FirstKey.create()));
disposable = RxStackObservable.create(backstack).subscribe(stateChange -> {
if (stateChange.topNewState().equals(stateChange.topPreviousState())) {
return;
}
defaultStateChanger.performViewChange(stateChange.topPreviousState(), stateChange.topNewState(), stateChange, () -> {
});
});
Navigator.executeDeferredInitialization(this);
}
use of io.reactivex.disposables.Disposable in project Rocket.Chat.Android by RocketChat.
the class LoginPresenter method loadSessionState.
private void loadSessionState() {
final Disposable subscription = sessionInteractor.getSessionState().distinctUntilChanged().subscribeOn(AndroidSchedulers.from(BackgroundLooper.get())).observeOn(AndroidSchedulers.mainThread()).subscribe(state -> {
switch(state) {
case UNAVAILABLE:
isLogging = true;
view.showLogin(hostname);
break;
case INVALID:
isLogging = false;
view.showRetryLogin(hostname);
break;
case VALID:
isLogging = false;
view.closeView();
}
}, Logger::report);
addSubscription(subscription);
}
use of io.reactivex.disposables.Disposable in project Rocket.Chat.Android by RocketChat.
the class MainPresenter method onRetryLogin.
@Override
public void onRetryLogin() {
final Disposable subscription = sessionInteractor.retryLogin().subscribe();
addSubscription(subscription);
}
use of io.reactivex.disposables.Disposable in project Rocket.Chat.Android by RocketChat.
the class MessageOptionsDialogFragment method setUpDialog.
private void setUpDialog(final BottomSheetDialog bottomSheetDialog, String messageId) {
RocketChatCache cache = new RocketChatCache(bottomSheetDialog.getContext());
String hostname = cache.getSelectedServerHostname();
EditMessageInteractor editMessageInteractor = getEditMessageInteractor(hostname);
MessageRepository messageRepository = new RealmMessageRepository(hostname);
Disposable disposable = messageRepository.getById(messageId).flatMap(it -> {
if (!it.isPresent()) {
return Single.just(Pair.<Message, Boolean>create(null, false));
}
Message message = it.get();
return Single.zip(Single.just(message), editMessageInteractor.isAllowed(message), Pair::create);
}).subscribeOn(AndroidSchedulers.from(BackgroundLooper.get())).observeOn(AndroidSchedulers.mainThread()).subscribe(pair -> {
if (pair.second) {
bottomSheetDialog.findViewById(R.id.message_options_info).setVisibility(View.GONE);
View editView = bottomSheetDialog.findViewById(R.id.message_options_edit_action);
editView.setVisibility(View.VISIBLE);
editView.setOnClickListener(view -> internalListener.onEdit(pair.first));
} else {
((TextView) bottomSheetDialog.findViewById(R.id.message_options_info)).setText(R.string.message_options_no_permissions_info);
}
}, throwable -> {
((TextView) bottomSheetDialog.findViewById(R.id.message_options_info)).setText(R.string.message_options_no_message_info);
Logger.report(throwable);
});
compositeDisposable.add(disposable);
}
use of io.reactivex.disposables.Disposable in project Rocket.Chat.Android by RocketChat.
the class InputHostnamePresenter method connectToEnforced.
public void connectToEnforced(final String hostname) {
final ServerPolicyApi serverPolicyApi = new DefaultServerPolicyApi(OkHttpHelper.getClientForUploadFile(), hostname);
final ServerPolicyApiValidationHelper validationHelper = new ServerPolicyApiValidationHelper(serverPolicyApi);
clearSubscriptions();
final Disposable subscription = ServerPolicyHelper.isApiVersionValid(validationHelper).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).doOnTerminate(() -> view.hideLoader()).subscribe(serverValidation -> {
if (serverValidation.isValid()) {
onServerValid(hostname, serverValidation.usesSecureConnection());
} else {
view.showInvalidServerError();
}
}, throwable -> view.showConnectionError());
addSubscription(subscription);
}
Aggregations