Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AloqaIM-Android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
AloqaIM-Android
Commits
e173fca0
Commit
e173fca0
authored
Nov 26, 2016
by
Yusuke Iwaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix logout
parent
b83c2e63
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
20 deletions
+43
-20
MainActivity.java
.../main/java/chat/rocket/android/activity/MainActivity.java
+43
-20
No files found.
app/src/main/java/chat/rocket/android/activity/MainActivity.java
View file @
e173fca0
...
@@ -9,9 +9,9 @@ import chat.rocket.android.R;
...
@@ -9,9 +9,9 @@ import chat.rocket.android.R;
import
chat.rocket.android.fragment.chatroom.HomeFragment
;
import
chat.rocket.android.fragment.chatroom.HomeFragment
;
import
chat.rocket.android.fragment.chatroom.RoomFragment
;
import
chat.rocket.android.fragment.chatroom.RoomFragment
;
import
chat.rocket.android.fragment.sidebar.SidebarMainFragment
;
import
chat.rocket.android.fragment.sidebar.SidebarMainFragment
;
import
chat.rocket.android.helper.TextUtils
;
import
chat.rocket.android.model.internal.Session
;
import
chat.rocket.android.model.internal.Session
;
import
chat.rocket.android.realm_helper.RealmHelper
;
import
chat.rocket.android.realm_helper.RealmHelper
;
import
chat.rocket.android.realm_helper.RealmObjectObserver
;
import
chat.rocket.android.realm_helper.RealmStore
;
import
chat.rocket.android.realm_helper.RealmStore
;
import
hugo.weaving.DebugLog
;
import
hugo.weaving.DebugLog
;
...
@@ -19,11 +19,13 @@ import hugo.weaving.DebugLog;
...
@@ -19,11 +19,13 @@ import hugo.weaving.DebugLog;
* Entry-point for Rocket.Chat.Android application.
* Entry-point for Rocket.Chat.Android application.
*/
*/
public
class
MainActivity
extends
AbstractAuthedActivity
{
public
class
MainActivity
extends
AbstractAuthedActivity
{
private
RealmObjectObserver
<
Session
>
sessionObserver
;
@Override
protected
int
getLayoutContainerForFragment
()
{
@Override
protected
int
getLayoutContainerForFragment
()
{
return
R
.
id
.
activity_main_container
;
return
R
.
id
.
activity_main_container
;
}
}
@Override
protected
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
@Override
protected
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_main
);
setContentView
(
R
.
layout
.
activity_main
);
...
@@ -62,18 +64,16 @@ public class MainActivity extends AbstractAuthedActivity {
...
@@ -62,18 +64,16 @@ public class MainActivity extends AbstractAuthedActivity {
@DebugLog
@DebugLog
@Override
protected
void
onServerConfigIdUpdated
()
{
@Override
protected
void
onServerConfigIdUpdated
()
{
super
.
onServerConfigIdUpdated
();
super
.
onServerConfigIdUpdated
();
updateSessionObserver
();
updateSidebarMainFragment
();
updateSidebarMainFragment
();
showServerConfigActivityIfNeeded
();
}
}
private
void
updateS
idebarMainFragment
()
{
private
void
updateS
essionObserver
()
{
getSupportFragmentManager
().
beginTransaction
()
if
(
sessionObserver
!=
null
)
{
.
replace
(
R
.
id
.
sidebar_fragment_container
,
SidebarMainFragment
.
create
(
serverConfigId
))
sessionObserver
.
unsub
();
.
commit
()
;
sessionObserver
=
null
;
}
}
private
void
showServerConfigActivityIfNeeded
()
{
if
(
serverConfigId
==
null
)
{
if
(
serverConfigId
==
null
)
{
return
;
return
;
}
}
...
@@ -83,17 +83,25 @@ public class MainActivity extends AbstractAuthedActivity {
...
@@ -83,17 +83,25 @@ public class MainActivity extends AbstractAuthedActivity {
return
;
return
;
}
}
Session
session
=
realmHelper
.
executeTransactionForRead
(
realm
->
sessionObserver
=
realmHelper
realm
.
where
(
Session
.
class
).
equalTo
(
"sessionId"
,
Session
.
DEFAULT_ID
).
findFirst
());
.
createObjectObserver
(
realm
->
realm
.
where
(
Session
.
class
)
.
equalTo
(
"sessionId"
,
Session
.
DEFAULT_ID
)
.
isNotNull
(
"token"
)
.
equalTo
(
"tokenVerified"
,
true
)
.
isNull
(
"error"
))
.
setOnUpdateListener
(
session
->
{
if
(
session
==
null
)
{
LaunchUtil
.
showServerConfigActivity
(
this
,
serverConfigId
);
}
});
sessionObserver
.
sub
();
}
if
(
session
!=
null
private
void
updateSidebarMainFragment
()
{
&&
!
TextUtils
.
isEmpty
(
session
.
getToken
())
getSupportFragmentManager
().
beginTransaction
()
&&
session
.
isTokenVerified
()
.
replace
(
R
.
id
.
sidebar_fragment_container
,
SidebarMainFragment
.
create
(
serverConfigId
))
&&
TextUtils
.
isEmpty
(
session
.
getError
()))
{
.
commit
();
// session is OK.
}
else
{
LaunchUtil
.
showServerConfigActivity
(
this
,
serverConfigId
);
}
}
}
@Override
protected
void
onRoomIdUpdated
()
{
@Override
protected
void
onRoomIdUpdated
()
{
...
@@ -107,6 +115,21 @@ public class MainActivity extends AbstractAuthedActivity {
...
@@ -107,6 +115,21 @@ public class MainActivity extends AbstractAuthedActivity {
}
}
}
}
@Override
protected
void
onResume
()
{
super
.
onResume
();
if
(
sessionObserver
!=
null
)
{
sessionObserver
.
keepalive
();
}
}
@Override
protected
void
onDestroy
()
{
if
(
sessionObserver
!=
null
)
{
sessionObserver
.
unsub
();
sessionObserver
=
null
;
}
super
.
onDestroy
();
}
@Override
protected
boolean
onBackPress
()
{
@Override
protected
boolean
onBackPress
()
{
return
closeSidebarIfNeeded
()
||
super
.
onBackPress
();
return
closeSidebarIfNeeded
()
||
super
.
onBackPress
();
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment