mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-04-14 19:56:32 +00:00
improve way errors are displayed
This commit is contained in:
parent
0be832f63f
commit
9158100c40
7 changed files with 26 additions and 17 deletions
|
|
@ -48,8 +48,8 @@
|
|||
<dimen name="row_title_size">16sp</dimen>
|
||||
<dimen name="row_text_size">14sp</dimen>
|
||||
<dimen name="row_title_bottommargin">2dp</dimen>
|
||||
<dimen name="pet_width">92dp</dimen>
|
||||
<dimen name="mount_width">120dp</dimen>
|
||||
<dimen name="pet_width">82dp</dimen>
|
||||
<dimen name="mount_width">110dp</dimen>
|
||||
<dimen name="bottom_menu_padding">20dp</dimen>
|
||||
<dimen name="pet_image_width">68dp</dimen>
|
||||
<dimen name="pet_image_height">65dp</dimen>
|
||||
|
|
|
|||
|
|
@ -99,7 +99,6 @@ class ApiClientImpl(
|
|||
|
||||
override var languageCode: String? = null
|
||||
private var lastAPICallURL: String? = null
|
||||
private var hadError = false
|
||||
|
||||
init {
|
||||
buildRetrofit()
|
||||
|
|
@ -144,6 +143,7 @@ class ApiClientImpl(
|
|||
lastAPICallURL = original.url.toString()
|
||||
val response = chain.proceed(request)
|
||||
if (response.isSuccessful) {
|
||||
hideConnectionProblemDialog()
|
||||
return@addNetworkInterceptor response
|
||||
} else {
|
||||
// Modify cache control for 4xx or 5xx range - effectively "do not cache", preventing caching of 4xx and 5xx responses
|
||||
|
|
@ -311,19 +311,21 @@ class ApiClientImpl(
|
|||
showConnectionProblemDialog(context.getString(resourceTitleString), context.getString(resourceMessageString))
|
||||
}
|
||||
|
||||
private var erroredRequestCount = 0
|
||||
private fun showConnectionProblemDialog(
|
||||
resourceTitleString: String?,
|
||||
resourceMessageString: String
|
||||
) {
|
||||
hadError = true
|
||||
erroredRequestCount += 1
|
||||
val application = (context as? HabiticaBaseApplication)
|
||||
?: (context.applicationContext as? HabiticaBaseApplication)
|
||||
application?.currentActivity?.get()
|
||||
?.showConnectionProblem(resourceTitleString, resourceMessageString)
|
||||
?.showConnectionProblem(erroredRequestCount, resourceTitleString, resourceMessageString)
|
||||
}
|
||||
|
||||
private fun hideConnectionProblemDialog() {
|
||||
hadError = false
|
||||
if (erroredRequestCount == 0) return
|
||||
erroredRequestCount = 0
|
||||
val application = (context as? HabiticaBaseApplication)
|
||||
?: (context.applicationContext as? HabiticaBaseApplication)
|
||||
application?.currentActivity?.get()
|
||||
|
|
|
|||
|
|
@ -223,7 +223,7 @@ abstract class BaseActivity : AppCompatActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
open fun showConnectionProblem(title: String?, message: String) {
|
||||
open fun showConnectionProblem(errorCount: Int, title: String?, message: String) {
|
||||
val alert = HabiticaAlertDialog(this)
|
||||
alert.setTitle(title)
|
||||
alert.setMessage(message)
|
||||
|
|
|
|||
|
|
@ -81,6 +81,7 @@ import com.habitrpg.android.habitica.ui.views.AppHeaderView
|
|||
import com.habitrpg.android.habitica.ui.views.ComposableAvatarView
|
||||
import com.habitrpg.android.habitica.ui.views.GroupPlanMemberList
|
||||
import com.habitrpg.android.habitica.ui.views.HabiticaButton
|
||||
import com.habitrpg.android.habitica.ui.views.HabiticaSnackbar
|
||||
import com.habitrpg.android.habitica.ui.views.SnackbarActivity
|
||||
import com.habitrpg.android.habitica.ui.views.dialogs.QuestCompletedDialog
|
||||
import com.habitrpg.android.habitica.ui.views.showAsBottomSheet
|
||||
|
|
@ -767,9 +768,11 @@ open class MainActivity : BaseActivity(), SnackbarActivity {
|
|||
|
||||
private var errorJob: Job? = null
|
||||
|
||||
override fun showConnectionProblem(title: String?, message: String) {
|
||||
if (title != null) {
|
||||
super.showConnectionProblem(title, message)
|
||||
override fun showConnectionProblem(errorCount: Int, title: String?, message: String) {
|
||||
if (errorCount == 1) {
|
||||
showSnackbar(title = title, content = message, displayType = HabiticaSnackbar.SnackbarDisplayType.FAILURE)
|
||||
} else if (title != null) {
|
||||
super.showConnectionProblem(errorCount, title, message)
|
||||
} else {
|
||||
if (errorJob?.isCancelled == false) {
|
||||
// a new error resets the timer to hide the error message
|
||||
|
|
|
|||
|
|
@ -109,13 +109,13 @@ fun MountBottomSheet(
|
|||
) {
|
||||
BackgroundScene()
|
||||
|
||||
val regularPosition = 40f
|
||||
val highJump = 28f
|
||||
val lowJump = 35f
|
||||
val regularPosition = 12f
|
||||
val highJump = 0f
|
||||
val lowJump = 8f
|
||||
val position by if (isAnimalFlying(mount)) {
|
||||
infiniteTransition.animateFloat(
|
||||
initialValue = 24f,
|
||||
targetValue = 16f,
|
||||
initialValue = 4f,
|
||||
targetValue = 0f,
|
||||
animationSpec = infiniteRepeatable(
|
||||
tween(
|
||||
2500,
|
||||
|
|
@ -145,7 +145,7 @@ fun MountBottomSheet(
|
|||
}
|
||||
MountView(mount, modifier = Modifier
|
||||
.offset(0.dp, position.dp)
|
||||
.size(72.dp)
|
||||
.size(81.dp, 99.dp)
|
||||
.align(Alignment.TopCenter)
|
||||
.zIndex(2f)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.habitrpg.android.habitica.ui.views.stable
|
|||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.ViewGroup
|
||||
import android.widget.FrameLayout
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
|
|
@ -29,8 +30,11 @@ class MountView @JvmOverloads constructor(
|
|||
|
||||
init {
|
||||
addView(bodyView)
|
||||
bodyView.layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
|
||||
addView(headView)
|
||||
headView.layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Composable
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
NAME=4.3
|
||||
CODE=6631
|
||||
CODE=6661
|
||||
Loading…
Reference in a new issue