Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Retrofit article block example
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