Fix up singleton to store room state

Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
Mario Danic 2018-06-19 20:46:20 +02:00
Родитель 76fc46ab04
Коммит caebce2b22
2 изменённых файлов: 31 добавлений и 36 удалений

Просмотреть файл

@ -979,42 +979,37 @@ public class CallController extends BaseController {
connectingView.setVisibility(View.GONE);
conversationView.setVisibility(View.VISIBLE);
// start pinging the call
if (!hasChatSupport) {
ApplicationWideCurrentRoomHolder.getInstance().setCurrentRoomId(roomId);
ApplicationWideCurrentRoomHolder.getInstance().setInCall(true);
ApplicationWideCurrentRoomHolder.getInstance().setUserInRoom(userEntity);
ApplicationWideCurrentRoomHolder.getInstance().setCurrentRoomId(roomId);
ApplicationWideCurrentRoomHolder.getInstance().setInCall(true);
ApplicationWideCurrentRoomHolder.getInstance().setUserInRoom(userEntity);
ncApi.pingCall(credentials, ApiUtils.getUrlForCallPing(baseUrl, roomToken))
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.repeatWhen(observable -> observable.delay(5000, TimeUnit.MILLISECONDS))
.takeWhile(observable -> inCall)
.retry(3, observable -> inCall)
.subscribe(new Observer<GenericOverall>() {
@Override
public void onSubscribe(Disposable d) {
pingDisposable = d;
}
ncApi.pingCall(credentials, ApiUtils.getUrlForCallPing(baseUrl, roomToken))
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.repeatWhen(observable -> observable.delay(5000, TimeUnit.MILLISECONDS))
.takeWhile(observable -> inCall)
.retry(3, observable -> inCall)
.subscribe(new Observer<GenericOverall>() {
@Override
public void onSubscribe(Disposable d) {
pingDisposable = d;
}
@Override
public void onNext(GenericOverall genericOverall) {
@Override
public void onNext(GenericOverall genericOverall) {
}
}
@Override
public void onError(Throwable e) {
dispose(pingDisposable);
}
@Override
public void onError(Throwable e) {
dispose(pingDisposable);
}
@Override
public void onComplete() {
dispose(pingDisposable);
}
});
} else {
ApplicationWideCurrentRoomHolder.getInstance().setInCall(true);
}
@Override
public void onComplete() {
dispose(pingDisposable);
}
});
// Start pulling signaling messages
String urlToken = null;

Просмотреть файл

@ -156,7 +156,7 @@ public class ChatController extends BaseController implements MessagesListAdapte
private int newMessagesCount = 0;
private Boolean startCallFromNotification;
private String roomId;
private boolean voiceOnly = false;
private boolean voiceOnly;
public ChatController(Bundle args) {
super(args);
@ -173,10 +173,6 @@ public class ChatController extends BaseController implements MessagesListAdapte
this.roomId = args.getString(BundleKeys.KEY_ROOM_ID, "");
ApplicationWideCurrentRoomHolder.getInstance().setCurrentRoomId(roomId);
ApplicationWideCurrentRoomHolder.getInstance().setInCall(false);
ApplicationWideCurrentRoomHolder.getInstance().setUserInRoom(conversationUser);
this.roomToken = args.getString(BundleKeys.KEY_ROOM_TOKEN, "");
if (args.containsKey(BundleKeys.KEY_ACTIVE_CONVERSATION)) {
@ -414,6 +410,10 @@ public class ChatController extends BaseController implements MessagesListAdapte
getActionBar().setDisplayHomeAsUpEnabled(true);
}
ApplicationWideCurrentRoomHolder.getInstance().setCurrentRoomId(roomId);
ApplicationWideCurrentRoomHolder.getInstance().setInCall(false);
ApplicationWideCurrentRoomHolder.getInstance().setUserInRoom(conversationUser);
if (mentionAutocomplete != null && mentionAutocomplete.isPopupShowing()) {
mentionAutocomplete.dismissPopup();
}