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
feb65d69
Commit
feb65d69
authored
Nov 11, 2016
by
Yusuke Iwaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix code style
parent
ffd30513
Changes
24
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
78 additions
and
61 deletions
+78
-61
LaunchUtil.java
app/src/main/java/chat/rocket/android/LaunchUtil.java
+1
-1
MainActivity.java
.../main/java/chat/rocket/android/activity/MainActivity.java
+1
-1
ServerConfigActivity.java
...va/chat/rocket/android/activity/ServerConfigActivity.java
+4
-4
RoomFragment.java
...a/chat/rocket/android/fragment/chatroom/RoomFragment.java
+1
-1
GitHubOAuthFragment.java
...at/rocket/android/fragment/oauth/GitHubOAuthFragment.java
+2
-2
AbstractServerConfigFragment.java
.../fragment/server_config/AbstractServerConfigFragment.java
+1
-1
InputHostnameFragment.java
...android/fragment/server_config/InputHostnameFragment.java
+3
-3
LoginFragment.java
.../rocket/android/fragment/server_config/LoginFragment.java
+1
-1
MethodCallHelper.java
...ain/java/chat/rocket/android/helper/MethodCallHelper.java
+2
-2
RoomListManager.java
...rocket/android/layouthelper/chatroom/RoomListManager.java
+1
-1
MethodCall.java
app/src/main/java/chat/rocket/android/model/MethodCall.java
+20
-12
ServerConfig.java
...src/main/java/chat/rocket/android/model/ServerConfig.java
+16
-8
Email.java
app/src/main/java/chat/rocket/android/model/ddp/Email.java
+2
-2
MeteorLoginServiceConfiguration.java
...et/android/model/ddp/MeteorLoginServiceConfiguration.java
+1
-1
RoomSubscription.java
.../java/chat/rocket/android/model/ddp/RoomSubscription.java
+1
-1
User.java
app/src/main/java/chat/rocket/android/model/ddp/User.java
+1
-1
RocketChatService.java
...n/java/chat/rocket/android/service/RocketChatService.java
+2
-2
RocketChatWebSocketThread.java
...hat/rocket/android/service/RocketChatWebSocketThread.java
+5
-5
AbstractDDPDocEventSubscriber.java
...et/android/service/ddp/AbstractDDPDocEventSubscriber.java
+1
-1
ActiveUsersSubscriber.java
...hat/rocket/android/service/ddp/ActiveUsersSubscriber.java
+3
-2
LoginServiceConfigurationSubscriber.java
...roid/service/ddp/LoginServiceConfigurationSubscriber.java
+2
-2
MethodCallObserver.java
...t/rocket/android/service/observer/MethodCallObserver.java
+4
-4
SessionObserver.java
...chat/rocket/android/service/observer/SessionObserver.java
+2
-2
checkstyle-suppressions.xml
config/quality/checkstyle/checkstyle-suppressions.xml
+1
-1
No files found.
app/src/main/java/chat/rocket/android/LaunchUtil.java
View file @
feb65d69
...
...
@@ -14,7 +14,7 @@ public class LaunchUtil {
public
static
void
showServerConfigActivity
(
Context
context
,
String
serverCondigId
)
{
Intent
intent
=
new
Intent
(
context
,
ServerConfigActivity
.
class
);
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_REORDER_TO_FRONT
|
Intent
.
FLAG_ACTIVITY_CLEAR_TOP
);
intent
.
putExtra
(
"
i
d"
,
serverCondigId
);
intent
.
putExtra
(
"
serverConfigI
d"
,
serverCondigId
);
context
.
startActivity
(
intent
);
}
}
app/src/main/java/chat/rocket/android/activity/MainActivity.java
View file @
feb65d69
...
...
@@ -11,7 +11,7 @@ import chat.rocket.android.fragment.chatroom.HomeFragment;
import
chat.rocket.android.fragment.chatroom.RoomFragment
;
import
chat.rocket.android.helper.Avatar
;
import
chat.rocket.android.layouthelper.chatroom.RoomListManager
;
import
chat.rocket.android.model.RoomSubscription
;
import
chat.rocket.android.model.
ddp.
RoomSubscription
;
import
com.jakewharton.rxbinding.view.RxView
;
import
com.jakewharton.rxbinding.widget.RxCompoundButton
;
import
io.realm.Realm
;
...
...
app/src/main/java/chat/rocket/android/activity/ServerConfigActivity.java
View file @
feb65d69
...
...
@@ -27,7 +27,7 @@ public class ServerConfigActivity extends AbstractFragmentActivity {
private
RealmObjectObserver
<
ServerConfig
>
serverConfigObserver
=
new
RealmObjectObserver
<
ServerConfig
>()
{
@Override
protected
RealmQuery
<
ServerConfig
>
query
(
Realm
realm
)
{
return
realm
.
where
(
ServerConfig
.
class
).
equalTo
(
"
i
d"
,
serverConfigId
);
return
realm
.
where
(
ServerConfig
.
class
).
equalTo
(
"
serverConfigI
d"
,
serverConfigId
);
}
@Override
protected
void
onChange
(
ServerConfig
config
)
{
...
...
@@ -69,7 +69,7 @@ public class ServerConfigActivity extends AbstractFragmentActivity {
}
private
static
boolean
launchFor
(
Context
context
,
ServerConfig
config
)
{
LaunchUtil
.
showServerConfigActivity
(
context
,
config
.
getId
());
LaunchUtil
.
showServerConfigActivity
(
context
,
config
.
get
ServerConfig
Id
());
return
true
;
}
...
...
@@ -86,7 +86,7 @@ public class ServerConfigActivity extends AbstractFragmentActivity {
return
;
}
serverConfigId
=
intent
.
getStringExtra
(
"
i
d"
);
serverConfigId
=
intent
.
getStringExtra
(
"
serverConfigI
d"
);
if
(
TextUtils
.
isEmpty
(
serverConfigId
))
{
finish
();
return
;
...
...
@@ -154,7 +154,7 @@ public class ServerConfigActivity extends AbstractFragmentActivity {
if
(
args
==
null
)
{
args
=
new
Bundle
();
}
args
.
putString
(
"
i
d"
,
serverConfigId
);
args
.
putString
(
"
serverConfigI
d"
,
serverConfigId
);
fragment
.
setArguments
(
args
);
}
...
...
app/src/main/java/chat/rocket/android/fragment/chatroom/RoomFragment.java
View file @
feb65d69
...
...
@@ -3,7 +3,7 @@ package chat.rocket.android.fragment.chatroom;
import
android.os.Bundle
;
import
android.support.annotation.Nullable
;
import
chat.rocket.android.R
;
import
chat.rocket.android.model.RoomSubscription
;
import
chat.rocket.android.model.
ddp.
RoomSubscription
;
import
io.realm.Realm
;
import
io.realm.RealmQuery
;
import
jp.co.crowdworks.realm_java_helpers.RealmObjectObserver
;
...
...
app/src/main/java/chat/rocket/android/fragment/oauth/GitHubOAuthFragment.java
View file @
feb65d69
...
...
@@ -9,7 +9,7 @@ import android.webkit.WebView;
import
chat.rocket.android.fragment.AbstractWebViewFragment
;
import
chat.rocket.android.helper.LogcatIfError
;
import
chat.rocket.android.helper.MethodCallHelper
;
import
chat.rocket.android.model.MeteorLoginServiceConfiguration
;
import
chat.rocket.android.model.
ddp.
MeteorLoginServiceConfiguration
;
import
chat.rocket.android.model.ServerConfig
;
import
java.nio.charset.Charset
;
import
jp.co.crowdworks.realm_java_helpers.RealmHelper
;
...
...
@@ -51,7 +51,7 @@ public class GitHubOAuthFragment extends AbstractWebViewFragment {
serverConfigId
=
args
.
getString
(
"serverConfigId"
);
ServerConfig
serverConfig
=
RealmHelper
.
executeTransactionForRead
(
realm
->
realm
.
where
(
ServerConfig
.
class
).
equalTo
(
"
i
d"
,
serverConfigId
).
findFirst
());
realm
.
where
(
ServerConfig
.
class
).
equalTo
(
"
serverConfigI
d"
,
serverConfigId
).
findFirst
());
MeteorLoginServiceConfiguration
oauthConfig
=
RealmHelper
.
executeTransactionForRead
(
realm
->
realm
.
where
(
MeteorLoginServiceConfiguration
.
class
)
.
equalTo
(
"service"
,
"github"
)
...
...
app/src/main/java/chat/rocket/android/fragment/server_config/AbstractServerConfigFragment.java
View file @
feb65d69
...
...
@@ -21,7 +21,7 @@ abstract class AbstractServerConfigFragment extends AbstractFragment
return
;
}
serverConfigId
=
args
.
getString
(
"
i
d"
);
serverConfigId
=
args
.
getString
(
"
serverConfigI
d"
);
if
(
TextUtils
.
isEmpty
(
serverConfigId
))
{
finish
();
return
;
...
...
app/src/main/java/chat/rocket/android/fragment/server_config/InputHostnameFragment.java
View file @
feb65d69
...
...
@@ -25,7 +25,7 @@ public class InputHostnameFragment extends AbstractServerConfigFragment {
};
RealmObjectObserver
<
ServerConfig
>
serverConfigObserver
=
new
RealmObjectObserver
<
ServerConfig
>()
{
@Override
protected
RealmQuery
<
ServerConfig
>
query
(
Realm
realm
)
{
return
realm
.
where
(
ServerConfig
.
class
).
equalTo
(
"
i
d"
,
serverConfigId
);
return
realm
.
where
(
ServerConfig
.
class
).
equalTo
(
"
serverConfigI
d"
,
serverConfigId
);
}
@Override
protected
void
onChange
(
ServerConfig
config
)
{
...
...
@@ -54,7 +54,7 @@ public class InputHostnameFragment extends AbstractServerConfigFragment {
RealmHelperBolts
.
executeTransaction
(
realm
->
realm
.
createOrUpdateObjectFromJson
(
ServerConfig
.
class
,
new
JSONObject
().
put
(
"
i
d"
,
serverConfigId
)
new
JSONObject
().
put
(
"
serverConfigI
d"
,
serverConfigId
)
.
put
(
"hostname"
,
hostname
)
.
put
(
"connectionError"
,
JSONObject
.
NULL
)
.
put
(
"session"
,
JSONObject
.
NULL
))).
continueWith
(
new
LogcatIfError
());
...
...
@@ -91,7 +91,7 @@ public class InputHostnameFragment extends AbstractServerConfigFragment {
private
void
clearConnectionErrorAndHostname
()
{
RealmHelperBolts
.
executeTransaction
(
realm
->
realm
.
createOrUpdateObjectFromJson
(
ServerConfig
.
class
,
new
JSONObject
().
put
(
"
i
d"
,
serverConfigId
)
new
JSONObject
().
put
(
"
serverConfigI
d"
,
serverConfigId
)
.
put
(
"hostname"
,
JSONObject
.
NULL
)
.
put
(
"connectionError"
,
JSONObject
.
NULL
))).
continueWith
(
new
LogcatIfError
());
}
...
...
app/src/main/java/chat/rocket/android/fragment/server_config/LoginFragment.java
View file @
feb65d69
...
...
@@ -7,7 +7,7 @@ import chat.rocket.android.R;
import
chat.rocket.android.fragment.oauth.GitHubOAuthFragment
;
import
chat.rocket.android.helper.MethodCallHelper
;
import
chat.rocket.android.helper.TextUtils
;
import
chat.rocket.android.model.MeteorLoginServiceConfiguration
;
import
chat.rocket.android.model.
ddp.
MeteorLoginServiceConfiguration
;
import
io.realm.Realm
;
import
io.realm.RealmResults
;
import
java.util.List
;
...
...
app/src/main/java/chat/rocket/android/helper/MethodCallHelper.java
View file @
feb65d69
...
...
@@ -4,7 +4,7 @@ import android.util.Patterns;
import
bolts.Continuation
;
import
bolts.Task
;
import
chat.rocket.android.model.MethodCall
;
import
chat.rocket.android.model.RoomSubscription
;
import
chat.rocket.android.model.
ddp.
RoomSubscription
;
import
chat.rocket.android.model.ServerConfig
;
import
chat.rocket.android.ws.RocketChatWebSocketAPI
;
import
java.util.UUID
;
...
...
@@ -96,7 +96,7 @@ public class MethodCallHelper {
private
Task
<
Void
>
saveToken
(
Task
<
String
>
task
)
{
return
RealmHelperBolts
.
executeTransaction
(
realm
->
realm
.
createOrUpdateObjectFromJson
(
ServerConfig
.
class
,
new
JSONObject
()
.
put
(
"
i
d"
,
serverConfigId
)
.
put
(
"
serverConfigI
d"
,
serverConfigId
)
.
put
(
"token"
,
task
.
getResult
())
.
put
(
"tokenVerified"
,
true
)));
}
...
...
app/src/main/java/chat/rocket/android/layouthelper/chatroom/RoomListManager.java
View file @
feb65d69
...
...
@@ -3,7 +3,7 @@ package chat.rocket.android.layouthelper.chatroom;
import
android.view.View
;
import
android.view.ViewGroup
;
import
chat.rocket.android.helper.TextUtils
;
import
chat.rocket.android.model.RoomSubscription
;
import
chat.rocket.android.model.
ddp.
RoomSubscription
;
import
chat.rocket.android.widget.internal.RoomListItemView
;
import
java.util.List
;
...
...
app/src/main/java/chat/rocket/android/model/MethodCall.java
View file @
feb65d69
...
...
@@ -14,22 +14,21 @@ import jp.co.crowdworks.realm_java_helpers_bolts.RealmHelperBolts;
import
org.json.JSONException
;
import
org.json.JSONObject
;
@SuppressWarnings
(
"PMD.ShortVariable"
)
public
class
MethodCall
extends
RealmObject
{
@PrimaryKey
private
String
i
d
;
@PrimaryKey
private
String
methodCallI
d
;
private
String
serverConfigId
;
//not ServerConfig!(not to be notified the change of ServerConfig)
private
int
syncstate
;
private
String
name
;
private
String
paramsJson
;
private
String
resultJson
;
public
String
getId
()
{
return
i
d
;
public
String
get
MethodCall
Id
()
{
return
methodCallI
d
;
}
public
void
set
Id
(
String
i
d
)
{
this
.
id
=
i
d
;
public
void
set
MethodCallId
(
String
methodCallI
d
)
{
this
.
methodCallId
=
methodCallI
d
;
}
public
String
getServerConfigId
()
{
...
...
@@ -82,12 +81,15 @@ public class MethodCall extends RealmObject {
}
}
/**
* insert a new record to request a method call.
*/
public
static
Task
<
JSONObject
>
execute
(
String
serverConfigId
,
String
name
,
String
paramsJson
)
{
final
String
newId
=
UUID
.
randomUUID
().
toString
();
TaskCompletionSource
<
JSONObject
>
task
=
new
TaskCompletionSource
<>();
RealmHelperBolts
.
executeTransaction
(
realm
->
{
MethodCall
call
=
realm
.
createObjectFromJson
(
MethodCall
.
class
,
new
JSONObject
()
.
put
(
"
i
d"
,
newId
)
.
put
(
"
methodCallI
d"
,
newId
)
.
put
(
"serverConfigId"
,
serverConfigId
)
.
put
(
"syncstate"
,
SyncState
.
NOT_SYNCED
)
.
put
(
"name"
,
name
));
...
...
@@ -99,7 +101,7 @@ public class MethodCall extends RealmObject {
}
else
{
new
RealmObjectObserver
<
MethodCall
>()
{
@Override
protected
RealmQuery
<
MethodCall
>
query
(
Realm
realm
)
{
return
realm
.
where
(
MethodCall
.
class
).
equalTo
(
"
i
d"
,
newId
);
return
realm
.
where
(
MethodCall
.
class
).
equalTo
(
"
methodCallI
d"
,
newId
);
}
@Override
protected
void
onChange
(
MethodCall
methodCall
)
{
...
...
@@ -111,10 +113,10 @@ public class MethodCall extends RealmObject {
}
catch
(
JSONException
exception
)
{
task
.
setError
(
new
Error
(
exception
));
}
exit
(
methodCall
.
getId
());
exit
(
methodCall
.
get
MethodCall
Id
());
}
else
if
(
syncstate
==
SyncState
.
FAILED
)
{
task
.
setError
(
new
Error
(
methodCall
.
getResultJson
()));
exit
(
methodCall
.
getId
());
exit
(
methodCall
.
get
MethodCall
Id
());
}
}
...
...
@@ -129,8 +131,14 @@ public class MethodCall extends RealmObject {
return
task
.
getTask
();
}
public
static
final
Task
<
Void
>
remove
(
String
id
)
{
/**
* remove the request.
*/
public
static
final
Task
<
Void
>
remove
(
String
methodCallId
)
{
return
RealmHelperBolts
.
executeTransaction
(
realm
->
realm
.
where
(
MethodCall
.
class
).
equalTo
(
"id"
,
id
).
findAll
().
deleteAllFromRealm
());
realm
.
where
(
MethodCall
.
class
)
.
equalTo
(
"methodCallId"
,
methodCallId
)
.
findAll
()
.
deleteAllFromRealm
());
}
}
app/src/main/java/chat/rocket/android/model/ServerConfig.java
View file @
feb65d69
...
...
@@ -15,9 +15,8 @@ import org.json.JSONObject;
/**
* Server configuration.
*/
@SuppressWarnings
(
"PMD.ShortVariable"
)
public
class
ServerConfig
extends
RealmObject
{
@PrimaryKey
private
String
i
d
;
@PrimaryKey
private
String
serverConfigI
d
;
private
String
hostname
;
private
String
connectionError
;
private
String
session
;
...
...
@@ -28,6 +27,9 @@ public class ServerConfig extends RealmObject {
return
realm
.
where
(
ServerConfig
.
class
).
equalTo
(
"tokenVerified"
,
false
);
}
/**
* Check if connection login required exists.
*/
public
static
boolean
hasLoginRequiredConnection
()
{
ServerConfig
config
=
RealmHelper
.
executeTransactionForRead
(
realm
->
...
...
@@ -36,6 +38,9 @@ public class ServerConfig extends RealmObject {
return
config
!=
null
;
}
/**
* Request token refresh.
*/
public
static
Task
<
Void
>
forceInvalidateToken
()
{
return
RealmHelperBolts
.
executeTransaction
(
realm
->
{
RealmResults
<
ServerConfig
>
targetConfigs
=
realm
.
where
(
ServerConfig
.
class
)
...
...
@@ -49,21 +54,24 @@ public class ServerConfig extends RealmObject {
});
}
@DebugLog
public
static
void
logConnectionError
(
String
id
,
Exception
exception
)
{
/**
* Log the server connection is lost due to soem exception.
*/
@DebugLog
public
static
void
logConnectionError
(
String
serverConfigId
,
Exception
exception
)
{
RealmHelperBolts
.
executeTransaction
(
realm
->
realm
.
createOrUpdateObjectFromJson
(
ServerConfig
.
class
,
new
JSONObject
()
.
put
(
"
id"
,
i
d
)
.
put
(
"
serverConfigId"
,
serverConfigI
d
)
.
put
(
"connectionError"
,
exception
.
getMessage
())
.
put
(
"session"
,
JSONObject
.
NULL
)))
.
continueWith
(
new
LogcatIfError
());
}
public
String
getId
()
{
return
i
d
;
public
String
get
ServerConfig
Id
()
{
return
serverConfigI
d
;
}
public
void
set
Id
(
String
i
d
)
{
this
.
id
=
i
d
;
public
void
set
ServerConfigId
(
String
serverConfigI
d
)
{
this
.
serverConfigId
=
serverConfigI
d
;
}
public
String
getHostname
()
{
...
...
app/src/main/java/chat/rocket/android/model/Email.java
→
app/src/main/java/chat/rocket/android/model/
ddp/
Email.java
View file @
feb65d69
package
chat
.
rocket
.
android
.
model
;
package
chat
.
rocket
.
android
.
model
.
ddp
;
import
io.realm.RealmObject
;
import
io.realm.annotations.PrimaryKey
;
/**
* Login-User's email
* Login-User's email
.
*/
public
class
Email
extends
RealmObject
{
@PrimaryKey
private
String
address
;
...
...
app/src/main/java/chat/rocket/android/model/MeteorLoginServiceConfiguration.java
→
app/src/main/java/chat/rocket/android/model/
ddp/
MeteorLoginServiceConfiguration.java
View file @
feb65d69
package
chat
.
rocket
.
android
.
model
;
package
chat
.
rocket
.
android
.
model
.
ddp
;
import
io.realm.RealmObject
;
import
io.realm.annotations.PrimaryKey
;
...
...
app/src/main/java/chat/rocket/android/model/RoomSubscription.java
→
app/src/main/java/chat/rocket/android/model/
ddp/
RoomSubscription.java
View file @
feb65d69
package
chat
.
rocket
.
android
.
model
;
package
chat
.
rocket
.
android
.
model
.
ddp
;
import
io.realm.RealmObject
;
import
io.realm.annotations.PrimaryKey
;
...
...
app/src/main/java/chat/rocket/android/model/User.java
→
app/src/main/java/chat/rocket/android/model/
ddp/
User.java
View file @
feb65d69
package
chat
.
rocket
.
android
.
model
;
package
chat
.
rocket
.
android
.
model
.
ddp
;
import
io.realm.RealmList
;
import
io.realm.RealmObject
;
...
...
app/src/main/java/chat/rocket/android/service/RocketChatService.java
View file @
feb65d69
...
...
@@ -88,7 +88,7 @@ public class RocketChatService extends Service {
String
serverConfigId
=
entry
.
getKey
();
boolean
found
=
false
;
for
(
ServerConfig
config
:
configList
)
{
if
(
serverConfigId
.
equals
(
config
.
getId
()))
{
if
(
serverConfigId
.
equals
(
config
.
get
ServerConfig
Id
()))
{
found
=
true
;
break
;
}
...
...
@@ -111,7 +111,7 @@ public class RocketChatService extends Service {
}
private
Task
<
RocketChatWebSocketThread
>
findOrCreateWebSocketThread
(
final
ServerConfig
config
)
{
final
String
serverConfigId
=
config
.
getId
();
final
String
serverConfigId
=
config
.
get
ServerConfig
Id
();
if
(
webSocketThreads
.
containsKey
(
serverConfigId
))
{
return
Task
.
forResult
(
webSocketThreads
.
get
(
serverConfigId
));
}
else
{
...
...
app/src/main/java/chat/rocket/android/service/RocketChatWebSocketThread.java
View file @
feb65d69
...
...
@@ -9,8 +9,8 @@ import bolts.TaskCompletionSource;
import
chat.rocket.android.helper.LogcatIfError
;
import
chat.rocket.android.helper.TextUtils
;
import
chat.rocket.android.model.ServerConfig
;
import
chat.rocket.android.service.ddp
_subscriber
.ActiveUsersSubscriber
;
import
chat.rocket.android.service.ddp
_subscriber
.LoginServiceConfigurationSubscriber
;
import
chat.rocket.android.service.ddp.ActiveUsersSubscriber
;
import
chat.rocket.android.service.ddp.LoginServiceConfigurationSubscriber
;
import
chat.rocket.android.service.observer.MethodCallObserver
;
import
chat.rocket.android.service.observer.SessionObserver
;
import
chat.rocket.android.service.observer.TokenLoginObserver
;
...
...
@@ -55,7 +55,7 @@ public class RocketChatWebSocketThread extends HandlerThread {
@DebugLog
public
static
Task
<
RocketChatWebSocketThread
>
getStarted
(
Context
appContext
,
ServerConfig
config
)
{
TaskCompletionSource
<
RocketChatWebSocketThread
>
task
=
new
TaskCompletionSource
<>();
new
RocketChatWebSocketThread
(
appContext
,
config
.
getId
())
{
new
RocketChatWebSocketThread
(
appContext
,
config
.
get
ServerConfig
Id
())
{
@Override
protected
void
onLooperPrepared
()
{
try
{
super
.
onLooperPrepared
();
...
...
@@ -136,14 +136,14 @@ public class RocketChatWebSocketThread extends HandlerThread {
socketExists
=
true
;
final
ServerConfig
config
=
RealmHelper
.
executeTransactionForRead
(
realm
->
realm
.
where
(
ServerConfig
.
class
).
equalTo
(
"
i
d"
,
serverConfigId
).
findFirst
());
realm
.
where
(
ServerConfig
.
class
).
equalTo
(
"
serverConfigI
d"
,
serverConfigId
).
findFirst
());
prepareWebSocket
(
config
);
return
webSocketAPI
.
connect
(
config
.
getSession
()).
onSuccessTask
(
task
->
{
final
String
session
=
task
.
getResult
().
session
;
RealmHelperBolts
.
executeTransaction
(
realm
->
realm
.
createOrUpdateObjectFromJson
(
ServerConfig
.
class
,
new
JSONObject
()
.
put
(
"
i
d"
,
serverConfigId
)
.
put
(
"
serverConfigI
d"
,
serverConfigId
)
.
put
(
"session"
,
session
))
).
continueWith
(
new
LogcatIfError
());
return
task
;
...
...
app/src/main/java/chat/rocket/android/service/ddp
_subscriber
/AbstractDDPDocEventSubscriber.java
→
app/src/main/java/chat/rocket/android/service/ddp/AbstractDDPDocEventSubscriber.java
View file @
feb65d69
package
chat
.
rocket
.
android
.
service
.
ddp
_subscriber
;
package
chat
.
rocket
.
android
.
service
.
ddp
;
import
android.content.Context
;
import
android.text.TextUtils
;
...
...
app/src/main/java/chat/rocket/android/service/ddp
_subscriber
/ActiveUsersSubscriber.java
→
app/src/main/java/chat/rocket/android/service/ddp/ActiveUsersSubscriber.java
View file @
feb65d69
package
chat
.
rocket
.
android
.
service
.
ddp
_subscriber
;
package
chat
.
rocket
.
android
.
service
.
ddp
;
import
android.content.Context
;
import
chat.rocket.android.model.User
;
import
chat.rocket.android.model.
ddp.
User
;
import
chat.rocket.android.ws.RocketChatWebSocketAPI
;
import
io.realm.RealmObject
;
/**
* "activeUsers" subscriber.
*/
public
class
ActiveUsersSubscriber
extends
AbstractDDPDocEventSubscriber
{
public
ActiveUsersSubscriber
(
Context
context
,
String
serverConfigId
,
...
...
app/src/main/java/chat/rocket/android/service/ddp
_subscriber
/LoginServiceConfigurationSubscriber.java
→
app/src/main/java/chat/rocket/android/service/ddp/LoginServiceConfigurationSubscriber.java
View file @
feb65d69
package
chat
.
rocket
.
android
.
service
.
ddp
_subscriber
;
package
chat
.
rocket
.
android
.
service
.
ddp
;
import
android.content.Context
;
import
chat.rocket.android.model.MeteorLoginServiceConfiguration
;
import
chat.rocket.android.model.
ddp.
MeteorLoginServiceConfiguration
;
import
chat.rocket.android.ws.RocketChatWebSocketAPI
;
import
io.realm.RealmObject
;
...
...
app/src/main/java/chat/rocket/android/service/observer/MethodCallObserver.java
View file @
feb65d69
...
...
@@ -58,19 +58,19 @@ public class MethodCallObserver extends AbstractModelObserver<MethodCall> {
}
MethodCall
call
=
list
.
get
(
0
);
final
String
methodCallId
=
call
.
getId
();
final
String
methodCallId
=
call
.
get
MethodCall
Id
();
final
String
methodName
=
call
.
getName
();
final
String
params
=
call
.
getParamsJson
();
RealmHelperBolts
.
executeTransaction
(
realm
->
realm
.
createOrUpdateObjectFromJson
(
MethodCall
.
class
,
new
JSONObject
()
.
put
(
"
i
d"
,
methodCallId
)
.
put
(
"
methodCallI
d"
,
methodCallId
)
.
put
(
"syncstate"
,
SyncState
.
SYNCING
))
).
onSuccessTask
(
task
->
webSocketAPI
.
rpc
(
methodCallId
,
methodName
,
params
).
onSuccessTask
(
_task
->
RealmHelperBolts
.
executeTransaction
(
realm
->
{
JSONObject
result
=
_task
.
getResult
().
result
;
return
realm
.
createOrUpdateObjectFromJson
(
MethodCall
.
class
,
new
JSONObject
()
.
put
(
"
i
d"
,
methodCallId
)
.
put
(
"
methodCallI
d"
,
methodCallId
)
.
put
(
"syncstate"
,
SyncState
.
SYNCED
)
.
put
(
"resultJson"
,
result
==
null
?
null
:
result
.
toString
()));
})
...
...
@@ -83,7 +83,7 @@ public class MethodCallObserver extends AbstractModelObserver<MethodCall> {
?
((
DDPClientCallback
.
RPC
.
Error
)
exception
).
error
.
toString
()
:
exception
.
getMessage
();
realm
.
createOrUpdateObjectFromJson
(
MethodCall
.
class
,
new
JSONObject
()
.
put
(
"
i
d"
,
methodCallId
)
.
put
(
"
methodCallI
d"
,
methodCallId
)
.
put
(
"syncstate"
,
SyncState
.
FAILED
)
.
put
(
"resultJson"
,
errMessage
));
return
null
;
...
...
app/src/main/java/chat/rocket/android/service/observer/SessionObserver.java
View file @
feb65d69
...
...
@@ -3,7 +3,7 @@ package chat.rocket.android.service.observer;
import
android.content.Context
;
import
chat.rocket.android.helper.LogcatIfError
;
import
chat.rocket.android.helper.MethodCallHelper
;
import
chat.rocket.android.model.RoomSubscription
;
import
chat.rocket.android.model.
ddp.
RoomSubscription
;
import
chat.rocket.android.model.ServerConfig
;
import
chat.rocket.android.ws.RocketChatWebSocketAPI
;
import
hugo.weaving.DebugLog
;
...
...
@@ -25,7 +25,7 @@ public class SessionObserver extends AbstractModelObserver<ServerConfig> {
@Override
protected
RealmResults
<
ServerConfig
>
queryItems
(
Realm
realm
)
{
return
realm
.
where
(
ServerConfig
.
class
)
.
equalTo
(
"
i
d"
,
serverConfigId
)
.
equalTo
(
"
serverConfigI
d"
,
serverConfigId
)
.
isNotNull
(
"hostname"
)
.
isNull
(
"connectionError"
)
.
isNotNull
(
"session"
)
...
...
config/quality/checkstyle/checkstyle-suppressions.xml
View file @
feb65d69
...
...
@@ -6,5 +6,5 @@
<!-- suppress some checks for classes extending RealmObject -->
<suppress
checks=
"JavadocMethod|MemberName|ParameterName"
files=
"chat[\\/]rocket[\\/]android[\\/]model"
/>
files=
"chat[\\/]rocket[\\/]android[\\/]model
[\\/]ddp
"
/>
</suppressions>
\ No newline at end of file
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