Created
January 12, 2019 11:18
-
-
Save finnkvan/e4b7d2151782206715086ea7f348a4c2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class LiveDataCallAdapterFactory: CallAdapter.Factory() { | |
override fun get(returnType: Type, annotations: Array<Annotation>, retrofit: Retrofit): CallAdapter<*, *>? { | |
val observableType = | |
CallAdapter.Factory.getParameterUpperBound(0, returnType as ParameterizedType) as? ParameterizedType | |
?: throw IllegalArgumentException("resource must be parameterized") | |
return LiveDataCallAdapter<Any>(CallAdapter.Factory.getParameterUpperBound(0, observableType)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment