Improves Scroll Jitter

This commit is contained in:
tom5079
2020-10-13 23:34:16 +09:00
parent 0688294f18
commit 96108bc1ec
3 changed files with 44 additions and 29 deletions

View File

@@ -1,19 +1,17 @@
{
"version": 1,
"version": 2,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "xyz.quaver.pupil",
"variantName": "release",
"variantName": "processReleaseResources",
"elements": [
{
"type": "SINGLE",
"filters": [],
"properties": [],
"versionCode": 63,
"versionName": "5.1.4-hotfix1",
"enabled": true,
"versionName": "5.1.5",
"outputFile": "app-release.apk"
}
]

View File

@@ -20,6 +20,7 @@ package xyz.quaver.pupil.adapters
import android.content.Context
import android.graphics.drawable.Drawable
import android.util.Log
import android.util.SparseBooleanArray
import android.view.LayoutInflater
import android.view.View
@@ -229,6 +230,8 @@ class GalleryBlockAdapter(private val galleries: List<Int>) : RecyclerSwipeAdapt
}
tags.clear()
CoroutineScope(Dispatchers.IO).launch {
tags.addAll(
galleryBlock.relatedTags.sortedBy {
val tag = Tag.parse(it)
@@ -246,8 +249,11 @@ class GalleryBlockAdapter(private val galleries: List<Int>) : RecyclerSwipeAdapt
}
)
launch(Dispatchers.Main) {
refresh()
}
}
}
galleryblock_id.text = galleryBlock.id.toString()
galleryblock_pagecount.text = "-"

View File

@@ -21,8 +21,13 @@ package xyz.quaver.pupil.ui.view
import android.content.Context
import android.content.res.TypedArray
import android.util.AttributeSet
import android.util.Log
import com.google.android.material.chip.Chip
import com.google.android.material.chip.ChipGroup
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import kotlinx.coroutines.launch
import xyz.quaver.pupil.R
import xyz.quaver.pupil.types.Tag
import xyz.quaver.pupil.types.Tags
@@ -69,17 +74,23 @@ class TagChipGroup @JvmOverloads constructor(context: Context, attr: AttributeSe
fun refresh() {
this.removeAllViews()
tags.take(maxChipSize).forEach {
this.addView(TagChip(context, it).apply {
CoroutineScope(Dispatchers.Main).launch {
tags.take(maxChipSize).map {
CoroutineScope(Dispatchers.Default).async {
TagChip(context, it).apply {
setOnClickListener {
onClickListener?.invoke(this.tag)
}
})
}
}
}.forEach {
addView(it.await())
}
if (maxChipSize > 0 && this.size > maxChipSize)
if (maxChipSize > 0 && tags.size > maxChipSize && parent == null)
addView(moreView)
}
}
init {
applyAttributes(context.obtainStyledAttributes(attr, R.styleable.TagChipGroup))