Commit 3f049ecb authored by Yusuke Iwaki's avatar Yusuke Iwaki

fix NPE

parent c77a90ae
......@@ -164,7 +164,7 @@ public class MainActivity extends AbstractAuthedActivity {
protected void onRoomIdUpdated() {
super.onRoomIdUpdated();
if (roomId != null) {
if (roomId != null && RoomFragment.canCreate(RealmStore.get(serverConfigId))) {
showFragment(RoomFragment.create(serverConfigId, roomId));
closeSidebarIfNeeded();
} else {
......
......@@ -67,6 +67,14 @@ public class RoomFragment extends AbstractChatRoomFragment
public RoomFragment() {
}
public static boolean canCreate(RealmHelper realmHelper) {
User currentUser = realmHelper.executeTransactionForRead(realm ->
User.queryCurrentUser(realm).findFirst());
Session session = realmHelper.executeTransactionForRead(realm ->
Session.queryDefaultSession(realm).findFirst());
return currentUser != null && session != null;
}
/**
* create fragment with roomId.
*/
......
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