Skip to content

The library supports retrofit2 request execution sequentially

License

Notifications You must be signed in to change notification settings

I3eyonder/retrofit2-queue

Repository files navigation

retrofit2-queue

The library supports retrofit2 request execution sequentially.

Kotlin version is here

Installation

************* 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>

Usage

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();

About

The library supports retrofit2 request execution sequentially

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages