Avoid unnecessary recompose in ReaderProgressIndicator
This commit is contained in:
1 parent
f2c8c5d66d
commit
513bce51ea
3 files changed
+7
-1
No files matched your search
@@ -9,6 +9,7 @@ import androidx.annotation.IntRange
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableFloatStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.platform.AbstractComposeView
|
||||
import androidx.compose.ui.platform.ViewCompositionStrategy
|
||||
@@ -27,19 +28,22 @@ class ReaderProgressIndicator @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
private var progress by mutableFloatStateOf(0f)
|
||||
private var visible by mutableStateOf(false)
|
||||
|
||||
@Composable
|
||||
override fun Content() {
|
||||
Mdc3Theme {
|
||||
CombinedCircularProgressIndicator(progress = progress)
|
||||
if (visible) CombinedCircularProgressIndicator(progress = progress)
|
||||
}
|
||||
}
|
||||
|
||||
fun show() {
|
||||
visible = true
|
||||
isVisible = true
|
||||
}
|
||||
|
||||
fun hide() {
|
||||
visible = false
|
||||
isVisible = false
|
||||
}
|
||||
|
||||
|
||||
@@ -149,6 +149,7 @@ class PagerPageHolder(
|
||||
*/
|
||||
private fun setImage(drawable: Drawable) {
|
||||
progressIndicator.setProgress(0)
|
||||
progressIndicator.hide()
|
||||
errorLayout?.root?.isVisible = false
|
||||
setImage(
|
||||
drawable,
|
||||
|
||||
@@ -195,6 +195,7 @@ class WebtoonPageHolder(
|
||||
*/
|
||||
private fun setImage(drawable: Drawable) {
|
||||
progressIndicator.setProgress(0)
|
||||
progressIndicator.hide()
|
||||
removeErrorLayout()
|
||||
frame.setImage(
|
||||
drawable,
|
||||
|
||||
Reference in new issue
Block a user