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
6df94252
Commit
6df94252
authored
Sep 06, 2018
by
Kiryl Vashyla
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finally updated ChatRoomAdapter#prependData code: order of merging chat history updated.
parent
88caa298
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
10 deletions
+11
-10
ChatRoomAdapter.kt
...a/chat/rocket/android/chatroom/adapter/ChatRoomAdapter.kt
+11
-10
No files found.
app/src/main/java/chat/rocket/android/chatroom/adapter/ChatRoomAdapter.kt
View file @
6df94252
...
...
@@ -158,15 +158,7 @@ class ChatRoomAdapter(
}
fun
prependData
(
dataSet
:
List
<
BaseUiModel
<*
>>)
{
val
minAdditionDate
=
dataSet
.
minBy
{
it
.
message
.
timestamp
}
?:
return
//---1. In the most cases we will just add new elements to the top of messages heap
if
(
minAdditionDate
.
message
.
timestamp
>
this
.
dataSet
[
0
].
message
.
timestamp
)
{
this
.
dataSet
.
addAll
(
0
,
dataSet
)
notifyItemRangeInserted
(
0
,
dataSet
.
size
)
return
}
//---2. Else branch: merging messages---
//---2.1 At first we will update all already saved elements with received updated ones
//---At first we will update all already saved elements with received updated ones
val
filteredDataSet
=
dataSet
.
filter
{
newItem
->
val
matchedIndex
=
this
.
dataSet
.
indexOfFirst
{
it
.
messageId
==
newItem
.
messageId
&&
it
.
viewType
==
newItem
.
viewType
}
if
(
matchedIndex
>
-
1
)
{
...
...
@@ -175,7 +167,16 @@ class ChatRoomAdapter(
}
return
@filter
(
matchedIndex
<
0
)
}
//---2.2 At the second stage we are inserting new received elements into set.
val
minAdditionDate
=
dataSet
.
minBy
{
it
.
message
.
timestamp
}
?:
return
//---In the most cases we will just add new elements to the top of messages heap
if
(
minAdditionDate
.
message
.
timestamp
>
this
.
dataSet
[
0
].
message
.
timestamp
)
{
this
.
dataSet
.
addAll
(
0
,
dataSet
)
notifyItemRangeInserted
(
0
,
dataSet
.
size
)
return
}
//---Else branch: merging messages---
//---We are inserting new received elements into set. Sort them by time+type and show
if
(
filteredDataSet
.
isEmpty
())
return
this
.
dataSet
.
addAll
(
0
,
filteredDataSet
)
val
tmp
=
this
.
dataSet
.
sortedWith
(
Comparator
{
t
,
t2
->
...
...
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