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
f15bca5b
Commit
f15bca5b
authored
Aug 24, 2018
by
Kiryl Vashyla
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Chat history issues fx: on adapter side
parent
aaf1bedd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
15 deletions
+15
-15
ChatRoomAdapter.kt
...a/chat/rocket/android/chatroom/adapter/ChatRoomAdapter.kt
+15
-15
No files found.
app/src/main/java/chat/rocket/android/chatroom/adapter/ChatRoomAdapter.kt
View file @
f15bca5b
...
...
@@ -150,23 +150,23 @@ class ChatRoomAdapter(
}
fun
prependData
(
dataSet
:
List
<
BaseUiModel
<*
>>)
{
val
item
=
dataSet
.
indexOfFirst
{
newItem
->
this
.
dataSet
.
indexOfFirst
{
it
.
messageId
==
newItem
.
messageId
&&
it
.
viewType
==
newItem
.
viewType
}
>
-
1
}
if
(
item
==
-
1
)
{
this
.
dataSet
.
addAll
(
0
,
dataSet
)
notifyItemRangeInserted
(
0
,
dataSet
.
size
)
}
else
{
dataSet
.
forEach
{
item
->
val
index
=
this
.
dataSet
.
indexOfFirst
{
item
.
messageId
==
it
.
messageId
&&
item
.
viewType
==
it
.
viewType
}
if
(
index
>
-
1
)
{
this
.
dataSet
[
index
]
=
item
notifyItemChanged
(
index
)
}
//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
)
{
this
.
dataSet
[
matchedIndex
]
=
newItem
notifyItemChanged
(
matchedIndex
)
}
return
@filter
(
matchedIndex
<
0
)
}
//At the second stage we are inserting new received elements into set.
if
(
filteredDataSet
.
size
==
0
)
return
this
.
dataSet
.
addAll
(
0
,
filteredDataSet
)
val
tmp
=
this
.
dataSet
.
sortedWith
(
Comparator
{
t
,
t2
->
t
.
message
.
timestamp
.
compareTo
(
t2
.
message
.
timestamp
)
}).
reversed
()
this
.
dataSet
.
clear
()
this
.
dataSet
.
addAll
(
tmp
)
notifyDataSetChanged
()
}
fun
updateItem
(
message
:
BaseUiModel
<
*
>)
{
...
...
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