Last active
June 26, 2016 11:11
-
-
Save AAverin/bf7c7c176ad9c70ce5a6b423db9c7461 to your computer and use it in GitHub Desktop.
gist for CleanAndroidCode article series https://medium.com/@anton.averin.dev/keep-your-droid-clean-e9c093140eb6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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