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
2a383afd
Commit
2a383afd
authored
Nov 05, 2016
by
Yusuke Iwaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix checkstyle issues
parent
4e101ae7
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
150 additions
and
144 deletions
+150
-144
LaunchUtil.java
app/src/main/java/chat/rocket/android/LaunchUtil.java
+1
-1
ServerConfigActivity.java
...va/chat/rocket/android/activity/ServerConfigActivity.java
+11
-11
AbstractFragment.java
...n/java/chat/rocket/android/fragment/AbstractFragment.java
+5
-4
AbstractServerConfigFragment.java
.../fragment/server_config/AbstractServerConfigFragment.java
+3
-3
InputHostnameFragment.java
...android/fragment/server_config/InputHostnameFragment.java
+15
-15
TextUtils.java
app/src/main/java/chat/rocket/android/helper/TextUtils.java
+2
-1
MeteorLoginServiceConfiguration.java
...rocket/android/model/MeteorLoginServiceConfiguration.java
+3
-2
ServerConfig.java
...src/main/java/chat/rocket/android/model/ServerConfig.java
+3
-2
Registerable.java
...c/main/java/chat/rocket/android/service/Registerable.java
+4
-4
RocketChatService.java
...n/java/chat/rocket/android/service/RocketChatService.java
+11
-9
RocketChatWebSocketThread.java
...hat/rocket/android/service/RocketChatWebSocketThread.java
+30
-30
AbstractDDPDocEventSubscriber.java
...service/ddp_subscriber/AbstractDDPDocEventSubscriber.java
+40
-40
AbstractModelObserver.java
...ocket/android/service/observer/AbstractModelObserver.java
+4
-4
FontAwesomeTextView.java
...in/java/chat/rocket/android/view/FontAwesomeTextView.java
+1
-1
FontelloTextView.java
.../main/java/chat/rocket/android/view/FontelloTextView.java
+1
-1
WaitingView.java
app/src/main/java/chat/rocket/android/view/WaitingView.java
+6
-6
RocketChatWebSocketAPI.java
...n/java/chat/rocket/android/ws/RocketChatWebSocketAPI.java
+10
-10
No files found.
app/src/main/java/chat/rocket/android/LaunchUtil.java
View file @
2a383afd
...
@@ -5,7 +5,7 @@ import android.content.Intent;
...
@@ -5,7 +5,7 @@ import android.content.Intent;
import
chat.rocket.android.activity.ServerConfigActivity
;
import
chat.rocket.android.activity.ServerConfigActivity
;
/**
/**
* utility class for launching Activity
* utility class for launching Activity
.
*/
*/
public
class
LaunchUtil
{
public
class
LaunchUtil
{
/**
/**
...
...
app/src/main/java/chat/rocket/android/activity/ServerConfigActivity.java
View file @
2a383afd
...
@@ -24,11 +24,11 @@ import jp.co.crowdworks.realm_java_helpers.RealmObjectObserver;
...
@@ -24,11 +24,11 @@ import jp.co.crowdworks.realm_java_helpers.RealmObjectObserver;
*/
*/
public
class
ServerConfigActivity
extends
AbstractFragmentActivity
{
public
class
ServerConfigActivity
extends
AbstractFragmentActivity
{
private
String
mS
erverConfigId
;
private
String
s
erverConfigId
;
private
RealmObjectObserver
<
ServerConfig
>
mS
erverConfigObserver
=
private
RealmObjectObserver
<
ServerConfig
>
s
erverConfigObserver
=
new
RealmObjectObserver
<
ServerConfig
>()
{
new
RealmObjectObserver
<
ServerConfig
>()
{
@Override
protected
RealmQuery
<
ServerConfig
>
query
(
Realm
realm
)
{
@Override
protected
RealmQuery
<
ServerConfig
>
query
(
Realm
realm
)
{
return
realm
.
where
(
ServerConfig
.
class
).
equalTo
(
"id"
,
mS
erverConfigId
);
return
realm
.
where
(
ServerConfig
.
class
).
equalTo
(
"id"
,
s
erverConfigId
);
}
}
@Override
protected
void
onChange
(
ServerConfig
config
)
{
@Override
protected
void
onChange
(
ServerConfig
config
)
{
...
@@ -93,8 +93,8 @@ public class ServerConfigActivity extends AbstractFragmentActivity {
...
@@ -93,8 +93,8 @@ public class ServerConfigActivity extends AbstractFragmentActivity {
return
;
return
;
}
}
mS
erverConfigId
=
intent
.
getStringExtra
(
"id"
);
s
erverConfigId
=
intent
.
getStringExtra
(
"id"
);
if
(
TextUtils
.
isEmpty
(
mS
erverConfigId
))
{
if
(
TextUtils
.
isEmpty
(
s
erverConfigId
))
{
finish
();
finish
();
return
;
return
;
}
}
...
@@ -105,11 +105,11 @@ public class ServerConfigActivity extends AbstractFragmentActivity {
...
@@ -105,11 +105,11 @@ public class ServerConfigActivity extends AbstractFragmentActivity {
@Override
protected
void
onResume
()
{
@Override
protected
void
onResume
()
{
super
.
onResume
();
super
.
onResume
();
RocketChatService
.
keepalive
(
this
);
RocketChatService
.
keepalive
(
this
);
mS
erverConfigObserver
.
sub
();
s
erverConfigObserver
.
sub
();
}
}
@Override
protected
void
onPause
()
{
@Override
protected
void
onPause
()
{
mS
erverConfigObserver
.
unsub
();
s
erverConfigObserver
.
unsub
();
super
.
onPause
();
super
.
onPause
();
}
}
...
@@ -152,21 +152,21 @@ public class ServerConfigActivity extends AbstractFragmentActivity {
...
@@ -152,21 +152,21 @@ public class ServerConfigActivity extends AbstractFragmentActivity {
}
}
@Override
protected
void
showFragment
(
Fragment
fragment
)
{
@Override
protected
void
showFragment
(
Fragment
fragment
)
{
injectIdArgTo
(
fragment
);
inject
ServerConfig
IdArgTo
(
fragment
);
super
.
showFragment
(
fragment
);
super
.
showFragment
(
fragment
);
}
}
@Override
protected
void
showFragmentWithBackStack
(
Fragment
fragment
)
{
@Override
protected
void
showFragmentWithBackStack
(
Fragment
fragment
)
{
injectIdArgTo
(
fragment
);
inject
ServerConfig
IdArgTo
(
fragment
);
super
.
showFragmentWithBackStack
(
fragment
);
super
.
showFragmentWithBackStack
(
fragment
);
}
}
private
void
injectIdArgTo
(
Fragment
fragment
)
{
private
void
inject
ServerConfig
IdArgTo
(
Fragment
fragment
)
{
Bundle
args
=
fragment
.
getArguments
();
Bundle
args
=
fragment
.
getArguments
();
if
(
args
==
null
)
{
if
(
args
==
null
)
{
args
=
new
Bundle
();
args
=
new
Bundle
();
}
}
args
.
putString
(
"id"
,
mS
erverConfigId
);
args
.
putString
(
"id"
,
s
erverConfigId
);
fragment
.
setArguments
(
args
);
fragment
.
setArguments
(
args
);
}
}
...
...
app/src/main/java/chat/rocket/android/fragment/AbstractFragment.java
View file @
2a383afd
...
@@ -12,18 +12,19 @@ import android.view.ViewGroup;
...
@@ -12,18 +12,19 @@ import android.view.ViewGroup;
* Fragment base class for this Application.
* Fragment base class for this Application.
*/
*/
public
abstract
class
AbstractFragment
extends
Fragment
{
public
abstract
class
AbstractFragment
extends
Fragment
{
protected
View
mR
ootView
;
protected
View
r
ootView
;
protected
abstract
@LayoutRes
int
getLayout
();
protected
abstract
@LayoutRes
int
getLayout
();
protected
abstract
void
onSetupView
();
protected
abstract
void
onSetupView
();
@Nullable
@Override
@Nullable
@Override
public
View
onCreateView
(
LayoutInflater
inflater
,
@Nullable
ViewGroup
container
,
public
View
onCreateView
(
LayoutInflater
inflater
,
@Nullable
ViewGroup
container
,
@Nullable
Bundle
savedInstanceState
)
{
@Nullable
Bundle
savedInstanceState
)
{
mR
ootView
=
inflater
.
inflate
(
getLayout
(),
container
,
false
);
r
ootView
=
inflater
.
inflate
(
getLayout
(),
container
,
false
);
onSetupView
();
onSetupView
();
return
mR
ootView
;
return
r
ootView
;
}
}
protected
void
finish
()
{
protected
void
finish
()
{
...
...
app/src/main/java/chat/rocket/android/fragment/server_config/AbstractServerConfigFragment.java
View file @
2a383afd
...
@@ -6,7 +6,7 @@ import chat.rocket.android.fragment.AbstractFragment;
...
@@ -6,7 +6,7 @@ import chat.rocket.android.fragment.AbstractFragment;
import
chat.rocket.android.helper.TextUtils
;
import
chat.rocket.android.helper.TextUtils
;
abstract
class
AbstractServerConfigFragment
extends
AbstractFragment
{
abstract
class
AbstractServerConfigFragment
extends
AbstractFragment
{
protected
String
mS
erverConfigId
;
protected
String
s
erverConfigId
;
@Override
public
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
@Override
public
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
...
@@ -17,8 +17,8 @@ abstract class AbstractServerConfigFragment extends AbstractFragment {
...
@@ -17,8 +17,8 @@ abstract class AbstractServerConfigFragment extends AbstractFragment {
return
;
return
;
}
}
mS
erverConfigId
=
args
.
getString
(
"id"
);
s
erverConfigId
=
args
.
getString
(
"id"
);
if
(
TextUtils
.
isEmpty
(
mS
erverConfigId
))
{
if
(
TextUtils
.
isEmpty
(
s
erverConfigId
))
{
finish
();
finish
();
return
;
return
;
}
}
...
...
app/src/main/java/chat/rocket/android/fragment/server_config/InputHostnameFragment.java
View file @
2a383afd
...
@@ -18,14 +18,14 @@ import org.json.JSONObject;
...
@@ -18,14 +18,14 @@ import org.json.JSONObject;
* Input server host.
* Input server host.
*/
*/
public
class
InputHostnameFragment
extends
AbstractServerConfigFragment
{
public
class
InputHostnameFragment
extends
AbstractServerConfigFragment
{
private
Handler
mShowErro
r
=
new
Handler
()
{
private
Handler
errorShowingHandle
r
=
new
Handler
()
{
@Override
public
void
handleMessage
(
Message
msg
)
{
@Override
public
void
handleMessage
(
Message
msg
)
{
Toast
.
makeText
(
mR
ootView
.
getContext
(),
(
String
)
msg
.
obj
,
Toast
.
LENGTH_SHORT
).
show
();
Toast
.
makeText
(
r
ootView
.
getContext
(),
(
String
)
msg
.
obj
,
Toast
.
LENGTH_SHORT
).
show
();
}
}
};
};
RealmObjectObserver
<
ServerConfig
>
m
Observer
=
new
RealmObjectObserver
<
ServerConfig
>()
{
RealmObjectObserver
<
ServerConfig
>
serverConfig
Observer
=
new
RealmObjectObserver
<
ServerConfig
>()
{
@Override
protected
RealmQuery
<
ServerConfig
>
query
(
Realm
realm
)
{
@Override
protected
RealmQuery
<
ServerConfig
>
query
(
Realm
realm
)
{
return
realm
.
where
(
ServerConfig
.
class
).
equalTo
(
"id"
,
mS
erverConfigId
);
return
realm
.
where
(
ServerConfig
.
class
).
equalTo
(
"id"
,
s
erverConfigId
);
}
}
@Override
protected
void
onChange
(
ServerConfig
config
)
{
@Override
protected
void
onChange
(
ServerConfig
config
)
{
...
@@ -41,42 +41,42 @@ public class InputHostnameFragment extends AbstractServerConfigFragment {
...
@@ -41,42 +41,42 @@ public class InputHostnameFragment extends AbstractServerConfigFragment {
}
}
@Override
protected
void
onSetupView
()
{
@Override
protected
void
onSetupView
()
{
mR
ootView
.
findViewById
(
R
.
id
.
btn_connect
).
setOnClickListener
(
view
->
handleConnect
());
r
ootView
.
findViewById
(
R
.
id
.
btn_connect
).
setOnClickListener
(
view
->
handleConnect
());
m
Observer
.
sub
();
serverConfig
Observer
.
sub
();
}
}
private
void
handleConnect
()
{
private
void
handleConnect
()
{
final
TextView
editor
=
(
TextView
)
mR
ootView
.
findViewById
(
R
.
id
.
editor_hostname
);
final
TextView
editor
=
(
TextView
)
r
ootView
.
findViewById
(
R
.
id
.
editor_hostname
);
final
String
hostname
=
final
String
hostname
=
TextUtils
.
or
(
TextUtils
.
or
(
editor
.
getText
(),
editor
.
getHint
()),
""
).
toString
();
TextUtils
.
or
(
TextUtils
.
or
(
editor
.
getText
(),
editor
.
getHint
()),
""
).
toString
();
RealmHelperBolts
.
executeTransaction
(
RealmHelperBolts
.
executeTransaction
(
realm
->
realm
.
createOrUpdateObjectFromJson
(
ServerConfig
.
class
,
realm
->
realm
.
createOrUpdateObjectFromJson
(
ServerConfig
.
class
,
new
JSONObject
().
put
(
"id"
,
mS
erverConfigId
)
new
JSONObject
().
put
(
"id"
,
s
erverConfigId
)
.
put
(
"hostname"
,
hostname
)
.
put
(
"hostname"
,
hostname
)
.
put
(
"connectionError"
,
JSONObject
.
NULL
))).
continueWith
(
new
LogcatIfError
());
.
put
(
"connectionError"
,
JSONObject
.
NULL
))).
continueWith
(
new
LogcatIfError
());
}
}
@Override
public
void
onResume
()
{
@Override
public
void
onResume
()
{
super
.
onResume
();
super
.
onResume
();
m
Observer
.
keepalive
();
serverConfig
Observer
.
keepalive
();
}
}
@Override
public
void
onDestroyView
()
{
@Override
public
void
onDestroyView
()
{
m
Observer
.
unsub
();
serverConfig
Observer
.
unsub
();
super
.
onDestroyView
();
super
.
onDestroyView
();
}
}
private
void
showError
(
String
errString
)
{
private
void
showError
(
String
errString
)
{
mShowErro
r
.
removeMessages
(
0
);
errorShowingHandle
r
.
removeMessages
(
0
);
Message
msg
=
Message
.
obtain
(
mShowErro
r
,
0
,
errString
);
Message
msg
=
Message
.
obtain
(
errorShowingHandle
r
,
0
,
errString
);
mShowErro
r
.
sendMessageDelayed
(
msg
,
160
);
errorShowingHandle
r
.
sendMessageDelayed
(
msg
,
160
);
}
}
private
void
onRenderServerConfig
(
ServerConfig
config
)
{
private
void
onRenderServerConfig
(
ServerConfig
config
)
{
final
TextView
editor
=
(
TextView
)
mR
ootView
.
findViewById
(
R
.
id
.
editor_hostname
);
final
TextView
editor
=
(
TextView
)
r
ootView
.
findViewById
(
R
.
id
.
editor_hostname
);
if
(!
TextUtils
.
isEmpty
(
config
.
getHostname
()))
{
if
(!
TextUtils
.
isEmpty
(
config
.
getHostname
()))
{
editor
.
setText
(
config
.
getHostname
());
editor
.
setText
(
config
.
getHostname
());
...
@@ -90,7 +90,7 @@ public class InputHostnameFragment extends AbstractServerConfigFragment {
...
@@ -90,7 +90,7 @@ public class InputHostnameFragment extends AbstractServerConfigFragment {
private
void
clearConnectionErrorAndHostname
()
{
private
void
clearConnectionErrorAndHostname
()
{
RealmHelperBolts
.
executeTransaction
(
RealmHelperBolts
.
executeTransaction
(
realm
->
realm
.
createOrUpdateObjectFromJson
(
ServerConfig
.
class
,
realm
->
realm
.
createOrUpdateObjectFromJson
(
ServerConfig
.
class
,
new
JSONObject
().
put
(
"id"
,
mS
erverConfigId
)
new
JSONObject
().
put
(
"id"
,
s
erverConfigId
)
.
put
(
"hostname"
,
JSONObject
.
NULL
)
.
put
(
"hostname"
,
JSONObject
.
NULL
)
.
put
(
"connectionError"
,
JSONObject
.
NULL
))).
continueWith
(
new
LogcatIfError
());
.
put
(
"connectionError"
,
JSONObject
.
NULL
))).
continueWith
(
new
LogcatIfError
());
}
}
...
...
app/src/main/java/chat/rocket/android/helper/TextUtils.java
View file @
2a383afd
...
@@ -19,7 +19,8 @@ public class TextUtils {
...
@@ -19,7 +19,8 @@ public class TextUtils {
/**
/**
* Returns str if it is not empty; otherwise defaultValue is returned.
* Returns str if it is not empty; otherwise defaultValue is returned.
*/
*/
@SuppressWarnings
(
"PMD.ShortMethodName"
)
public
static
CharSequence
or
(
CharSequence
str
,
@SuppressWarnings
(
"PMD.ShortMethodName"
)
public
static
CharSequence
or
(
CharSequence
str
,
CharSequence
defaultValue
)
{
CharSequence
defaultValue
)
{
if
(
isEmpty
(
str
))
{
if
(
isEmpty
(
str
))
{
return
defaultValue
;
return
defaultValue
;
...
...
app/src/main/java/chat/rocket/android/model/MeteorLoginServiceConfiguration.java
View file @
2a383afd
...
@@ -4,9 +4,10 @@ import io.realm.RealmObject;
...
@@ -4,9 +4,10 @@ import io.realm.RealmObject;
import
io.realm.annotations.PrimaryKey
;
import
io.realm.annotations.PrimaryKey
;
/**
/**
* subscription model for "meteor_accounts_loginServiceConfiguration"
* subscription model for "meteor_accounts_loginServiceConfiguration"
.
*/
*/
@SuppressWarnings
(
"PMD.ShortVariable"
)
public
class
MeteorLoginServiceConfiguration
@SuppressWarnings
(
"PMD.ShortVariable"
)
public
class
MeteorLoginServiceConfiguration
extends
RealmObject
{
extends
RealmObject
{
@PrimaryKey
private
String
id
;
@PrimaryKey
private
String
id
;
private
String
service
;
private
String
service
;
...
...
app/src/main/java/chat/rocket/android/model/ServerConfig.java
View file @
2a383afd
...
@@ -12,9 +12,10 @@ import jp.co.crowdworks.realm_java_helpers_bolts.RealmHelperBolts;
...
@@ -12,9 +12,10 @@ import jp.co.crowdworks.realm_java_helpers_bolts.RealmHelperBolts;
import
org.json.JSONObject
;
import
org.json.JSONObject
;
/**
/**
* Server configuration
* Server configuration
.
*/
*/
@SuppressWarnings
(
"PMD.ShortVariable"
)
public
class
ServerConfig
extends
RealmObject
{
@SuppressWarnings
(
"PMD.ShortVariable"
)
public
class
ServerConfig
extends
RealmObject
{
@PrimaryKey
private
String
id
;
@PrimaryKey
private
String
id
;
private
String
hostname
;
private
String
hostname
;
private
String
connectionError
;
private
String
connectionError
;
...
...
app/src/main/java/chat/rocket/android/service/Registerable.java
View file @
2a383afd
package
chat
.
rocket
.
android
.
service
;
package
chat
.
rocket
.
android
.
service
;
/**
/**
* interface for observer and ddp_subscription
* interface for observer and ddp_subscription
.
*/
*/
public
interface
Registerable
{
public
interface
Registerable
{
/**
/**
* register
* register
.
*/
*/
void
register
();
void
register
();
/**
/**
* keepalive
* keepalive
.
*/
*/
void
keepalive
();
void
keepalive
();
/**
/**
* unregister
* unregister
.
*/
*/
void
unregister
();
void
unregister
();
}
}
app/src/main/java/chat/rocket/android/service/RocketChatService.java
View file @
2a383afd
...
@@ -20,8 +20,8 @@ import jp.co.crowdworks.realm_java_helpers.RealmListObserver;
...
@@ -20,8 +20,8 @@ import jp.co.crowdworks.realm_java_helpers.RealmListObserver;
*/
*/
public
class
RocketChatService
extends
Service
{
public
class
RocketChatService
extends
Service
{
private
HashMap
<
String
,
RocketChatWebSocketThread
>
mW
ebSocketThreads
;
private
HashMap
<
String
,
RocketChatWebSocketThread
>
w
ebSocketThreads
;
private
RealmListObserver
<
ServerConfig
>
mC
onnectionRequiredServerConfigObserver
=
private
RealmListObserver
<
ServerConfig
>
c
onnectionRequiredServerConfigObserver
=
new
RealmListObserver
<
ServerConfig
>()
{
new
RealmListObserver
<
ServerConfig
>()
{
@Override
protected
RealmResults
<
ServerConfig
>
queryItems
(
Realm
realm
)
{
@Override
protected
RealmResults
<
ServerConfig
>
queryItems
(
Realm
realm
)
{
return
realm
.
where
(
ServerConfig
.
class
)
return
realm
.
where
(
ServerConfig
.
class
)
...
@@ -51,17 +51,17 @@ public class RocketChatService extends Service {
...
@@ -51,17 +51,17 @@ public class RocketChatService extends Service {
@Override
public
void
onCreate
()
{
@Override
public
void
onCreate
()
{
super
.
onCreate
();
super
.
onCreate
();
mW
ebSocketThreads
=
new
HashMap
<>();
w
ebSocketThreads
=
new
HashMap
<>();
}
}
@Override
public
int
onStartCommand
(
Intent
intent
,
int
flags
,
int
startId
)
{
@Override
public
int
onStartCommand
(
Intent
intent
,
int
flags
,
int
startId
)
{
mC
onnectionRequiredServerConfigObserver
.
keepalive
();
c
onnectionRequiredServerConfigObserver
.
keepalive
();
return
START_STICKY
;
return
START_STICKY
;
}
}
private
void
syncWebSocketThreadsWith
(
List
<
ServerConfig
>
configList
)
{
private
void
syncWebSocketThreadsWith
(
List
<
ServerConfig
>
configList
)
{
final
Iterator
<
Map
.
Entry
<
String
,
RocketChatWebSocketThread
>>
iterator
=
final
Iterator
<
Map
.
Entry
<
String
,
RocketChatWebSocketThread
>>
iterator
=
mW
ebSocketThreads
.
entrySet
().
iterator
();
w
ebSocketThreads
.
entrySet
().
iterator
();
while
(
iterator
.
hasNext
())
{
while
(
iterator
.
hasNext
())
{
Map
.
Entry
<
String
,
RocketChatWebSocketThread
>
entry
=
iterator
.
next
();
Map
.
Entry
<
String
,
RocketChatWebSocketThread
>
entry
=
iterator
.
next
();
...
@@ -90,18 +90,20 @@ public class RocketChatService extends Service {
...
@@ -90,18 +90,20 @@ public class RocketChatService extends Service {
private
Task
<
RocketChatWebSocketThread
>
findOrCreateWebSocketThread
(
final
ServerConfig
config
)
{
private
Task
<
RocketChatWebSocketThread
>
findOrCreateWebSocketThread
(
final
ServerConfig
config
)
{
final
String
serverConfigId
=
config
.
getId
();
final
String
serverConfigId
=
config
.
getId
();
if
(
mW
ebSocketThreads
.
containsKey
(
serverConfigId
))
{
if
(
w
ebSocketThreads
.
containsKey
(
serverConfigId
))
{
return
Task
.
forResult
(
mW
ebSocketThreads
.
get
(
serverConfigId
));
return
Task
.
forResult
(
w
ebSocketThreads
.
get
(
serverConfigId
));
}
else
{
}
else
{
return
RocketChatWebSocketThread
.
getStarted
(
getApplicationContext
(),
config
)
return
RocketChatWebSocketThread
.
getStarted
(
getApplicationContext
(),
config
)
.
onSuccessTask
(
task
->
{
.
onSuccessTask
(
task
->
{
mW
ebSocketThreads
.
put
(
serverConfigId
,
task
.
getResult
());
w
ebSocketThreads
.
put
(
serverConfigId
,
task
.
getResult
());
return
task
;
return
task
;
});
});
}
}
}
}
@Nullable
@Override
public
IBinder
onBind
(
Intent
intent
)
{
@Nullable
@Override
public
IBinder
onBind
(
Intent
intent
)
{
return
null
;
return
null
;
}
}
}
}
app/src/main/java/chat/rocket/android/service/RocketChatWebSocketThread.java
View file @
2a383afd
...
@@ -24,17 +24,17 @@ public class RocketChatWebSocketThread extends HandlerThread {
...
@@ -24,17 +24,17 @@ public class RocketChatWebSocketThread extends HandlerThread {
private
static
final
Class
[]
REGISTERABLE_CLASSES
=
{
private
static
final
Class
[]
REGISTERABLE_CLASSES
=
{
LoginServiceConfigurationSubscriber
.
class
LoginServiceConfigurationSubscriber
.
class
};
};
private
final
Context
mA
ppContext
;
private
final
Context
a
ppContext
;
private
final
String
mS
erverConfigId
;
private
final
String
s
erverConfigId
;
private
final
ArrayList
<
Registerable
>
mL
isteners
=
new
ArrayList
<>();
private
final
ArrayList
<
Registerable
>
l
isteners
=
new
ArrayList
<>();
private
RocketChatWebSocketAPI
mW
ebSocketAPI
;
private
RocketChatWebSocketAPI
w
ebSocketAPI
;
private
boolean
mS
ocketExists
;
private
boolean
s
ocketExists
;
private
boolean
mL
istenersRegistered
;
private
boolean
l
istenersRegistered
;
private
RocketChatWebSocketThread
(
Context
appContext
,
String
serverConfigId
)
{
private
RocketChatWebSocketThread
(
Context
appContext
,
String
serverConfigId
)
{
super
(
"RC_thread_"
+
serverConfigId
);
super
(
"RC_thread_"
+
serverConfigId
);
mS
erverConfigId
=
serverConfigId
;
this
.
s
erverConfigId
=
serverConfigId
;
mA
ppContext
=
appContext
;
this
.
a
ppContext
=
appContext
;
}
}
/**
/**
...
@@ -57,14 +57,14 @@ public class RocketChatWebSocketThread extends HandlerThread {
...
@@ -57,14 +57,14 @@ public class RocketChatWebSocketThread extends HandlerThread {
}
}
/**
/**
* terminate the thread
* terminate the thread
.
*/
*/
@DebugLog
public
static
void
terminate
(
RocketChatWebSocketThread
thread
)
{
@DebugLog
public
static
void
terminate
(
RocketChatWebSocketThread
thread
)
{
thread
.
quit
();
thread
.
quit
();
}
}
private
Task
<
Void
>
ensureConnection
()
{
private
Task
<
Void
>
ensureConnection
()
{
if
(
mWebSocketAPI
==
null
||
!
mW
ebSocketAPI
.
isConnected
())
{
if
(
webSocketAPI
==
null
||
!
w
ebSocketAPI
.
isConnected
())
{
return
registerListeners
();
return
registerListeners
();
}
else
{
}
else
{
return
Task
.
forResult
(
null
);
return
Task
.
forResult
(
null
);
...
@@ -113,21 +113,21 @@ public class RocketChatWebSocketThread extends HandlerThread {
...
@@ -113,21 +113,21 @@ public class RocketChatWebSocketThread extends HandlerThread {
private
void
prepareWebSocket
()
{
private
void
prepareWebSocket
()
{
ServerConfig
config
=
RealmHelper
.
executeTransactionForRead
(
ServerConfig
config
=
RealmHelper
.
executeTransactionForRead
(
realm
->
realm
.
where
(
ServerConfig
.
class
).
equalTo
(
"id"
,
mS
erverConfigId
).
findFirst
());
realm
->
realm
.
where
(
ServerConfig
.
class
).
equalTo
(
"id"
,
s
erverConfigId
).
findFirst
());
if
(
mWebSocketAPI
==
null
||
!
mW
ebSocketAPI
.
isConnected
())
{
if
(
webSocketAPI
==
null
||
!
w
ebSocketAPI
.
isConnected
())
{
mW
ebSocketAPI
=
RocketChatWebSocketAPI
.
create
(
config
.
getHostname
());
w
ebSocketAPI
=
RocketChatWebSocketAPI
.
create
(
config
.
getHostname
());
}
}
}
}
@DebugLog
private
Task
<
Void
>
registerListeners
()
{
@DebugLog
private
Task
<
Void
>
registerListeners
()
{
if
(
mS
ocketExists
)
{
if
(
s
ocketExists
)
{
return
Task
.
forResult
(
null
);
return
Task
.
forResult
(
null
);
}
}
mS
ocketExists
=
true
;
s
ocketExists
=
true
;
prepareWebSocket
();
prepareWebSocket
();
return
mW
ebSocketAPI
.
connect
().
onSuccess
(
task
->
{
return
w
ebSocketAPI
.
connect
().
onSuccess
(
task
->
{
registerListenersActually
();
registerListenersActually
();
DDPClient
client
=
task
.
getResult
().
client
;
DDPClient
client
=
task
.
getResult
().
client
;
...
@@ -146,7 +146,7 @@ public class RocketChatWebSocketThread extends HandlerThread {
...
@@ -146,7 +146,7 @@ public class RocketChatWebSocketThread extends HandlerThread {
return
null
;
return
null
;
}).
continueWith
(
task
->
{
}).
continueWith
(
task
->
{
if
(
task
.
isFaulted
())
{
if
(
task
.
isFaulted
())
{
ServerConfig
.
logError
(
mS
erverConfigId
,
task
.
getError
());
ServerConfig
.
logError
(
s
erverConfigId
,
task
.
getError
());
}
}
return
null
;
return
null
;
});
});
...
@@ -154,20 +154,20 @@ public class RocketChatWebSocketThread extends HandlerThread {
...
@@ -154,20 +154,20 @@ public class RocketChatWebSocketThread extends HandlerThread {
//@DebugLog
//@DebugLog
private
void
registerListenersActually
()
{
private
void
registerListenersActually
()
{
if
(
mL
istenersRegistered
)
{
if
(
l
istenersRegistered
)
{
return
;
return
;
}
}
mL
istenersRegistered
=
true
;
l
istenersRegistered
=
true
;
for
(
Class
clazz
:
REGISTERABLE_CLASSES
)
{
for
(
Class
clazz
:
REGISTERABLE_CLASSES
)
{
try
{
try
{
Constructor
ctor
=
clazz
.
getConstructor
(
Context
.
class
,
RocketChatWebSocketAPI
.
class
);
Constructor
ctor
=
clazz
.
getConstructor
(
Context
.
class
,
RocketChatWebSocketAPI
.
class
);
Object
obj
=
ctor
.
newInstance
(
mAppContext
,
mW
ebSocketAPI
);
Object
obj
=
ctor
.
newInstance
(
appContext
,
w
ebSocketAPI
);
if
(
obj
instanceof
Registerable
)
{
if
(
obj
instanceof
Registerable
)
{
Registerable
registerable
=
(
Registerable
)
obj
;
Registerable
registerable
=
(
Registerable
)
obj
;
registerable
.
register
();
registerable
.
register
();
mL
isteners
.
add
(
registerable
);
l
isteners
.
add
(
registerable
);
}
}
}
catch
(
Exception
exception
)
{
}
catch
(
Exception
exception
)
{
Timber
.
w
(
exception
,
"Failed to register listeners!!"
);
Timber
.
w
(
exception
,
"Failed to register listeners!!"
);
...
@@ -177,32 +177,32 @@ public class RocketChatWebSocketThread extends HandlerThread {
...
@@ -177,32 +177,32 @@ public class RocketChatWebSocketThread extends HandlerThread {
//@DebugLog
//@DebugLog
private
void
keepaliveListeners
()
{
private
void
keepaliveListeners
()
{
if
(!
mSocketExists
||
!
mL
istenersRegistered
)
{
if
(!
socketExists
||
!
l
istenersRegistered
)
{
return
;
return
;
}
}
for
(
Registerable
registerable
:
mL
isteners
)
{
for
(
Registerable
registerable
:
l
isteners
)
{
registerable
.
keepalive
();
registerable
.
keepalive
();
}
}
}
}
//@DebugLog
//@DebugLog
private
void
unregisterListeners
()
{
private
void
unregisterListeners
()
{
if
(!
mSocketExists
||
!
mL
istenersRegistered
)
{
if
(!
socketExists
||
!
l
istenersRegistered
)
{
return
;
return
;
}
}
Iterator
<
Registerable
>
iterator
=
mL
isteners
.
iterator
();
Iterator
<
Registerable
>
iterator
=
l
isteners
.
iterator
();
while
(
iterator
.
hasNext
())
{
while
(
iterator
.
hasNext
())
{
Registerable
registerable
=
iterator
.
next
();
Registerable
registerable
=
iterator
.
next
();
registerable
.
unregister
();
registerable
.
unregister
();
iterator
.
remove
();
iterator
.
remove
();
}
}
if
(
mW
ebSocketAPI
!=
null
)
{
if
(
w
ebSocketAPI
!=
null
)
{
mW
ebSocketAPI
.
close
();
w
ebSocketAPI
.
close
();
mW
ebSocketAPI
=
null
;
w
ebSocketAPI
=
null
;
}
}
mL
istenersRegistered
=
false
;
l
istenersRegistered
=
false
;
mS
ocketExists
=
false
;
s
ocketExists
=
false
;
}
}
}
}
app/src/main/java/chat/rocket/android/service/ddp_subscriber/AbstractDDPDocEventSubscriber.java
View file @
2a383afd
...
@@ -16,14 +16,14 @@ import rx.Subscription;
...
@@ -16,14 +16,14 @@ import rx.Subscription;
import
timber.log.Timber
;
import
timber.log.Timber
;
abstract
class
AbstractDDPDocEventSubscriber
implements
Registerable
{
abstract
class
AbstractDDPDocEventSubscriber
implements
Registerable
{
protected
final
Context
mC
ontext
;
protected
final
Context
c
ontext
;
protected
final
RocketChatWebSocketAPI
m
API
;
protected
final
RocketChatWebSocketAPI
webSocket
API
;
private
String
mID
;
private
String
subscriptionId
;
private
Subscription
m
Subscription
;
private
Subscription
rx
Subscription
;
protected
AbstractDDPDocEventSubscriber
(
Context
context
,
RocketChatWebSocketAPI
api
)
{
protected
AbstractDDPDocEventSubscriber
(
Context
context
,
RocketChatWebSocketAPI
api
)
{
mC
ontext
=
context
;
this
.
c
ontext
=
context
;
m
API
=
api
;
this
.
webSocket
API
=
api
;
}
}
protected
abstract
String
getSubscriptionName
();
protected
abstract
String
getSubscriptionName
();
...
@@ -32,13 +32,13 @@ abstract class AbstractDDPDocEventSubscriber implements Registerable {
...
@@ -32,13 +32,13 @@ abstract class AbstractDDPDocEventSubscriber implements Registerable {
protected
abstract
Class
<?
extends
RealmObject
>
getModelClass
();
protected
abstract
Class
<?
extends
RealmObject
>
getModelClass
();
protected
JSONObject
customizeFieldJ
SON
(
JSONObject
json
)
{
protected
JSONObject
customizeFieldJ
son
(
JSONObject
json
)
{
return
json
;
return
json
;
}
}
@Override
public
void
register
()
{
@Override
public
void
register
()
{
m
API
.
subscribe
(
getSubscriptionName
(),
null
).
onSuccess
(
task
->
{
webSocket
API
.
subscribe
(
getSubscriptionName
(),
null
).
onSuccess
(
task
->
{
mID
=
task
.
getResult
().
id
;
subscriptionId
=
task
.
getResult
().
id
;
return
null
;
return
null
;
}).
continueWith
(
task
->
{
}).
continueWith
(
task
->
{
if
(
task
.
isFaulted
())
{
if
(
task
.
isFaulted
())
{
...
@@ -57,7 +57,7 @@ abstract class AbstractDDPDocEventSubscriber implements Registerable {
...
@@ -57,7 +57,7 @@ abstract class AbstractDDPDocEventSubscriber implements Registerable {
}
}
private
void
registerSubscriptionCallback
()
{
private
void
registerSubscriptionCallback
()
{
mSubscription
=
m
API
.
getSubscriptionCallback
()
rxSubscription
=
webSocket
API
.
getSubscriptionCallback
()
.
filter
(
event
->
event
instanceof
DDPSubscription
.
DocEvent
)
.
filter
(
event
->
event
instanceof
DDPSubscription
.
DocEvent
)
.
cast
(
DDPSubscription
.
DocEvent
.
class
)
.
cast
(
DDPSubscription
.
DocEvent
.
class
)
.
filter
(
event
->
getSubscriptionCallbackName
().
equals
(
event
.
collection
))
.
filter
(
event
->
getSubscriptionCallbackName
().
equals
(
event
.
collection
))
...
@@ -74,8 +74,8 @@ abstract class AbstractDDPDocEventSubscriber implements Registerable {
...
@@ -74,8 +74,8 @@ abstract class AbstractDDPDocEventSubscriber implements Registerable {
}
else
if
(
docEvent
instanceof
DDPSubscription
.
MovedBefore
)
{
}
else
if
(
docEvent
instanceof
DDPSubscription
.
MovedBefore
)
{
//ignore movedBefore
//ignore movedBefore
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
xception
)
{
Timber
.
w
(
e
,
"failed to handle subscription callback"
);
Timber
.
w
(
e
xception
,
"failed to handle subscription callback"
);
}
}
});
});
}
}
...
@@ -87,35 +87,20 @@ abstract class AbstractDDPDocEventSubscriber implements Registerable {
...
@@ -87,35 +87,20 @@ abstract class AbstractDDPDocEventSubscriber implements Registerable {
}).
continueWith
(
new
LogcatIfError
());
}).
continueWith
(
new
LogcatIfError
());
}
}
pr
otected
void
onDocumentChanged
(
DDPSubscription
.
Changed
docEvent
)
{
pr
ivate
void
onDocumentAdded
(
Realm
realm
,
DDPSubscription
.
Added
docEvent
)
throws
JSONException
{
RealmHelperBolts
.
executeTransaction
(
realm
->
{
//executed in RealmTransaction
onDocumentChanged
(
realm
,
docEvent
);
JSONObject
json
=
new
JSONObject
().
put
(
"id"
,
docEvent
.
docID
);
return
null
;
mergeJson
(
json
,
docEvent
.
fields
)
;
}).
continueWith
(
new
LogcatIfError
(
));
realm
.
createOrUpdateObjectFromJson
(
getModelClass
(),
customizeFieldJson
(
json
));
}
}
protected
void
onDocument
Removed
(
DDPSubscription
.
Remov
ed
docEvent
)
{
protected
void
onDocument
Changed
(
DDPSubscription
.
Chang
ed
docEvent
)
{
RealmHelperBolts
.
executeTransaction
(
realm
->
{
RealmHelperBolts
.
executeTransaction
(
realm
->
{
onDocument
Remov
ed
(
realm
,
docEvent
);
onDocument
Chang
ed
(
realm
,
docEvent
);
return
null
;
return
null
;
}).
continueWith
(
new
LogcatIfError
());
}).
continueWith
(
new
LogcatIfError
());
}
}
private
void
mergeJSON
(
JSONObject
target
,
JSONObject
src
)
throws
JSONException
{
Iterator
<
String
>
iterator
=
src
.
keys
();
while
(
iterator
.
hasNext
())
{
String
key
=
iterator
.
next
();
target
.
put
(
key
,
src
.
get
(
key
));
}
}
private
void
onDocumentAdded
(
Realm
realm
,
DDPSubscription
.
Added
docEvent
)
throws
JSONException
{
//executed in RealmTransaction
JSONObject
json
=
new
JSONObject
().
put
(
"id"
,
docEvent
.
docID
);
mergeJSON
(
json
,
docEvent
.
fields
);
realm
.
createOrUpdateObjectFromJson
(
getModelClass
(),
customizeFieldJSON
(
json
));
}
private
void
onDocumentChanged
(
Realm
realm
,
DDPSubscription
.
Changed
docEvent
)
private
void
onDocumentChanged
(
Realm
realm
,
DDPSubscription
.
Changed
docEvent
)
throws
JSONException
{
throws
JSONException
{
//executed in RealmTransaction
//executed in RealmTransaction
...
@@ -124,8 +109,15 @@ abstract class AbstractDDPDocEventSubscriber implements Registerable {
...
@@ -124,8 +109,15 @@ abstract class AbstractDDPDocEventSubscriber implements Registerable {
String
fieldToDelete
=
docEvent
.
cleared
.
getString
(
i
);
String
fieldToDelete
=
docEvent
.
cleared
.
getString
(
i
);
json
.
remove
(
fieldToDelete
);
json
.
remove
(
fieldToDelete
);
}
}
mergeJSON
(
json
,
docEvent
.
fields
);
mergeJson
(
json
,
docEvent
.
fields
);
realm
.
createOrUpdateObjectFromJson
(
getModelClass
(),
customizeFieldJSON
(
json
));
realm
.
createOrUpdateObjectFromJson
(
getModelClass
(),
customizeFieldJson
(
json
));
}
protected
void
onDocumentRemoved
(
DDPSubscription
.
Removed
docEvent
)
{
RealmHelperBolts
.
executeTransaction
(
realm
->
{
onDocumentRemoved
(
realm
,
docEvent
);
return
null
;
}).
continueWith
(
new
LogcatIfError
());
}
}
private
void
onDocumentRemoved
(
Realm
realm
,
DDPSubscription
.
Removed
docEvent
)
private
void
onDocumentRemoved
(
Realm
realm
,
DDPSubscription
.
Removed
docEvent
)
...
@@ -134,16 +126,24 @@ abstract class AbstractDDPDocEventSubscriber implements Registerable {
...
@@ -134,16 +126,24 @@ abstract class AbstractDDPDocEventSubscriber implements Registerable {
realm
.
where
(
getModelClass
()).
equalTo
(
"id"
,
docEvent
.
docID
).
findAll
().
deleteAllFromRealm
();
realm
.
where
(
getModelClass
()).
equalTo
(
"id"
,
docEvent
.
docID
).
findAll
().
deleteAllFromRealm
();
}
}
private
void
mergeJson
(
JSONObject
target
,
JSONObject
src
)
throws
JSONException
{
Iterator
<
String
>
iterator
=
src
.
keys
();
while
(
iterator
.
hasNext
())
{
String
key
=
iterator
.
next
();
target
.
put
(
key
,
src
.
get
(
key
));
}
}
@Override
public
void
keepalive
()
{
@Override
public
void
keepalive
()
{
}
}
@Override
public
void
unregister
()
{
@Override
public
void
unregister
()
{
if
(
m
Subscription
!=
null
)
{
if
(
rx
Subscription
!=
null
)
{
m
Subscription
.
unsubscribe
();
rx
Subscription
.
unsubscribe
();
}
}
if
(!
TextUtils
.
isEmpty
(
mID
))
{
if
(!
TextUtils
.
isEmpty
(
subscriptionId
))
{
mAPI
.
unsubscribe
(
mID
).
continueWith
(
new
LogcatIfError
());
webSocketAPI
.
unsubscribe
(
subscriptionId
).
continueWith
(
new
LogcatIfError
());
}
}
}
}
}
}
app/src/main/java/chat/rocket/android/service/observer/AbstractModelObserver.java
View file @
2a383afd
...
@@ -9,12 +9,12 @@ import jp.co.crowdworks.realm_java_helpers.RealmListObserver;
...
@@ -9,12 +9,12 @@ import jp.co.crowdworks.realm_java_helpers.RealmListObserver;
abstract
class
AbstractModelObserver
<
T
extends
RealmObject
>
extends
RealmListObserver
<
T
>
abstract
class
AbstractModelObserver
<
T
extends
RealmObject
>
extends
RealmListObserver
<
T
>
implements
Registerable
{
implements
Registerable
{
protected
final
Context
mC
ontext
;
protected
final
Context
c
ontext
;
protected
final
RocketChatWebSocketAPI
m
API
;
protected
final
RocketChatWebSocketAPI
webSocket
API
;
protected
AbstractModelObserver
(
Context
context
,
RocketChatWebSocketAPI
api
)
{
protected
AbstractModelObserver
(
Context
context
,
RocketChatWebSocketAPI
api
)
{
mC
ontext
=
context
;
this
.
c
ontext
=
context
;
m
API
=
api
;
webSocket
API
=
api
;
}
}
@Override
public
void
register
()
{
@Override
public
void
register
()
{
...
...
app/src/main/java/chat/rocket/android/view/FontAwesomeTextView.java
View file @
2a383afd
...
@@ -4,7 +4,7 @@ import android.content.Context;
...
@@ -4,7 +4,7 @@ import android.content.Context;
import
android.util.AttributeSet
;
import
android.util.AttributeSet
;
/**
/**
* TextView with font-awesome
* TextView with font-awesome
.
*/
*/
public
class
FontAwesomeTextView
extends
AbstractCustomFontTextView
{
public
class
FontAwesomeTextView
extends
AbstractCustomFontTextView
{
public
FontAwesomeTextView
(
Context
context
,
AttributeSet
attrs
,
int
defStyle
)
{
public
FontAwesomeTextView
(
Context
context
,
AttributeSet
attrs
,
int
defStyle
)
{
...
...
app/src/main/java/chat/rocket/android/view/FontelloTextView.java
View file @
2a383afd
...
@@ -4,7 +4,7 @@ import android.content.Context;
...
@@ -4,7 +4,7 @@ import android.content.Context;
import
android.util.AttributeSet
;
import
android.util.AttributeSet
;
/**
/**
* TextView with fontello
* TextView with fontello
.
*/
*/
public
class
FontelloTextView
extends
AbstractCustomFontTextView
{
public
class
FontelloTextView
extends
AbstractCustomFontTextView
{
public
FontelloTextView
(
Context
context
,
AttributeSet
attrs
,
int
defStyle
)
{
public
FontelloTextView
(
Context
context
,
AttributeSet
attrs
,
int
defStyle
)
{
...
...
app/src/main/java/chat/rocket/android/view/WaitingView.java
View file @
2a383afd
...
@@ -18,7 +18,7 @@ import java.util.ArrayList;
...
@@ -18,7 +18,7 @@ import java.util.ArrayList;
* View for indicating "waiting for connection ..." and so on.
* View for indicating "waiting for connection ..." and so on.
*/
*/
public
class
WaitingView
extends
LinearLayout
{
public
class
WaitingView
extends
LinearLayout
{
private
ArrayList
<
View
>
mD
ots
;
private
ArrayList
<
View
>
d
ots
;
public
WaitingView
(
Context
context
)
{
public
WaitingView
(
Context
context
)
{
super
(
context
);
super
(
context
);
...
@@ -53,7 +53,7 @@ public class WaitingView extends LinearLayout {
...
@@ -53,7 +53,7 @@ public class WaitingView extends LinearLayout {
array
.
recycle
();
array
.
recycle
();
}
}
mD
ots
=
new
ArrayList
<>();
d
ots
=
new
ArrayList
<>();
setOrientation
(
HORIZONTAL
);
setOrientation
(
HORIZONTAL
);
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
addDot
(
context
,
size
);
addDot
(
context
,
size
);
...
@@ -78,12 +78,12 @@ public class WaitingView extends LinearLayout {
...
@@ -78,12 +78,12 @@ public class WaitingView extends LinearLayout {
dot
.
setLayoutParams
(
new
FrameLayout
.
LayoutParams
(
size
,
size
,
Gravity
.
CENTER
));
dot
.
setLayoutParams
(
new
FrameLayout
.
LayoutParams
(
size
,
size
,
Gravity
.
CENTER
));
frameLayout
.
addView
(
dot
);
frameLayout
.
addView
(
dot
);
addView
(
frameLayout
);
addView
(
frameLayout
);
mD
ots
.
add
(
dot
);
d
ots
.
add
(
dot
);
}
}
private
void
start
()
{
private
void
start
()
{
for
(
int
i
=
0
;
i
<
mD
ots
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
d
ots
.
size
();
i
++)
{
animateDot
(
mD
ots
.
get
(
i
),
160
*
i
,
480
,
480
);
animateDot
(
d
ots
.
get
(
i
),
160
*
i
,
480
,
480
);
}
}
}
}
...
@@ -111,7 +111,7 @@ public class WaitingView extends LinearLayout {
...
@@ -111,7 +111,7 @@ public class WaitingView extends LinearLayout {
}
}
private
void
cancel
()
{
private
void
cancel
()
{
for
(
View
dot
:
mD
ots
)
{
for
(
View
dot
:
d
ots
)
{
dot
.
clearAnimation
();
dot
.
clearAnimation
();
}
}
}
}
...
...
app/src/main/java/chat/rocket/android/ws/RocketChatWebSocketAPI.java
View file @
2a383afd
...
@@ -13,12 +13,12 @@ import rx.Observable;
...
@@ -13,12 +13,12 @@ import rx.Observable;
* API for several POST actions.
* API for several POST actions.
*/
*/
public
class
RocketChatWebSocketAPI
{
public
class
RocketChatWebSocketAPI
{
private
final
DDPClient
mDDP
Client
;
private
final
DDPClient
ddp
Client
;
private
final
String
mHostN
ame
;
private
final
String
hostn
ame
;
private
RocketChatWebSocketAPI
(
String
hostname
)
{
private
RocketChatWebSocketAPI
(
String
hostname
)
{
mDDP
Client
=
new
DDPClient
(
OkHttpHelper
.
getClientForWebSocket
());
ddp
Client
=
new
DDPClient
(
OkHttpHelper
.
getClientForWebSocket
());
mHostN
ame
=
hostname
;
this
.
hostn
ame
=
hostname
;
}
}
/**
/**
...
@@ -32,41 +32,41 @@ public class RocketChatWebSocketAPI {
...
@@ -32,41 +32,41 @@ public class RocketChatWebSocketAPI {
* Connect to WebSocket server with DDP client.
* Connect to WebSocket server with DDP client.
*/
*/
public
Task
<
DDPClientCallback
.
Connect
>
connect
()
{
public
Task
<
DDPClientCallback
.
Connect
>
connect
()
{
return
mDDPClient
.
connect
(
"wss://"
+
mHostN
ame
+
"/websocket"
);
return
ddpClient
.
connect
(
"wss://"
+
hostn
ame
+
"/websocket"
);
}
}
/**
/**
* Returns whether DDP client is connected to WebSocket server.
* Returns whether DDP client is connected to WebSocket server.
*/
*/
public
boolean
isConnected
()
{
public
boolean
isConnected
()
{
return
mDDP
Client
.
isConnected
();
return
ddp
Client
.
isConnected
();
}
}
/**
/**
* close connection.
* close connection.
*/
*/
public
void
close
()
{
public
void
close
()
{
mDDP
Client
.
close
();
ddp
Client
.
close
();
}
}
/**
/**
* Subscribe with DDP client.
* Subscribe with DDP client.
*/
*/
public
Task
<
DDPSubscription
.
Ready
>
subscribe
(
final
String
name
,
JSONArray
param
)
{
public
Task
<
DDPSubscription
.
Ready
>
subscribe
(
final
String
name
,
JSONArray
param
)
{
return
mDDP
Client
.
sub
(
UUID
.
randomUUID
().
toString
(),
name
,
param
);
return
ddp
Client
.
sub
(
UUID
.
randomUUID
().
toString
(),
name
,
param
);
}
}
/**
/**
* Unsubscribe with DDP client.
* Unsubscribe with DDP client.
*/
*/
public
Task
<
DDPSubscription
.
NoSub
>
unsubscribe
(
final
String
subscriptionId
)
{
public
Task
<
DDPSubscription
.
NoSub
>
unsubscribe
(
final
String
subscriptionId
)
{
return
mDDP
Client
.
unsub
(
subscriptionId
);
return
ddp
Client
.
unsub
(
subscriptionId
);
}
}
/**
/**
* Returns Observable for handling DDP subscription.
* Returns Observable for handling DDP subscription.
*/
*/
public
Observable
<
DDPSubscription
.
Event
>
getSubscriptionCallback
()
{
public
Observable
<
DDPSubscription
.
Event
>
getSubscriptionCallback
()
{
return
mDDP
Client
.
getSubscriptionCallback
();
return
ddp
Client
.
getSubscriptionCallback
();
}
}
}
}
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