Use mutableStateListOf, remove some recompose trigger
This commit is contained in:
1 parent
60fe67b97a
commit
23c6291cc8
2 files changed
+8
-20
No files matched your search
@@ -16,6 +16,7 @@
|
||||
package com.hippo.ehviewer.client
|
||||
|
||||
import android.util.Log
|
||||
import androidx.compose.runtime.mutableStateListOf
|
||||
import arrow.core.memoize
|
||||
import com.hippo.ehviewer.EhDB
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo
|
||||
@@ -24,12 +25,12 @@ import com.hippo.ehviewer.dao.Filter
|
||||
private val regex = { p: Filter -> Regex(p.text!!) }.memoize()
|
||||
|
||||
object EhFilter {
|
||||
val titleFilterList = mutableListOf<Filter>()
|
||||
val uploaderFilterList = mutableListOf<Filter>()
|
||||
val tagFilterList = mutableListOf<Filter>()
|
||||
val tagNamespaceFilterList = mutableListOf<Filter>()
|
||||
val commenterFilterList = mutableListOf<Filter>()
|
||||
val commentFilterList = mutableListOf<Filter>()
|
||||
val titleFilterList = mutableStateListOf<Filter>()
|
||||
val uploaderFilterList = mutableStateListOf<Filter>()
|
||||
val tagFilterList = mutableStateListOf<Filter>()
|
||||
val tagNamespaceFilterList = mutableStateListOf<Filter>()
|
||||
val commenterFilterList = mutableStateListOf<Filter>()
|
||||
val commentFilterList = mutableStateListOf<Filter>()
|
||||
|
||||
const val MODE_TITLE = 0
|
||||
const val MODE_UPLOADER = 1
|
||||
|
||||
@@ -53,7 +53,6 @@ fun FilterScreen() {
|
||||
val context = LocalContext.current
|
||||
val coroutineScope = rememberCoroutineScope { Dispatchers.IO }
|
||||
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior()
|
||||
val scaffoldRecomposeScope = currentRecomposeScope
|
||||
class AddFilterDialogHelper(private val dialog: AlertDialog) : View.OnClickListener {
|
||||
private val mArray = dialog.context.resources.getStringArray(R.array.filter_entries)
|
||||
private val binding = DialogAddFilterBinding.bind(dialog.findViewById(R.id.base)!!)
|
||||
@@ -88,7 +87,6 @@ fun FilterScreen() {
|
||||
error = null
|
||||
}
|
||||
}
|
||||
scaffoldRecomposeScope.invalidate()
|
||||
dialog.dismiss()
|
||||
}
|
||||
}
|
||||
@@ -116,7 +114,6 @@ fun FilterScreen() {
|
||||
}
|
||||
},
|
||||
) { paddingValues ->
|
||||
val lazyListRecomposeScope = currentRecomposeScope
|
||||
LazyColumn(
|
||||
modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
|
||||
contentPadding = paddingValues,
|
||||
@@ -149,17 +146,7 @@ fun FilterScreen() {
|
||||
Text(text = filter.text.orEmpty())
|
||||
Spacer(modifier = Modifier.weight(1F))
|
||||
IconButton(
|
||||
onClick = {
|
||||
BaseDialogBuilder(context).setMessage(context.getString(R.string.delete_filter, filter.text))
|
||||
.setPositiveButton(R.string.delete) { _, which ->
|
||||
if (DialogInterface.BUTTON_POSITIVE == which) {
|
||||
coroutineScope.launch {
|
||||
EhFilter.deleteFilter(filter)
|
||||
lazyListRecomposeScope.invalidate()
|
||||
}
|
||||
}
|
||||
}.setNegativeButton(android.R.string.cancel, null).show()
|
||||
},
|
||||
onClick = { BaseDialogBuilder(context).setMessage(context.getString(R.string.delete_filter, filter.text)).setPositiveButton(R.string.delete) { _, which -> if (DialogInterface.BUTTON_POSITIVE == which) { coroutineScope.launch { EhFilter.deleteFilter(filter) } } }.setNegativeButton(android.R.string.cancel, null).show() },
|
||||
) {
|
||||
Icon(imageVector = Icons.Default.Delete, contentDescription = null)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user