Advertisement
Guest User

Untitled

a guest
Mar 21st, 2018
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 0.47 KB | None | 0 0
  1. class NullOnEmptyConverterFactory : Converter.Factory() {
  2.     override fun responseBodyConverter(type: Type?, annotations: Array<Annotation>?, retrofit: Retrofit?): Converter<ResponseBody, *>? {
  3.         val delegate = retrofit!!.nextResponseBodyConverter<Any>(this, type!!, annotations!!)
  4.         return Converter<ResponseBody, Any> {
  5.             if (it.contentLength() == 0L) return@Converter ResponseSuccess(true, "", null)
  6.             delegate.convert(it)
  7.         }
  8.     }
  9.  
  10. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement