-
-
Save appsoluut/a8b32bc574d393e4d81474637c71a8f1 to your computer and use it in GitHub Desktop.
Retrofit article block example
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
RuntimeTypeAdapterFactory<Block> articleBlockFactory = RuntimeTypeAdapterFactory.of(Block.class, "type") | |
.registerSubtype(TextBlock.class, "text") | |
.registerSubtype(ImageBlock.class, "image") | |
.registerSubtype(VideoBlock.class, "video"); | |
Gson gson = new GsonBuilder() | |
.setDateFormat("yyyy-MM-dd'T'HH:mm:ssZ") | |
.registerTypeAdapterFactory(AutoValueTypeAdapterFactory.create()) | |
.registerTypeAdapterFactory(articleBlockFactory) | |
.create(); | |
Retrofit retrofit = new Retrofit.Builder() | |
.baseUrl("https://api.example.com/") | |
.addConverterFactory(GsonConverterFactory.create(gson)) | |
.build(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment