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
35a75978
Commit
35a75978
authored
Aug 31, 2017
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Return hostname along with its logo URI when fetched for logged in servers
parent
c0ff4aba
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
9 deletions
+12
-9
RocketChatCache.java
app/src/main/java/chat/rocket/android/RocketChatCache.java
+5
-3
RocketChatCacheTest.kt
...rc/test/kotlin/chat.rocket.android/RocketChatCacheTest.kt
+7
-6
No files found.
app/src/main/java/chat/rocket/android/RocketChatCache.java
View file @
35a75978
...
...
@@ -15,6 +15,7 @@ import java.util.List;
import
java.util.UUID
;
import
chat.rocket.android.log.RCLog
;
import
chat.rocket.core.utils.Pair
;
import
io.reactivex.BackpressureStrategy
;
import
io.reactivex.Flowable
;
import
io.reactivex.annotations.NonNull
;
...
...
@@ -60,16 +61,17 @@ public class RocketChatCache {
}
}
public
List
<
String
>
getServerList
()
{
public
List
<
Pair
<
String
,
String
>
>
getServerList
()
{
String
json
=
getString
(
KEY_HOSTNAME_LIST
,
null
);
if
(
json
==
null
)
{
return
Collections
.
emptyList
();
}
try
{
JSONObject
jsonObj
=
new
JSONObject
(
json
);
List
<
String
>
serverList
=
new
ArrayList
<>();
List
<
Pair
<
String
,
String
>
>
serverList
=
new
ArrayList
<>();
for
(
Iterator
<
String
>
iter
=
jsonObj
.
keys
();
iter
.
hasNext
();)
{
serverList
.
add
(
iter
.
next
());
String
hostname
=
iter
.
next
();
serverList
.
add
(
new
Pair
<>(
hostname
,
"http://"
+
hostname
+
"/"
+
jsonObj
.
getString
(
hostname
)));
}
return
serverList
;
}
catch
(
JSONException
e
)
{
...
...
app/src/test/kotlin/chat.rocket.android/RocketChatCacheTest.kt
View file @
35a75978
package
chat.rocket.android;
import
android.content.Context
import
chat.rocket.core.utils.Pair
import
org.hamcrest.CoreMatchers.equalTo
import
org.json.JSONObject
import
org.junit.Assert.assertThat
...
...
@@ -26,16 +27,16 @@ class RocketChatCacheTest {
@Test
fun
getServerList_ShouldReturnHostnameList
()
{
val
hostnameList
=
JSONObject
()
.
put
(
"
demo.rocket.chat"
,
"imageuri
"
)
.
put
(
"
192.168.0.6:3000"
,
"imageuri
"
)
.
put
(
"
http://demo.rocket.chat"
,
"images/logo/logo.png
"
)
.
put
(
"
http://192.168.0.6:3000"
,
"images/icon.svg
"
)
.
toString
()
doReturn
(
hostnameList
).
`when`
(
cache
).
getString
(
"KEY_HOSTNAME_LIST"
,
null
)
val
expectedServerList
=
mutableListOf
(
"demo.rocket.chat"
,
"192.168.0.6:3000"
)
val
expectedServerList
=
mutableListOf
(
Pair
(
"http://192.168.0.6:3000"
,
"http://192.168.0.6:3000/images/icon.svg"
),
Pair
(
"http://demo.rocket.chat"
,
"http://demo.rocket.chat/images/logo/logo.png"
))
val
serverList
=
cache
.
serverList
expectedServerList
.
sort
()
serverList
.
sort
()
assertThat
(
cache
.
serverList
,
equalTo
(
expectedServerList
))
assertThat
(
serverList
,
equalTo
(
expectedServerList
))
}
}
\ 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