Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AAverin/bf7c7c176ad9c70ce5a6b423db9c7461 to your computer and use it in GitHub Desktop.
Save AAverin/bf7c7c176ad9c70ce5a6b423db9c7461 to your computer and use it in GitHub Desktop.
interface RxHttpResolution {
fun onHttpException(httpException: HttpException)
fun onGenericRxException(t: Throwable)
}
interface NetworkConnectivityResolution {
fun onConnectivityAvailable()
fun onConnectivityUnavailable()
}
interface LocationRequestResolution {
fun onNetworkLocationError()
}
interface Resolution : RxHttpResultion, NetworkConnectivityResolution, LocationRequestResolution {
}
abstract class ResolutionByCase : Resolution {
override fun onHttpException(httpException: HttpException) {
val code = httpException.code()
when (code) {
500 -> onInternalServerError()
503 -> onServiceUnavailable()
404 -> onNotFound()
else -> onInternalServerError()
}
}
abstract fun onInternalServerError()
abstract fun onNotFound()
abstract fun onServiceUnavailable()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment