The library supports retrofit2 request execution sequentially.
Kotlin version is here
************* Using Gradle *************
Add repository:
repositories {
jcenter()
}
or
repositories {
maven {
url "https://dl.bintray.com/hieupham1993/utilities"
}
}
Add this in your app's build.gradle file:
For Gradle < 3.4
compile 'com.hieupt:retrofit2-queue:1.0.2'
For Gradle >= 3.4
implementation 'com.hieupt:retrofit2-queue:1.0.2'
************* Using Maven *************
<dependency>
<groupId>com.hieupt</groupId>
<artifactId>retrofit2-queue</artifactId>
<version>1.0.2</version>
<type>pom</type>
</dependency>
Create RetrofitQueue instance
// new instance
RetrofitQueue retrofitQueue = new RetrofitQueue();
// singleton
RetrofitQueue retrofitQueue = RetrofitQueueSingleton.getInstance();
Set number of request can be executed in parallel
retrofitQueue.updateMaxActiveRequest(int);
Add request to queue
retrofitQueue.addRequest(Call, Callback);
// or
retrofitQueue.addRequestToFrontQueue(Call, Callback);
Execute a request immediately
retrofitQueue.requestNow(Call, Callback);
Cancel a request
// cancel or remove from pending queue a specific request
retrofitQueue.cancel(Call);
Clear pending requests
// clear pending queue
retrofitQueue.clearQueue();