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
012a240a
Commit
012a240a
authored
Sep 02, 2018
by
Kiryl Vashyla
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ChatRoomAdapter#prependData improved, checked on files, reply, quote, reaction actions
parent
8a6ad2b5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
3 deletions
+17
-3
ChatRoomAdapter.kt
...a/chat/rocket/android/chatroom/adapter/ChatRoomAdapter.kt
+17
-3
No files found.
app/src/main/java/chat/rocket/android/chatroom/adapter/ChatRoomAdapter.kt
View file @
012a240a
...
...
@@ -158,7 +158,15 @@ class ChatRoomAdapter(
}
fun
prependData
(
dataSet
:
List
<
BaseUiModel
<*
>>)
{
//At first we will update all already saved elements with received updated ones
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
val
filteredDataSet
=
dataSet
.
filter
{
newItem
->
val
matchedIndex
=
this
.
dataSet
.
indexOfFirst
{
it
.
messageId
==
newItem
.
messageId
&&
it
.
viewType
==
newItem
.
viewType
}
if
(
matchedIndex
>
-
1
)
{
...
...
@@ -167,10 +175,16 @@ class ChatRoomAdapter(
}
return
@filter
(
matchedIndex
<
0
)
}
//At the second stage we are inserting new received elements into set.
//
---2.2
At the second stage we are inserting new received elements into set.
if
(
filteredDataSet
.
isEmpty
())
return
this
.
dataSet
.
addAll
(
0
,
filteredDataSet
)
val
tmp
=
this
.
dataSet
.
sortedWith
(
Comparator
{
t
,
t2
->
t
.
message
.
timestamp
.
compareTo
(
t2
.
message
.
timestamp
)
}).
reversed
()
val
tmp
=
this
.
dataSet
.
sortedWith
(
Comparator
{
t
,
t2
->
val
timeComparison
=
t
.
message
.
timestamp
.
compareTo
(
t2
.
message
.
timestamp
)
if
(
timeComparison
==
0
)
{
return
@Comparator
t
.
viewType
.
compareTo
(
t2
.
viewType
)
}
timeComparison
}).
reversed
()
this
.
dataSet
.
clear
()
this
.
dataSet
.
addAll
(
tmp
)
notifyDataSetChanged
()
...
...
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