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
5f7280f6
Commit
5f7280f6
authored
Jun 16, 2017
by
Enzo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#1 - Change Hostname on logout - fixed RC Cache Crash and RealmConfiguration access same file error
parent
b83023b3
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
9 deletions
+33
-9
SidebarMainFragment.java
.../rocket/android/fragment/sidebar/SidebarMainFragment.java
+3
-3
RocketChatService.java
...n/java/chat/rocket/android/service/RocketChatService.java
+16
-6
Migration.java
...rc/main/java/chat/rocket/persistence/realm/Migration.java
+12
-0
RealmStore.java
...c/main/java/chat/rocket/persistence/realm/RealmStore.java
+2
-0
No files found.
app/src/main/java/chat/rocket/android/fragment/sidebar/SidebarMainFragment.java
View file @
5f7280f6
...
...
@@ -16,7 +16,6 @@ import android.widget.TextView;
import
com.jakewharton.rxbinding2.support.v7.widget.RxSearchView
;
import
com.jakewharton.rxbinding2.widget.RxCompoundButton
;
import
chat.rocket.android.LaunchUtil
;
import
io.reactivex.Observable
;
import
io.reactivex.android.schedulers.AndroidSchedulers
;
...
...
@@ -268,8 +267,9 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
rootView
.
findViewById
(
R
.
id
.
btn_logout
).
setOnClickListener
(
view
->
{
presenter
.
onLogout
();
closeUserActionContainer
();
//go back to the AddServerActivity
LaunchUtil
.
showAddServerActivity
(
getContext
());
// destroy Activity on logout to be able to recreate most of the environment
this
.
getActivity
().
finish
();
});
}
...
...
app/src/main/java/chat/rocket/android/service/RocketChatService.java
View file @
5f7280f6
...
...
@@ -10,6 +10,9 @@ import android.support.annotation.Nullable;
import
java.util.HashMap
;
import
java.util.concurrent.TimeUnit
;
import
chat.rocket.android.activity.MainActivity
;
import
chat.rocket.persistence.realm.RealmStore
;
import
hugo.weaving.DebugLog
;
import
rx.Observable
;
import
rx.Single
;
...
...
@@ -49,7 +52,6 @@ public class RocketChatService extends Service implements ConnectivityServiceInt
@Override
public
void
onCreate
()
{
super
.
onCreate
();
connectivityManager
=
ConnectivityManager
.
getInstanceForInternal
(
getApplicationContext
());
connectivityManager
.
resetConnectivityStateList
();
webSocketThreads
=
new
HashMap
<>();
...
...
@@ -81,10 +83,18 @@ public class RocketChatService extends Service implements ConnectivityServiceInt
RocketChatWebSocketThread
thread
=
webSocketThreads
.
get
(
hostname
);
if
(
thread
!=
null
)
{
return
thread
.
terminate
()
//after disconnection from server, remove RCWebSocket key from HashMap
// after disconnection from server
.
doAfterTerminate
(()
->
{
// remove RCWebSocket key from HashMap
webSocketThreads
.
remove
(
hostname
);
stopSelf
();
// remove RealmConfiguration key from HashMap
RealmStore
.
sStore
.
remove
(
hostname
);
// clear "cache" SharedPreference
this
.
getSharedPreferences
(
"cache"
,
0
).
edit
().
clear
().
apply
();
// start a fresh new MainActivity
Intent
intent
=
new
Intent
(
this
,
MainActivity
.
class
);
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_CLEAR_TASK
|
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
this
.
startActivity
(
intent
);
});
}
else
{
return
Observable
.
timer
(
1
,
TimeUnit
.
SECONDS
).
toSingle
()
...
...
persistence-realm/src/main/java/chat/rocket/persistence/realm/Migration.java
View file @
5f7280f6
...
...
@@ -70,4 +70,16 @@ public class Migration implements RealmMigration {
messageSchema
.
addField
(
RealmMessage
.
EDITED_AT
,
long
.
class
);
}
}
// hack around to avoid "new different configuration cannot access the same file" error
@Override
public
int
hashCode
()
{
return
37
;
}
@Override
public
boolean
equals
(
Object
o
)
{
return
(
o
instanceof
Migration
);
}
// end hack
}
persistence-realm/src/main/java/chat/rocket/persistence/realm/RealmStore.java
View file @
5f7280f6
...
...
@@ -16,6 +16,8 @@ public class RealmStore {
.
modules
(
new
RocketChatLibraryModule
())
.
migration
(
new
Migration
())
.
schemaVersion
(
5
)
// Just in case
.
deleteRealmIfMigrationNeeded
()
.
build
();
}
...
...
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