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
3da22c34
Commit
3da22c34
authored
Jan 25, 2017
by
Yusuke Iwaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
just rename xxxImpl
parent
bcfb862d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
23 deletions
+24
-23
ConnectivityManager.java
...java/chat/rocket/android/service/ConnectivityManager.java
+1
-1
RealmBasedConnectivityManager.java
...rocket/android/service/RealmBasedConnectivityManager.java
+10
-9
RealmBasedServerInfo.java
...ava/chat/rocket/android/service/RealmBasedServerInfo.java
+13
-13
No files found.
app/src/main/java/chat/rocket/android/service/ConnectivityManager.java
View file @
3da22c34
...
...
@@ -6,7 +6,7 @@ import android.content.Context;
* Connectivity Manager API Factory.
*/
public
class
ConnectivityManager
{
private
static
final
ConnectivityManagerImpl
IMPL
=
new
ConnectivityManagerImpl
();
private
static
final
RealmBasedConnectivityManager
IMPL
=
new
RealmBasedConnectivityManager
();
public
static
ConnectivityManagerApi
getInstance
(
Context
appContext
)
{
return
IMPL
.
setContext
(
appContext
);
...
...
app/src/main/java/chat/rocket/android/service/
ConnectivityManagerImpl
.java
→
app/src/main/java/chat/rocket/android/service/
RealmBasedConnectivityManager
.java
View file @
3da22c34
...
...
@@ -21,7 +21,8 @@ import rx.subjects.PublishSubject;
/**
* Connectivity management implementation.
*/
/*package*/
class
ConnectivityManagerImpl
implements
ConnectivityManagerApi
,
ConnectivityManagerInternal
{
/*package*/
class
RealmBasedConnectivityManager
implements
ConnectivityManagerApi
,
ConnectivityManagerInternal
{
private
final
HashMap
<
String
,
Integer
>
serverConnectivityList
=
new
HashMap
<>();
private
final
PublishSubject
<
ServerConnectivity
>
connectivitySubject
=
PublishSubject
.
create
();
private
Context
appContext
;
...
...
@@ -39,7 +40,7 @@ import rx.subjects.PublishSubject;
private
ConnectivityServiceInterface
serviceInterface
;
/*package*/
ConnectivityManagerImpl
setContext
(
Context
appContext
)
{
/*package*/
RealmBasedConnectivityManager
setContext
(
Context
appContext
)
{
this
.
appContext
=
appContext
;
return
this
;
}
...
...
@@ -47,7 +48,7 @@ import rx.subjects.PublishSubject;
@Override
public
void
resetConnectivityStateList
()
{
serverConnectivityList
.
clear
();
for
(
ServerInfo
serverInfo
:
ServerInfoImpl
.
getAllFromRealm
())
{
for
(
ServerInfo
serverInfo
:
RealmBasedServerInfo
.
getServerInfoList
())
{
serverConnectivityList
.
put
(
serverInfo
.
hostname
,
ServerConnectivity
.
STATE_DISCONNECTED
);
}
}
...
...
@@ -72,8 +73,8 @@ import rx.subjects.PublishSubject;
@Override
public
void
addOrUpdateServer
(
String
hostname
,
@Nullable
String
name
,
boolean
insecure
)
{
ServerInfoImpl
.
addOrUpdate
(
hostname
,
name
);
ServerInfoImpl
.
setInsecure
(
hostname
,
insecure
);
RealmBasedServerInfo
.
addOrUpdate
(
hostname
,
name
);
RealmBasedServerInfo
.
setInsecure
(
hostname
,
insecure
);
if
(!
serverConnectivityList
.
containsKey
(
hostname
))
{
serverConnectivityList
.
put
(
hostname
,
ServerConnectivity
.
STATE_DISCONNECTED
);
}
...
...
@@ -83,7 +84,7 @@ import rx.subjects.PublishSubject;
@Override
public
void
removeServer
(
String
hostname
)
{
ServerInfoImpl
.
remove
(
hostname
);
RealmBasedServerInfo
.
remove
(
hostname
);
if
(
serverConnectivityList
.
containsKey
(
hostname
))
{
disconnectFromServerIfNeeded
(
hostname
)
.
subscribe
(
_val
->
{
},
RCLog:
:
e
);
...
...
@@ -97,12 +98,12 @@ import rx.subjects.PublishSubject;
@Override
public
List
<
ServerInfo
>
getServerList
()
{
return
ServerInfoImpl
.
getAllFromRealm
();
return
RealmBasedServerInfo
.
getServerInfoList
();
}
@Override
public
ServerInfo
getServerInfoForHost
(
String
hostname
)
{
return
ServerInfoImpl
.
getServerInfoForHost
(
hostname
);
return
RealmBasedServerInfo
.
getServerInfoForHost
(
hostname
);
}
private
List
<
ServerConnectivity
>
getCurrentConnectivityList
()
{
...
...
@@ -116,7 +117,7 @@ import rx.subjects.PublishSubject;
@DebugLog
@Override
public
void
notifyConnectionEstablished
(
String
hostname
,
String
session
)
{
ServerInfoImpl
.
updateSession
(
hostname
,
session
);
RealmBasedServerInfo
.
updateSession
(
hostname
,
session
);
serverConnectivityList
.
put
(
hostname
,
ServerConnectivity
.
STATE_CONNECTED
);
connectivitySubject
.
onNext
(
new
ServerConnectivity
(
hostname
,
ServerConnectivity
.
STATE_CONNECTED
));
...
...
app/src/main/java/chat/rocket/android/service/
ServerInfoImpl
.java
→
app/src/main/java/chat/rocket/android/service/
RealmBasedServerInfo
.java
View file @
3da22c34
...
...
@@ -15,7 +15,7 @@ import chat.rocket.android.realm_helper.RealmStore;
/**
* Backend implementation to store ServerInfo.
*/
public
class
ServerInfoImpl
extends
RealmObject
{
public
class
RealmBasedServerInfo
extends
RealmObject
{
private
static
final
String
DB_NAME
=
"serverlist"
;
@PrimaryKey
private
String
hostname
;
...
...
@@ -40,14 +40,14 @@ public class ServerInfoImpl extends RealmObject {
static
void
addOrUpdate
(
String
hostname
,
String
name
)
{
getRealm
().
executeTransaction
(
realm
->
realm
.
createOrUpdateObjectFromJson
(
ServerInfoImpl
.
class
,
new
JSONObject
()
realm
.
createOrUpdateObjectFromJson
(
RealmBasedServerInfo
.
class
,
new
JSONObject
()
.
put
(
ColumnName
.
HOSTNAME
,
hostname
)
.
put
(
ColumnName
.
NAME
,
TextUtils
.
isEmpty
(
name
)
?
JSONObject
.
NULL
:
name
)));
}
static
void
remove
(
String
hostname
)
{
getRealm
().
executeTransaction
(
realm
->
{
realm
.
where
(
ServerInfoImpl
.
class
).
equalTo
(
ColumnName
.
HOSTNAME
,
hostname
)
realm
.
where
(
RealmBasedServerInfo
.
class
).
equalTo
(
ColumnName
.
HOSTNAME
,
hostname
)
.
findAll
()
.
deleteAllFromRealm
();
return
null
;
...
...
@@ -55,8 +55,8 @@ public class ServerInfoImpl extends RealmObject {
}
static
void
updateSession
(
String
hostname
,
String
session
)
{
ServerInfoImpl
impl
=
getRealm
().
executeTransactionForRead
(
realm
->
realm
.
where
(
ServerInfoImpl
.
class
).
equalTo
(
ColumnName
.
HOSTNAME
,
hostname
).
findFirst
());
RealmBasedServerInfo
impl
=
getRealm
().
executeTransactionForRead
(
realm
->
realm
.
where
(
RealmBasedServerInfo
.
class
).
equalTo
(
ColumnName
.
HOSTNAME
,
hostname
).
findFirst
());
if
(
impl
!=
null
)
{
impl
.
session
=
session
;
...
...
@@ -68,14 +68,14 @@ public class ServerInfoImpl extends RealmObject {
}
static
@Nullable
ServerInfo
getServerInfoForHost
(
String
hostname
)
{
ServerInfoImpl
impl
=
getRealm
().
executeTransactionForRead
(
realm
->
realm
.
where
(
ServerInfoImpl
.
class
).
equalTo
(
ColumnName
.
HOSTNAME
,
hostname
).
findFirst
());
RealmBasedServerInfo
impl
=
getRealm
().
executeTransactionForRead
(
realm
->
realm
.
where
(
RealmBasedServerInfo
.
class
).
equalTo
(
ColumnName
.
HOSTNAME
,
hostname
).
findFirst
());
return
impl
==
null
?
null
:
impl
.
getServerInfo
();
}
static
void
setInsecure
(
String
hostname
,
boolean
insecure
)
{
ServerInfoImpl
impl
=
getRealm
().
executeTransactionForRead
(
realm
->
realm
.
where
(
ServerInfoImpl
.
class
).
equalTo
(
ColumnName
.
HOSTNAME
,
hostname
).
findFirst
());
RealmBasedServerInfo
impl
=
getRealm
().
executeTransactionForRead
(
realm
->
realm
.
where
(
RealmBasedServerInfo
.
class
).
equalTo
(
ColumnName
.
HOSTNAME
,
hostname
).
findFirst
());
if
(
impl
!=
null
)
{
impl
.
insecure
=
insecure
;
...
...
@@ -86,11 +86,11 @@ public class ServerInfoImpl extends RealmObject {
}
}
static
List
<
ServerInfo
>
get
AllFromRealm
()
{
List
<
ServerInfoImpl
>
results
=
getRealm
().
executeTransactionForReadResults
(
realm
->
realm
.
where
(
ServerInfoImpl
.
class
).
findAll
());
static
List
<
ServerInfo
>
get
ServerInfoList
()
{
List
<
RealmBasedServerInfo
>
results
=
getRealm
().
executeTransactionForReadResults
(
realm
->
realm
.
where
(
RealmBasedServerInfo
.
class
).
findAll
());
ArrayList
<
ServerInfo
>
list
=
new
ArrayList
<>();
for
(
ServerInfoImpl
impl
:
results
)
{
for
(
RealmBasedServerInfo
impl
:
results
)
{
list
.
add
(
impl
.
getServerInfo
());
}
return
list
;
...
...
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