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
f9e48f49
Commit
f9e48f49
authored
Aug 14, 2017
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update MethodCallHelper.java
parent
a41ab15e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
18 deletions
+28
-18
MethodCallHelper.java
...c/main/java/chat/rocket/android/api/MethodCallHelper.java
+28
-18
No files found.
app/src/main/java/chat/rocket/android/api/MethodCallHelper.java
View file @
f9e48f49
...
@@ -481,24 +481,34 @@ public class MethodCallHelper {
...
@@ -481,24 +481,34 @@ public class MethodCallHelper {
.
put
(
new
JSONObject
().
put
(
"rooms"
,
true
).
put
(
"users"
,
true
))
.
put
(
new
JSONObject
().
put
(
"rooms"
,
true
).
put
(
"users"
,
true
))
).
onSuccessTask
(
CONVERT_TO_JSON_OBJECT
)
).
onSuccessTask
(
CONVERT_TO_JSON_OBJECT
)
.
onSuccessTask
(
task
->
{
.
onSuccessTask
(
task
->
{
String
jsonString
=
""
;
final
JSONObject
result
=
task
.
getResult
();
final
JSONObject
result
=
task
.
getResult
();
if
(
result
.
has
(
"rooms"
)
&&
result
.
has
(
"users"
))
{
JSONArray
jsonRoomArray
=
(
JSONArray
)
result
.
get
(
"rooms"
);
if
(
result
.
has
(
"rooms"
))
{
JSONArray
jsonUserArray
=
(
JSONArray
)
result
.
get
(
"users"
);
JSONArray
roomJsonArray
=
(
JSONArray
)
result
.
get
(
"rooms"
);
jsonString
=
roomJsonArray
.
toString
();
String
roomJsonString
=
jsonRoomArray
.
toString
().
replace
(
"["
,
""
).
replace
(
"]"
,
""
);
}
String
userJsonString
=
jsonUserArray
.
toString
().
replace
(
"["
,
""
).
replace
(
"]"
,
""
);
String
jsonString
=
"["
+
roomJsonString
+
","
+
userJsonString
+
"]"
;
if
(
result
.
has
(
"users"
))
{
JSONArray
userJsonArray
=
(
JSONArray
)
result
.
get
(
"users"
);
Log
.
i
(
"JSON"
,
jsonString
);
int
usersTotal
=
userJsonArray
.
length
();
for
(
int
i
=
0
;
i
<
usersTotal
;
++
i
)
{
realmHelper
.
executeTransaction
(
new
Transaction
()
{
RealmSpotlight
.
Companion
.
customizeUserJsonObject
(
userJsonArray
.
getJSONObject
(
i
));
@Override
}
public
Object
execute
(
Realm
realm
)
throws
JSONException
{
realm
.
delete
(
RealmSpotlight
.
class
);
if
(
jsonString
.
equals
(
""
))
{
realm
.
createOrUpdateAllFromJson
(
RealmSpotlight
.
class
,
jsonString
);
jsonString
=
userJsonArray
.
toString
();
return
null
;
}
else
{
}
jsonString
=
jsonString
.
replace
(
"]"
,
""
)
+
","
+
userJsonArray
.
toString
().
replace
(
"["
,
""
);
}
}
if
(!
jsonString
.
equals
(
""
))
{
String
jsonStringResults
=
jsonString
;
realmHelper
.
executeTransaction
(
realm
->
{
realm
.
delete
(
RealmSpotlight
.
class
);
realm
.
createOrUpdateAllFromJson
(
RealmSpotlight
.
class
,
jsonStringResults
);
return
null
;
});
});
}
}
return
null
;
return
null
;
...
@@ -533,4 +543,4 @@ public class MethodCallHelper {
...
@@ -533,4 +543,4 @@ public class MethodCallHelper {
protected
interface
ParamBuilder
{
protected
interface
ParamBuilder
{
JSONArray
buildParam
()
throws
JSONException
;
JSONArray
buildParam
()
throws
JSONException
;
}
}
}
}
\ 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