From caebce2b22391240fa6069949e00ce6bdd821a18 Mon Sep 17 00:00:00 2001 From: Mario Danic Date: Tue, 19 Jun 2018 20:46:20 +0200 Subject: [PATCH] Fix up singleton to store room state Signed-off-by: Mario Danic --- .../talk/controllers/CallController.java | 57 +++++++++---------- .../talk/controllers/ChatController.java | 10 ++-- 2 files changed, 31 insertions(+), 36 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/controllers/CallController.java b/app/src/main/java/com/nextcloud/talk/controllers/CallController.java index ec61f4d42..e0fd6c13a 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/CallController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/CallController.java @@ -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() { - @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() { + @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; diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ChatController.java b/app/src/main/java/com/nextcloud/talk/controllers/ChatController.java index 7df10c678..de81ab72f 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ChatController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/ChatController.java @@ -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(); }