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
5ee45e9f
Commit
5ee45e9f
authored
Jan 30, 2017
by
Tiago Cunha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Try to recover from error
parent
38bb34f9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
1 deletion
+23
-1
AbstractAuthedActivity.java
.../chat/rocket/android/activity/AbstractAuthedActivity.java
+23
-1
No files found.
app/src/main/java/chat/rocket/android/activity/AbstractAuthedActivity.java
View file @
5ee45e9f
...
...
@@ -5,13 +5,15 @@ import android.content.SharedPreferences;
import
android.os.Bundle
;
import
android.support.annotation.Nullable
;
import
java.util.List
;
import
chat.rocket.android.LaunchUtil
;
import
chat.rocket.android.RocketChatCache
;
import
chat.rocket.android.model.ddp.RoomSubscription
;
import
chat.rocket.android.push.PushConstants
;
import
chat.rocket.android.push.PushNotificationHandler
;
import
chat.rocket.android.realm_helper.RealmListObserver
;
import
chat.rocket.android.realm_helper.RealmStore
;
import
chat.rocket.android.service.ConnectivityManager
;
import
chat.rocket.android.service.ServerInfo
;
import
icepick.State
;
abstract
class
AbstractAuthedActivity
extends
AbstractFragmentActivity
{
...
...
@@ -68,10 +70,14 @@ abstract class AbstractAuthedActivity extends AbstractFragmentActivity {
if
(
hostname
==
null
)
{
if
(
newHostname
!=
null
&&
assertServerRealmStoreExists
(
newHostname
))
{
updateHostname
(
newHostname
);
}
else
{
recoverFromHostnameError
(
prefs
);
}
}
else
{
if
(!
hostname
.
equals
(
newHostname
)
&&
assertServerRealmStoreExists
(
newHostname
))
{
updateHostname
(
newHostname
);
}
else
{
recoverFromHostnameError
(
prefs
);
}
}
}
...
...
@@ -85,6 +91,22 @@ abstract class AbstractAuthedActivity extends AbstractFragmentActivity {
onHostnameUpdated
();
}
private
void
recoverFromHostnameError
(
SharedPreferences
prefs
)
{
final
List
<
ServerInfo
>
serverInfoList
=
ConnectivityManager
.
getInstance
(
getApplicationContext
()).
getServerList
();
if
(
serverInfoList
==
null
||
serverInfoList
.
size
()
==
0
)
{
LaunchUtil
.
showAddServerActivity
(
this
);
return
;
}
// just connect to the first available
final
ServerInfo
serverInfo
=
serverInfoList
.
get
(
0
);
prefs
.
edit
()
.
putString
(
RocketChatCache
.
KEY_SELECTED_SERVER_HOSTNAME
,
serverInfo
.
hostname
)
.
remove
(
RocketChatCache
.
KEY_SELECTED_ROOM_ID
)
.
apply
();
}
private
void
updateRoomIdIfNeeded
(
SharedPreferences
prefs
)
{
String
newRoomId
=
prefs
.
getString
(
RocketChatCache
.
KEY_SELECTED_ROOM_ID
,
null
);
if
(
roomId
==
null
)
{
...
...
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