Skip to content

Instantly share code, notes, and snippets.

View dinukapj's full-sized avatar

Dinuka Jay dinukapj

View GitHub Profile
@dinukapj
dinukapj / RetrofitSingleton.java
Last active September 16, 2022 09:20
Retrofit Singleton implementation with support for extensible API classes.
/*
* Supports reusability of a retrofit instance and allows the usage of an authenticated/public retrofit instance for endpoints requiring authentication or for endpoints that are public.
* Objective was to provide maximum reusability of retrofit while avoiding issues such as duplicate POST requests or usage of expired access tokens.
*/
/*
Problem/Objectives:
- I needed global access to a retrofit instance without having to re-initialise an instance every time