Update page loading ui
This commit is contained in:
@@ -120,7 +120,9 @@ class PageHolderDelegate(
|
||||
if (state >= State.LOADED) {
|
||||
state = State.SHOWN
|
||||
error = null
|
||||
callback.onImageShown()
|
||||
callback.onImageShown(isPreview = false)
|
||||
} else if (state == State.LOADING_WITH_PREVIEW) {
|
||||
callback.onImageShown(isPreview = true)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,9 +187,9 @@ class PageHolderDelegate(
|
||||
state = State.LOADING
|
||||
error = null
|
||||
callback.onLoadingStarted()
|
||||
launch {
|
||||
val preview = loader.loadPreview(data) ?: return@launch
|
||||
if (state == State.LOADING) {
|
||||
val previewJob = launch {
|
||||
val preview = loader.loadPreview(data)
|
||||
if (preview != null && state == State.LOADING) {
|
||||
state = State.LOADING_WITH_PREVIEW
|
||||
callback.onPreviewReady(preview)
|
||||
}
|
||||
@@ -199,6 +201,7 @@ class PageHolderDelegate(
|
||||
val progressObserver = observeProgress(this, task.progressAsFlow())
|
||||
val file = task.await()
|
||||
progressObserver.cancelAndJoin()
|
||||
previewJob.cancel()
|
||||
uri = file
|
||||
state = State.LOADED
|
||||
cachedBounds = if (readerSettings.isPagesCropEnabled(isWebtoon)) {
|
||||
@@ -251,7 +254,7 @@ class PageHolderDelegate(
|
||||
|
||||
fun onImageShowing(settings: ReaderSettings, isPreview: Boolean)
|
||||
|
||||
fun onImageShown()
|
||||
fun onImageShown(isPreview: Boolean)
|
||||
|
||||
fun onProgressChanged(progress: Int)
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ import org.koitharu.kotatsu.core.ui.widgets.ZoomControl
|
||||
import org.koitharu.kotatsu.core.util.ext.getDisplayMessage
|
||||
import org.koitharu.kotatsu.core.util.ext.isLowRamDevice
|
||||
import org.koitharu.kotatsu.core.util.ext.isSerializable
|
||||
import org.koitharu.kotatsu.core.util.ext.setTextAndVisible
|
||||
import org.koitharu.kotatsu.databinding.ItemPageBinding
|
||||
import org.koitharu.kotatsu.parsers.util.ifZero
|
||||
import org.koitharu.kotatsu.reader.domain.PageLoader
|
||||
@@ -78,14 +79,17 @@ open class PageHolder(
|
||||
bindingInfo.layoutError.isVisible = false
|
||||
bindingInfo.progressBar.show()
|
||||
binding.ssiv.recycle()
|
||||
bindingInfo.textViewStatus.setTextAndVisible(R.string.loading_)
|
||||
}
|
||||
|
||||
override fun onProgressChanged(progress: Int) {
|
||||
if (progress in 0..100) {
|
||||
bindingInfo.progressBar.isIndeterminate = false
|
||||
bindingInfo.progressBar.setProgressCompat(progress, true)
|
||||
bindingInfo.textViewStatus.text = context.getString(R.string.percent_string_pattern, progress.toString())
|
||||
} else {
|
||||
bindingInfo.progressBar.isIndeterminate = true
|
||||
bindingInfo.textViewStatus.setText(R.string.loading_)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,8 +141,11 @@ open class PageHolder(
|
||||
}
|
||||
}
|
||||
|
||||
override fun onImageShown() {
|
||||
bindingInfo.progressBar.hide()
|
||||
override fun onImageShown(isPreview: Boolean) {
|
||||
if (!isPreview) {
|
||||
bindingInfo.progressBar.hide()
|
||||
}
|
||||
bindingInfo.textViewStatus.isVisible = false
|
||||
}
|
||||
|
||||
override fun onTrimMemory() {
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.koitharu.kotatsu.core.os.NetworkState
|
||||
import org.koitharu.kotatsu.core.util.GoneOnInvisibleListener
|
||||
import org.koitharu.kotatsu.core.util.ext.getDisplayMessage
|
||||
import org.koitharu.kotatsu.core.util.ext.isSerializable
|
||||
import org.koitharu.kotatsu.core.util.ext.setTextAndVisible
|
||||
import org.koitharu.kotatsu.databinding.ItemPageWebtoonBinding
|
||||
import org.koitharu.kotatsu.parsers.util.ifZero
|
||||
import org.koitharu.kotatsu.reader.domain.PageLoader
|
||||
@@ -78,14 +79,17 @@ class WebtoonHolder(
|
||||
bindingInfo.layoutError.isVisible = false
|
||||
bindingInfo.progressBar.show()
|
||||
binding.ssiv.recycle()
|
||||
bindingInfo.textViewStatus.setTextAndVisible(R.string.loading_)
|
||||
}
|
||||
|
||||
override fun onProgressChanged(progress: Int) {
|
||||
if (progress in 0..100) {
|
||||
bindingInfo.progressBar.isIndeterminate = false
|
||||
bindingInfo.progressBar.setProgressCompat(progress, true)
|
||||
bindingInfo.textViewStatus.text = context.getString(R.string.percent_string_pattern, progress.toString())
|
||||
} else {
|
||||
bindingInfo.progressBar.isIndeterminate = true
|
||||
bindingInfo.textViewStatus.setText(R.string.loading_)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,8 +113,9 @@ class WebtoonHolder(
|
||||
}
|
||||
}
|
||||
|
||||
override fun onImageShown() {
|
||||
override fun onImageShown(isPreview: Boolean) {
|
||||
bindingInfo.progressBar.hide()
|
||||
bindingInfo.textViewStatus.isVisible = false
|
||||
}
|
||||
|
||||
override fun onTrimMemory() {
|
||||
|
||||
@@ -5,15 +5,26 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:parentTag="android.widget.FrameLayout">
|
||||
|
||||
<com.google.android.material.progressindicator.CircularProgressIndicator
|
||||
<com.google.android.material.progressindicator.LinearProgressIndicator
|
||||
android:id="@+id/progressBar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="top"
|
||||
android:indeterminate="true"
|
||||
android:visibility="gone"
|
||||
app:hideAnimationBehavior="escape"
|
||||
app:trackCornerRadius="0dp"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView_status"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:indeterminate="true"
|
||||
android:max="100"
|
||||
app:hideAnimationBehavior="escape"
|
||||
app:showAnimationBehavior="none" />
|
||||
android:layout_marginHorizontal="60dp"
|
||||
android:gravity="center"
|
||||
android:textAppearance="?textAppearanceBodyLarge"
|
||||
tools:text="72%" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/layout_error"
|
||||
@@ -22,10 +33,12 @@
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginStart="60dp"
|
||||
android:layout_marginEnd="60dp"
|
||||
android:background="@drawable/bg_card"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical"
|
||||
android:padding="@dimen/screen_padding"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible">
|
||||
tools:visibility="gone">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView_error"
|
||||
|
||||
Reference in New Issue
Block a user