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
5c6e524c
Commit
5c6e524c
authored
Nov 27, 2016
by
Yusuke Iwaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change MethodCallHelper to keepalive RocketChatService.
parent
b0497388
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
35 additions
and
8 deletions
+35
-8
MethodCallHelper.java
...c/main/java/chat/rocket/android/api/MethodCallHelper.java
+19
-1
GitHubOAuthFragment.java
...at/rocket/android/fragment/oauth/GitHubOAuthFragment.java
+2
-1
LoginFragment.java
.../rocket/android/fragment/server_config/LoginFragment.java
+2
-1
RetryLoginFragment.java
...et/android/fragment/server_config/RetryLoginFragment.java
+1
-1
UserRegistrationDialogFragment.java
...ragment/server_config/UserRegistrationDialogFragment.java
+1
-1
SidebarMainFragment.java
.../rocket/android/fragment/sidebar/SidebarMainFragment.java
+1
-1
MethodCall.java
...n/java/chat/rocket/android/model/internal/MethodCall.java
+9
-2
No files found.
app/src/main/java/chat/rocket/android/api/MethodCallHelper.java
View file @
5c6e524c
package
chat
.
rocket
.
android
.
api
;
package
chat
.
rocket
.
android
.
api
;
import
android.content.Context
;
import
android.util.Patterns
;
import
android.util.Patterns
;
import
bolts.Continuation
;
import
bolts.Continuation
;
import
bolts.Task
;
import
bolts.Task
;
...
@@ -24,16 +25,33 @@ import org.json.JSONObject;
...
@@ -24,16 +25,33 @@ import org.json.JSONObject;
*/
*/
public
class
MethodCallHelper
{
public
class
MethodCallHelper
{
private
final
Context
context
;
private
final
RealmHelper
realmHelper
;
private
final
RealmHelper
realmHelper
;
private
final
DDPClientWraper
ddpClient
;
private
final
DDPClientWraper
ddpClient
;
private
static
final
long
TIMEOUT_MS
=
4000
;
private
static
final
long
TIMEOUT_MS
=
4000
;
@Deprecated
/**
* Deprecated. use MethodCall(Context, String) instead.
*/
public
MethodCallHelper
(
String
serverConfigId
)
{
public
MethodCallHelper
(
String
serverConfigId
)
{
this
(
null
,
serverConfigId
);
}
/**
* initialize with Context and ServerConfigId.
*/
public
MethodCallHelper
(
Context
context
,
String
serverConfigId
)
{
this
.
context
=
context
;
this
.
realmHelper
=
RealmStore
.
get
(
serverConfigId
);
this
.
realmHelper
=
RealmStore
.
get
(
serverConfigId
);
ddpClient
=
null
;
ddpClient
=
null
;
}
}
/**
* initialize with RealmHelper and DDPClient.
*/
public
MethodCallHelper
(
RealmHelper
realmHelper
,
DDPClientWraper
ddpClient
)
{
public
MethodCallHelper
(
RealmHelper
realmHelper
,
DDPClientWraper
ddpClient
)
{
this
.
context
=
null
;
this
.
realmHelper
=
realmHelper
;
this
.
realmHelper
=
realmHelper
;
this
.
ddpClient
=
ddpClient
;
this
.
ddpClient
=
ddpClient
;
}
}
...
@@ -44,7 +62,7 @@ public class MethodCallHelper {
...
@@ -44,7 +62,7 @@ public class MethodCallHelper {
return
ddpClient
.
rpc
(
UUID
.
randomUUID
().
toString
(),
methodName
,
param
,
timeout
)
return
ddpClient
.
rpc
(
UUID
.
randomUUID
().
toString
(),
methodName
,
param
,
timeout
)
.
onSuccessTask
(
task
->
Task
.
forResult
(
task
.
getResult
().
result
));
.
onSuccessTask
(
task
->
Task
.
forResult
(
task
.
getResult
().
result
));
}
else
{
}
else
{
return
MethodCall
.
execute
(
realmHelper
,
methodName
,
param
,
timeout
);
return
MethodCall
.
execute
(
context
,
realmHelper
,
methodName
,
param
,
timeout
);
}
}
}
}
...
...
app/src/main/java/chat/rocket/android/fragment/oauth/GitHubOAuthFragment.java
View file @
5c6e524c
...
@@ -151,7 +151,8 @@ public class GitHubOAuthFragment extends AbstractWebViewFragment {
...
@@ -151,7 +151,8 @@ public class GitHubOAuthFragment extends AbstractWebViewFragment {
}
}
private
void
handleOAuthCallback
(
final
String
credentialToken
,
final
String
credentialSecret
)
{
private
void
handleOAuthCallback
(
final
String
credentialToken
,
final
String
credentialSecret
)
{
new
MethodCallHelper
(
serverConfigId
).
loginWithGitHub
(
credentialToken
,
credentialSecret
)
new
MethodCallHelper
(
getContext
(),
serverConfigId
)
.
loginWithGitHub
(
credentialToken
,
credentialSecret
)
.
continueWith
(
new
LogcatIfError
());
.
continueWith
(
new
LogcatIfError
());
}
}
...
...
app/src/main/java/chat/rocket/android/fragment/server_config/LoginFragment.java
View file @
5c6e524c
...
@@ -43,7 +43,8 @@ public class LoginFragment extends AbstractServerConfigFragment {
...
@@ -43,7 +43,8 @@ public class LoginFragment extends AbstractServerConfigFragment {
}
}
view
.
setEnabled
(
false
);
view
.
setEnabled
(
false
);
new
MethodCallHelper
(
serverConfigId
).
loginWithEmail
(
username
.
toString
(),
passwd
.
toString
())
new
MethodCallHelper
(
getContext
(),
serverConfigId
)
.
loginWithEmail
(
username
.
toString
(),
passwd
.
toString
())
.
continueWith
(
task
->
{
.
continueWith
(
task
->
{
if
(
task
.
isFaulted
())
{
if
(
task
.
isFaulted
())
{
showError
(
task
.
getError
().
getMessage
());
showError
(
task
.
getError
().
getMessage
());
...
...
app/src/main/java/chat/rocket/android/fragment/server_config/RetryLoginFragment.java
View file @
5c6e524c
...
@@ -46,7 +46,7 @@ public class RetryLoginFragment extends AbstractServerConfigFragment {
...
@@ -46,7 +46,7 @@ public class RetryLoginFragment extends AbstractServerConfigFragment {
view
.
setEnabled
(
false
);
view
.
setEnabled
(
false
);
waitingView
.
setVisibility
(
View
.
VISIBLE
);
waitingView
.
setVisibility
(
View
.
VISIBLE
);
new
MethodCallHelper
(
serverConfigId
).
loginWithToken
(
token
)
new
MethodCallHelper
(
getContext
(),
serverConfigId
).
loginWithToken
(
token
)
.
continueWith
(
task
->
{
.
continueWith
(
task
->
{
if
(
task
.
isFaulted
())
{
if
(
task
.
isFaulted
())
{
view
.
setEnabled
(
true
);
view
.
setEnabled
(
true
);
...
...
app/src/main/java/chat/rocket/android/fragment/server_config/UserRegistrationDialogFragment.java
View file @
5c6e524c
...
@@ -109,7 +109,7 @@ public class UserRegistrationDialogFragment extends DialogFragment {
...
@@ -109,7 +109,7 @@ public class UserRegistrationDialogFragment extends DialogFragment {
email
=
txtEmail
.
getText
().
toString
();
email
=
txtEmail
.
getText
().
toString
();
password
=
txtPasswd
.
getText
().
toString
();
password
=
txtPasswd
.
getText
().
toString
();
MethodCallHelper
methodCallHelper
=
new
MethodCallHelper
(
serverConfigId
);
MethodCallHelper
methodCallHelper
=
new
MethodCallHelper
(
getContext
(),
serverConfigId
);
methodCallHelper
.
registerUser
(
username
,
email
,
password
,
password
)
methodCallHelper
.
registerUser
(
username
,
email
,
password
,
password
)
.
onSuccessTask
(
task
->
methodCallHelper
.
loginWithEmail
(
email
,
password
))
.
onSuccessTask
(
task
->
methodCallHelper
.
loginWithEmail
(
email
,
password
))
.
onSuccessTask
(
task
->
methodCallHelper
.
setUsername
(
username
))
//TODO: should prompt!
.
onSuccessTask
(
task
->
methodCallHelper
.
setUsername
(
username
))
//TODO: should prompt!
...
...
app/src/main/java/chat/rocket/android/fragment/sidebar/SidebarMainFragment.java
View file @
5c6e524c
...
@@ -70,7 +70,7 @@ public class SidebarMainFragment extends AbstractFragment {
...
@@ -70,7 +70,7 @@ public class SidebarMainFragment extends AbstractFragment {
.
createObjectObserver
(
realm
->
realm
.
where
(
User
.
class
).
isNotEmpty
(
"emails"
))
.
createObjectObserver
(
realm
->
realm
.
where
(
User
.
class
).
isNotEmpty
(
"emails"
))
.
setOnUpdateListener
(
this
::
onRenderCurrentUser
);
.
setOnUpdateListener
(
this
::
onRenderCurrentUser
);
methodCallHelper
=
new
MethodCallHelper
(
serverConfigId
);
methodCallHelper
=
new
MethodCallHelper
(
getContext
(),
serverConfigId
);
}
}
}
}
}
}
...
...
app/src/main/java/chat/rocket/android/model/internal/MethodCall.java
View file @
5c6e524c
package
chat
.
rocket
.
android
.
model
.
internal
;
package
chat
.
rocket
.
android
.
model
.
internal
;
import
android.content.Context
;
import
android.support.annotation.Nullable
;
import
bolts.Task
;
import
bolts.Task
;
import
bolts.TaskCompletionSource
;
import
bolts.TaskCompletionSource
;
import
chat.rocket.android.helper.LogcatIfError
;
import
chat.rocket.android.helper.LogcatIfError
;
...
@@ -7,6 +9,7 @@ import chat.rocket.android.helper.TextUtils;
...
@@ -7,6 +9,7 @@ import chat.rocket.android.helper.TextUtils;
import
chat.rocket.android.model.SyncState
;
import
chat.rocket.android.model.SyncState
;
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.RealmObjectObserver
;
import
chat.rocket.android.service.RocketChatService
;
import
io.realm.RealmObject
;
import
io.realm.RealmObject
;
import
io.realm.annotations.PrimaryKey
;
import
io.realm.annotations.PrimaryKey
;
import
java.util.UUID
;
import
java.util.UUID
;
...
@@ -89,8 +92,8 @@ public class MethodCall extends RealmObject {
...
@@ -89,8 +92,8 @@ public class MethodCall extends RealmObject {
/**
/**
* insert a new record to request a method call.
* insert a new record to request a method call.
*/
*/
public
static
Task
<
String
>
execute
(
RealmHelper
realmHelper
,
String
name
,
String
paramsJson
,
public
static
Task
<
String
>
execute
(
@Nullable
final
Context
context
,
long
timeout
)
{
RealmHelper
realmHelper
,
String
name
,
String
paramsJson
,
long
timeout
)
{
final
String
newId
=
UUID
.
randomUUID
().
toString
();
final
String
newId
=
UUID
.
randomUUID
().
toString
();
TaskCompletionSource
<
String
>
task
=
new
TaskCompletionSource
<>();
TaskCompletionSource
<
String
>
task
=
new
TaskCompletionSource
<>();
realmHelper
.
executeTransaction
(
realm
->
{
realmHelper
.
executeTransaction
(
realm
->
{
...
@@ -127,6 +130,10 @@ public class MethodCall extends RealmObject {
...
@@ -127,6 +130,10 @@ public class MethodCall extends RealmObject {
}
}
});
});
observer
.
sub
();
observer
.
sub
();
if
(
context
!=
null
)
{
RocketChatService
.
keepalive
(
context
);
}
}
}
return
null
;
return
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