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
7ab8c5c9
Commit
7ab8c5c9
authored
Nov 17, 2016
by
Yusuke Iwaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix coding style.
parent
32d380d4
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
25 additions
and
14 deletions
+25
-14
LaunchUtil.java
app/src/main/java/chat/rocket/android/LaunchUtil.java
+3
-0
RocketChatCache.java
app/src/main/java/chat/rocket/android/RocketChatCache.java
+4
-0
AbstractAuthedActivity.java
.../chat/rocket/android/activity/AbstractAuthedActivity.java
+2
-2
ServerConfig.java
...src/main/java/chat/rocket/android/model/ServerConfig.java
+4
-1
RocketChatService.java
...n/java/chat/rocket/android/service/RocketChatService.java
+3
-3
RocketChatWebSocketThread.java
...hat/rocket/android/service/RocketChatWebSocketThread.java
+2
-1
MethodCallObserver.java
...t/rocket/android/service/observer/MethodCallObserver.java
+7
-7
No files found.
app/src/main/java/chat/rocket/android/LaunchUtil.java
View file @
7ab8c5c9
...
...
@@ -10,6 +10,9 @@ import chat.rocket.android.activity.ServerConfigActivity;
*/
public
class
LaunchUtil
{
/**
* launch AddServerActivity with proper flags.
*/
public
static
void
showAddServerActivity
(
Context
context
)
{
Intent
intent
=
new
Intent
(
context
,
AddServerActivity
.
class
);
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_REORDER_TO_FRONT
|
Intent
.
FLAG_ACTIVITY_CLEAR_TOP
);
...
...
app/src/main/java/chat/rocket/android/RocketChatCache.java
View file @
7ab8c5c9
...
...
@@ -8,6 +8,10 @@ import android.content.SharedPreferences;
*/
public
class
RocketChatCache
{
public
static
final
String
KEY_SELECTED_SERVER_CONFIG_ID
=
"selectedServerConfigId"
;
/**
* get SharedPreference instance for RocketChat application cache.
*/
public
static
SharedPreferences
get
(
Context
context
)
{
return
context
.
getSharedPreferences
(
"cache"
,
Context
.
MODE_PRIVATE
);
}
...
...
app/src/main/java/chat/rocket/android/activity/AbstractAuthedActivity.java
View file @
7ab8c5c9
...
...
@@ -24,8 +24,8 @@ abstract class AbstractAuthedActivity extends AbstractFragmentActivity {
protected
String
serverConfigId
;
SharedPreferences
.
OnSharedPreferenceChangeListener
preferenceChangeListener
=
(
sharedPreferences
,
s
)
->
{
if
(
RocketChatCache
.
KEY_SELECTED_SERVER_CONFIG_ID
.
equals
(
s
))
{
(
sharedPreferences
,
key
)
->
{
if
(
RocketChatCache
.
KEY_SELECTED_SERVER_CONFIG_ID
.
equals
(
key
))
{
updateServerConfigIdIfNeeded
(
sharedPreferences
);
}
};
...
...
app/src/main/java/chat/rocket/android/model/ServerConfig.java
View file @
7ab8c5c9
...
...
@@ -75,7 +75,10 @@ public class ServerConfig extends RealmObject {
.
continueWith
(
new
LogcatIfError
());
}
public
static
Task
<
Void
>
setState
(
final
String
serverConfigId
,
int
state
)
{
/**
* Update the state of the ServerConfig with serverConfigId.
*/
public
static
Task
<
Void
>
updateState
(
final
String
serverConfigId
,
int
state
)
{
return
RealmStore
.
getDefault
().
executeTransaction
(
realm
->
{
ServerConfig
config
=
realm
.
where
(
ServerConfig
.
class
).
equalTo
(
"serverConfigId"
,
serverConfigId
).
findFirst
();
...
...
app/src/main/java/chat/rocket/android/service/RocketChatService.java
View file @
7ab8c5c9
...
...
@@ -113,16 +113,16 @@ public class RocketChatService extends Service {
private
Task
<
RocketChatWebSocketThread
>
findOrCreateWebSocketThread
(
final
ServerConfig
config
)
{
final
String
serverConfigId
=
config
.
getServerConfigId
();
if
(
webSocketThreads
.
containsKey
(
serverConfigId
))
{
return
ServerConfig
.
set
State
(
serverConfigId
,
ServerConfig
.
STATE_CONNECTED
)
return
ServerConfig
.
update
State
(
serverConfigId
,
ServerConfig
.
STATE_CONNECTED
)
.
onSuccessTask
(
_task
->
Task
.
forResult
(
webSocketThreads
.
get
(
serverConfigId
)));
}
else
{
return
ServerConfig
.
set
State
(
serverConfigId
,
ServerConfig
.
STATE_CONNECTING
)
return
ServerConfig
.
update
State
(
serverConfigId
,
ServerConfig
.
STATE_CONNECTING
)
.
onSuccessTask
(
_task
->
{
webSocketThreads
.
put
(
serverConfigId
,
null
);
return
RocketChatWebSocketThread
.
getStarted
(
getApplicationContext
(),
config
);
})
.
onSuccessTask
(
task
->
ServerConfig
.
set
State
(
serverConfigId
,
ServerConfig
.
STATE_CONNECTED
)
ServerConfig
.
update
State
(
serverConfigId
,
ServerConfig
.
STATE_CONNECTED
)
.
onSuccessTask
(
_task
->
task
))
.
onSuccessTask
(
task
->
{
webSocketThreads
.
put
(
serverConfigId
,
task
.
getResult
());
...
...
app/src/main/java/chat/rocket/android/service/RocketChatWebSocketThread.java
View file @
7ab8c5c9
...
...
@@ -84,7 +84,8 @@ public class RocketChatWebSocketThread extends HandlerThread {
private
void
forceInvalidateTokens
()
{
serverConfigRealm
.
executeTransaction
(
realm
->
{
Session
session
=
realm
.
where
(
Session
.
class
).
equalTo
(
"sessionId"
,
Session
.
DEFAULT_ID
).
findFirst
();
Session
session
=
realm
.
where
(
Session
.
class
)
.
equalTo
(
"sessionId"
,
Session
.
DEFAULT_ID
).
findFirst
();
if
(
session
!=
null
&&
!
TextUtils
.
isEmpty
(
session
.
getToken
())
&&
(
session
.
isTokenVerified
()
||
!
TextUtils
.
isEmpty
(
session
.
getError
())))
{
...
...
app/src/main/java/chat/rocket/android/service/observer/MethodCallObserver.java
View file @
7ab8c5c9
...
...
@@ -19,6 +19,7 @@ import org.json.JSONObject;
public
class
MethodCallObserver
extends
AbstractModelObserver
<
MethodCall
>
{
private
String
prevHash
;
/**
* constructor.
*/
...
...
@@ -94,13 +95,12 @@ public class MethodCallObserver extends AbstractModelObserver<MethodCall> {
).
onSuccessTask
(
task
->
webSocketAPI
.
rpc
(
methodCallId
,
methodName
,
params
,
timeout
)
.
onSuccessTask
(
_task
->
realmHelper
.
executeTransaction
(
realm
->
{
String
json
=
_task
.
getResult
().
result
;
return
realm
.
createOrUpdateObjectFromJson
(
MethodCall
.
class
,
new
JSONObject
()
.
put
(
"methodCallId"
,
methodCallId
)
.
put
(
"syncstate"
,
SyncState
.
SYNCED
)
.
put
(
"resultJson"
,
json
));
})
)
String
json
=
_task
.
getResult
().
result
;
return
realm
.
createOrUpdateObjectFromJson
(
MethodCall
.
class
,
new
JSONObject
()
.
put
(
"methodCallId"
,
methodCallId
)
.
put
(
"syncstate"
,
SyncState
.
SYNCED
)
.
put
(
"resultJson"
,
json
));
}))
).
continueWithTask
(
task
->
{
if
(
task
.
isFaulted
())
{
return
realmHelper
.
executeTransaction
(
realm
->
{
...
...
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