Move error tip below header in gallery detail
This commit is contained in:
1 parent
7b38171a9d
commit
52c21319d6
3 files changed
+44
-42
No files matched your search
@@ -559,10 +559,7 @@ class ContentLayout(context: Context, attrs: AttributeSet? = null) : FrameLayout
|
||||
fun onGetException(taskId: Int, e: Throwable) {
|
||||
if (mCurrentTaskId == taskId) {
|
||||
showProgress(PROGRESS_NONE)
|
||||
val readableError = run {
|
||||
e.printStackTrace()
|
||||
ExceptionUtils.getReadableString(e)
|
||||
}
|
||||
val readableError = ExceptionUtils.getReadableString(e)
|
||||
if (mViewTransition.shownViewIndex == 0) {
|
||||
Toast.makeText(context, readableError, Toast.LENGTH_SHORT).show()
|
||||
} else {
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
package com.hippo.ehviewer.ui.main
|
||||
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.layout.widthIn
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.GroupOff
|
||||
import androidx.compose.material.icons.filled.Label
|
||||
@@ -22,6 +26,7 @@ import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.dimensionResource
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.pluralStringResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
@@ -147,3 +152,21 @@ fun GalleryDetailHeaderCard(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun GalleryDetailErrorTip(error: String, onClick: () -> Unit) = Column(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.Center,
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(id = R.drawable.big_sad_pandroid),
|
||||
contentDescription = null,
|
||||
modifier = Modifier.clickable(onClick = onClick),
|
||||
)
|
||||
Spacer(modifier = Modifier.size(8.dp))
|
||||
Text(
|
||||
text = error,
|
||||
modifier = Modifier.widthIn(max = 228.dp),
|
||||
)
|
||||
}
|
||||
@@ -34,7 +34,6 @@ import android.widget.AdapterView
|
||||
import android.widget.ArrayAdapter
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.combinedClickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
@@ -49,7 +48,6 @@ import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.layout.widthIn
|
||||
import androidx.compose.foundation.lazy.grid.GridCells
|
||||
import androidx.compose.foundation.lazy.grid.GridItemSpan
|
||||
import androidx.compose.foundation.lazy.grid.LazyGridScope
|
||||
@@ -98,7 +96,6 @@ import androidx.compose.ui.layout.LocalPinnableContainer
|
||||
import androidx.compose.ui.platform.ComposeView
|
||||
import androidx.compose.ui.platform.LocalHapticFeedback
|
||||
import androidx.compose.ui.res.dimensionResource
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.viewinterop.AndroidView
|
||||
@@ -156,6 +153,7 @@ import com.hippo.ehviewer.ui.legacy.GalleryRatingBar.OnUserRateListener
|
||||
import com.hippo.ehviewer.ui.legacy.URLImageGetter
|
||||
import com.hippo.ehviewer.ui.legacy.calculateSuitableSpanCount
|
||||
import com.hippo.ehviewer.ui.main.EhPreviewItem
|
||||
import com.hippo.ehviewer.ui.main.GalleryDetailErrorTip
|
||||
import com.hippo.ehviewer.ui.main.GalleryDetailHeaderCard
|
||||
import com.hippo.ehviewer.ui.navToReader
|
||||
import com.hippo.ehviewer.ui.openBrowser
|
||||
@@ -468,39 +466,20 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener {
|
||||
},
|
||||
) {
|
||||
Surface {
|
||||
if (getDetailError.isNotBlank()) {
|
||||
Column(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.Center,
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(id = R.drawable.big_sad_pandroid),
|
||||
contentDescription = null,
|
||||
modifier = Modifier.clickable(onClick = ::actionRefresh),
|
||||
)
|
||||
Spacer(modifier = Modifier.size(8.dp))
|
||||
Text(
|
||||
text = getDetailError,
|
||||
modifier = Modifier.widthIn(max = 228.dp),
|
||||
)
|
||||
}
|
||||
val gi = composeBindingGI
|
||||
if (gi != null) {
|
||||
GalleryDetailContent(
|
||||
galleryInfo = gi,
|
||||
galleryDetail = composeBindingGD,
|
||||
contentPadding = it,
|
||||
modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
|
||||
)
|
||||
} else {
|
||||
val gi = composeBindingGI
|
||||
if (gi != null) {
|
||||
GalleryDetailContent(
|
||||
galleryInfo = gi,
|
||||
galleryDetail = composeBindingGD,
|
||||
contentPadding = it,
|
||||
modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
|
||||
)
|
||||
} else {
|
||||
Box(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
contentAlignment = Alignment.Center,
|
||||
) {
|
||||
CircularProgressIndicator()
|
||||
}
|
||||
Box(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
contentAlignment = Alignment.Center,
|
||||
) {
|
||||
CircularProgressIndicator()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -570,7 +549,9 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener {
|
||||
Text(text = readButtonText)
|
||||
}
|
||||
}
|
||||
if (galleryDetail != null) {
|
||||
if (getDetailError.isNotBlank()) {
|
||||
GalleryDetailErrorTip(error = getDetailError, onClick = ::actionRefresh)
|
||||
} else if (galleryDetail != null) {
|
||||
BelowHeader(galleryDetail)
|
||||
} else {
|
||||
Box(
|
||||
@@ -636,7 +617,9 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (galleryDetail != null) {
|
||||
if (getDetailError.isNotBlank()) {
|
||||
GalleryDetailErrorTip(error = getDetailError, onClick = ::actionRefresh)
|
||||
} else if (galleryDetail != null) {
|
||||
BelowHeader(galleryDetail)
|
||||
} else {
|
||||
Box(
|
||||
@@ -861,7 +844,6 @@ class GalleryDetailScene : BaseScene(), DownloadInfoListener {
|
||||
updateDownloadState()
|
||||
bindViewSecond()
|
||||
}.onFailure {
|
||||
it.printStackTrace()
|
||||
getDetailError = ExceptionUtils.getReadableString(it)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user