forked from github/szkolny
[Errors] Fix error reporting from snackbar.
This commit is contained in:
parent
15c8134d13
commit
43ed621879
@ -24,7 +24,7 @@ class ErrorSnackbar(val activity: AppCompatActivity) : CoroutineScope {
|
|||||||
|
|
||||||
private var snackbar: Snackbar? = null
|
private var snackbar: Snackbar? = null
|
||||||
private lateinit var coordinator: CoordinatorLayout
|
private lateinit var coordinator: CoordinatorLayout
|
||||||
private val errors = mutableListOf<ApiError>()
|
private var errors = mutableListOf<ApiError>()
|
||||||
|
|
||||||
private val job = Job()
|
private val job = Job()
|
||||||
override val coroutineContext: CoroutineContext
|
override val coroutineContext: CoroutineContext
|
||||||
@ -35,7 +35,7 @@ class ErrorSnackbar(val activity: AppCompatActivity) : CoroutineScope {
|
|||||||
snackbar = Snackbar.make(coordinator, R.string.snackbar_error_text, Snackbar.LENGTH_INDEFINITE)
|
snackbar = Snackbar.make(coordinator, R.string.snackbar_error_text, Snackbar.LENGTH_INDEFINITE)
|
||||||
snackbar?.setAction(R.string.more) {
|
snackbar?.setAction(R.string.more) {
|
||||||
ErrorDetailsDialog(activity, errors)
|
ErrorDetailsDialog(activity, errors)
|
||||||
errors.clear()
|
errors = mutableListOf()
|
||||||
}
|
}
|
||||||
val bgColor = ColorUtils.compositeColors(
|
val bgColor = ColorUtils.compositeColors(
|
||||||
getColorFromAttr(activity, R.attr.colorOnSurface) and 0xcfffffff.toInt(),
|
getColorFromAttr(activity, R.attr.colorOnSurface) and 0xcfffffff.toInt(),
|
||||||
@ -46,7 +46,7 @@ class ErrorSnackbar(val activity: AppCompatActivity) : CoroutineScope {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun addError(apiError: ApiError): ErrorSnackbar {
|
fun addError(apiError: ApiError): ErrorSnackbar {
|
||||||
errors += apiError
|
errors.add(apiError)
|
||||||
snackbar?.setText(apiError.getStringReason(activity))
|
snackbar?.setText(apiError.getStringReason(activity))
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user