Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Stefan Zabka
Companion App Android
Commits
5a4f238c
Commit
5a4f238c
authored
Aug 22, 2019
by
Anon
Browse files
ScannerListAdapter: Fix jumpy UI.
parent
4258ca6a
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/src/main/java/de/ccc/events/badge/card10/scanner/ScannerListAdapter.kt
View file @
5a4f238c
...
...
@@ -26,10 +26,12 @@ import android.view.LayoutInflater
import
android.view.ViewGroup
import
androidx.recyclerview.widget.RecyclerView
import
java.util.*
import
kotlin.collections.HashSet
class
ScannerListAdapter
(
val
clickListener
:
(
Device
)
->
Unit
)
:
RecyclerView
.
Adapter
<
DeviceViewHolder
>()
{
private
val
list
=
LinkedList
<
Device
>()
private
val
foundDevices
=
mutableSetOf
<
String
>()
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
):
DeviceViewHolder
{
val
inflater
=
LayoutInflater
.
from
(
parent
.
context
)
...
...
@@ -44,6 +46,12 @@ class ScannerListAdapter(val clickListener: (Device) -> Unit) : RecyclerView.Ada
override
fun
getItemCount
():
Int
=
list
.
size
fun
put
(
device
:
Device
)
{
if
(
foundDevices
.
contains
(
device
.
btMac
))
{
return
}
else
{
foundDevices
.
add
(
device
.
btMac
)
}
list
.
remove
(
device
)
list
.
add
(
device
)
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