Commit 4f259cc3 authored by Tiago Cunha's avatar Tiago Cunha Committed by GitHub

Merge pull request #243 from RocketChat/fix/room-npe

Crashes
parents b704af6f 54b7af44
...@@ -57,11 +57,19 @@ public class DefaultServerPolicyApi implements ServerPolicyApi { ...@@ -57,11 +57,19 @@ public class DefaultServerPolicyApi implements ServerPolicyApi {
return new okhttp3.Callback() { return new okhttp3.Callback() {
@Override @Override
public void onFailure(Call call, IOException ioException) { public void onFailure(Call call, IOException ioException) {
if (emitter.isCancelled()) {
return;
}
emitter.onError(ioException); emitter.onError(ioException);
} }
@Override @Override
public void onResponse(Call call, okhttp3.Response response) throws IOException { public void onResponse(Call call, okhttp3.Response response) throws IOException {
if (emitter.isCancelled()) {
return;
}
if (!response.isSuccessful()) { if (!response.isSuccessful()) {
emitter.onNext(new Response<>(false, protocol, null)); emitter.onNext(new Response<>(false, protocol, null));
emitter.onComplete(); emitter.onComplete();
......
...@@ -53,9 +53,7 @@ public class InputHostnamePresenter extends BasePresenter<InputHostnameContract. ...@@ -53,9 +53,7 @@ public class InputHostnamePresenter extends BasePresenter<InputHostnameContract.
view.showInvalidServerError(); view.showInvalidServerError();
} }
}, },
throwable -> { throwable -> view.showConnectionError());
view.showConnectionError();
});
addSubscription(subscription); addSubscription(subscription);
} }
......
...@@ -36,8 +36,6 @@ public interface RoomContract { ...@@ -36,8 +36,6 @@ public interface RoomContract {
void loadMoreMessages(); void loadMoreMessages();
void onViewSetup();
void onMessageSelected(@Nullable Message message); void onMessageSelected(@Nullable Message message);
void sendMessage(String messageText); void sendMessage(String messageText);
......
...@@ -202,8 +202,6 @@ public class RoomFragment extends AbstractChatRoomFragment ...@@ -202,8 +202,6 @@ public class RoomFragment extends AbstractChatRoomFragment
setupSideMenu(); setupSideMenu();
setupMessageComposer(); setupMessageComposer();
setupMessageActions(); setupMessageActions();
presenter.onViewSetup();
} }
private void setupMessageActions() { private void setupMessageActions() {
......
...@@ -59,6 +59,7 @@ public class RoomPresenter extends BasePresenter<RoomContract.View> ...@@ -59,6 +59,7 @@ public class RoomPresenter extends BasePresenter<RoomContract.View>
getRoomHistoryStateInfo(); getRoomHistoryStateInfo();
getMessages(); getMessages();
getUserPreferences(); getUserPreferences();
getAbsoluteUrl();
} }
@Override @Override
...@@ -76,16 +77,6 @@ public class RoomPresenter extends BasePresenter<RoomContract.View> ...@@ -76,16 +77,6 @@ public class RoomPresenter extends BasePresenter<RoomContract.View>
addSubscription(subscription); addSubscription(subscription);
} }
@Override
public void onViewSetup() {
final Disposable subscription = absoluteUrlHelper.getRocketChatAbsoluteUrl()
.subscribeOn(AndroidSchedulers.from(BackgroundLooper.get()))
.observeOn(AndroidSchedulers.mainThread())
.subscribe(it -> view.setupWith(it.orNull()));
addSubscription(subscription);
}
@Override @Override
public void loadMoreMessages() { public void loadMoreMessages() {
...@@ -248,6 +239,15 @@ public class RoomPresenter extends BasePresenter<RoomContract.View> ...@@ -248,6 +239,15 @@ public class RoomPresenter extends BasePresenter<RoomContract.View>
addSubscription(subscription); addSubscription(subscription);
} }
private void getAbsoluteUrl() {
final Disposable subscription = absoluteUrlHelper.getRocketChatAbsoluteUrl()
.subscribeOn(AndroidSchedulers.from(BackgroundLooper.get()))
.observeOn(AndroidSchedulers.mainThread())
.subscribe(it -> view.setupWith(it.orNull()));
addSubscription(subscription);
}
private Single<Pair<Room, User>> getRoomUserPair() { private Single<Pair<Room, User>> getRoomUserPair() {
return Single.zip( return Single.zip(
getSingleRoom(), getSingleRoom(),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment