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
8c1aa05b
Commit
8c1aa05b
authored
Oct 02, 2017
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update RoomListPresenter.kt
parent
7432e6c4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
16 deletions
+25
-16
RoomListPresenter.kt
...ocket/android/fragment/chatroom/list/RoomListPresenter.kt
+25
-16
No files found.
app/src/main/java/chat/rocket/android/fragment/chatroom/list/RoomListPresenter.kt
View file @
8c1aa05b
...
...
@@ -2,6 +2,7 @@ package chat.rocket.android.fragment.chatroom.list
import
android.content.Context
import
android.os.Handler
import
android.util.Log
import
chat.rocket.android.R
import
chat.rocket.android.api.rest.RestApiHelper
import
chat.rocket.android.helper.OkHttpHelper
...
...
@@ -191,27 +192,13 @@ class RoomListPresenter(val context: Context, val view: RoomListContract.View) :
val
messageJsonObject
=
messagesJSONArray
.
getJSONObject
(
it
)
val
userJsonObject
=
messageJsonObject
.
getJSONObject
(
"u"
)
val
timestampString
=
messageJsonObject
.
optString
(
"ts"
)
val
timestamp
=
if
(
timestampString
.
isBlank
())
{
0
}
else
{
Timestamp
.
valueOf
(
timestampString
.
replace
(
"T"
,
" "
).
replace
(
"Z"
,
""
)).
time
}
val
editedAtString
=
messageJsonObject
.
optString
(
"_updatedAt"
)
val
editedAt
=
if
(
editedAtString
.
isBlank
())
{
0
}
else
{
Timestamp
.
valueOf
(
editedAtString
.
replace
(
"T"
,
" "
).
replace
(
"Z"
,
""
)).
time
}
Message
.
builder
()
.
setId
(
messageJsonObject
.
optString
(
"_id"
))
.
setRoomId
(
messageJsonObject
.
optString
(
"rid"
))
.
setMessage
(
messageJsonObject
.
optString
(
"msg"
))
.
setUser
(
getUserFromJsonObject
(
userJsonObject
))
.
setTimestamp
(
timestamp
)
.
setEditedAt
(
editedAt
)
.
setTimestamp
(
getLongTimestamp
(
messageJsonObject
.
optString
(
"ts"
))
)
.
setEditedAt
(
getLongTimestamp
(
messageJsonObject
.
optString
(
"_updatedAt"
))
)
.
setGroupable
(
messageJsonObject
.
optBoolean
(
"groupable"
))
.
setSyncState
(
SyncState
.
SYNCED
)
.
build
()
...
...
@@ -236,6 +223,16 @@ class RoomListPresenter(val context: Context, val view: RoomListContract.View) :
private
fun
handleFilesJson
(
json
:
String
,
hostname
:
String
)
{
try
{
// val maxLogSize = 1000
// val stringLength = json.length
// for (i in 0..stringLength / maxLogSize) {
// val start = i * maxLogSize
// var end = (i + 1) * maxLogSize
// end = if (end >json.length) json.length else end
// Log.v("TAG", json.substring(start, end))
// }
val
jsonObject
=
JSONObject
(
json
)
val
filesJsonArray
=
jsonObject
.
getJSONArray
(
"files"
)
...
...
@@ -263,6 +260,7 @@ class RoomListPresenter(val context: Context, val view: RoomListContract.View) :
attachment
.
setCollapsed
(
false
)
.
setAttachmentTitle
(
attachmentTitle
)
.
setTimestamp
(
getSafeTimestamp
(
fileJsonObject
.
optString
(
"uploadedAt"
)))
.
build
()
}
...
...
@@ -313,6 +311,17 @@ class RoomListPresenter(val context: Context, val view: RoomListContract.View) :
.
build
()
}
private
fun
getLongTimestamp
(
timestamp
:
String
):
Long
{
return
if
(
timestamp
.
isNotBlank
())
{
Timestamp
.
valueOf
(
getSafeTimestamp
(
timestamp
)).
time
}
else
{
0
}
}
private
fun
getSafeTimestamp
(
timestamp
:
String
):
String
=
timestamp
.
replace
(
"T"
,
" "
).
replace
(
"Z"
,
""
)
private
fun
showPinnedMessageList
(
dataSet
:
ArrayList
<
Message
>,
total
:
String
)
{
mainHandler
.
post
{
view
.
showWaitingView
(
false
)
...
...
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