Last active
December 6, 2016 00:44
-
-
Save oldergod/1c20fde0787afe8840cc108a6abf902b to your computer and use it in GitHub Desktop.
Retrofit and envelopes
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
public class LoginContextUnwrappingConverter extends Converter.Factory { | |
@Override | |
public Converter<ResponseBody, LoginContext> | |
responseBodyConverter(Type type, | |
Annotation[] annotations, | |
Retrofit retrofit) { | |
if (type != LoginContext.class) { | |
return null; | |
} | |
final Converter<ResponseBody, LoginResponse> delegate = | |
retrofit.nextResponseBodyConverter(this, | |
LoginResponse.class, | |
annotations); | |
return body -> { | |
LoginResponse wrapper = delegate.convert(body); | |
return wrapper.context(); | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment