RetrofitHelper is an Open Source Android library that used to make HTTP request easily.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
app
gradle/wrapper
helper
.gitignore
README.md
build.gradle
gradle.properties
settings.gradle

README.md

RetrofitHelper

ScreenShot

RetrofitHelper is an Open Source Android library that used to make HTTP request easily.

Here are some advantages of using RetrofitHelper over other libraries:

  1. Network checking is not required.
  2. No need to handle ProgressDialog while calling an API.
  3. ApiInterface and ApiClinet are not required.
  4. You can handle errors in a single place.
  5. You can optimise your code.
  6. Avoid code redundancy.

For using this networking library, you need to follow the below instructions.

Step 1: Add Dependency in build.gradle

  compile 'com.droidmentor:helper:1.0.1' 

Step 2: Set Base URL and common headers if needed. Base URL field is mandatory.
Step 3: This library checks your internet connection be default so if you want to toast message you can set the error message.

  ApiClient.setBaseUrl(BASE_URL);
  ApiClient.setNetworkErrorMessage("Network Error");
  ApiClient.showNetworkErrorMessage(false);

Step 4: APICall is the class do the magic. You can call the API using the following set of code.

  APICall networkCall;
  networkCall = new APICall(this);

  Map queryParams = new HashMap<>();
  queryParams.put("user[email]", etUserEmail.getText().toString());
  queryParams.put("user[name]", etUserName.getText().toString());

  networkCall.APIRequest(APICall.Method.POST,"user",UserDetails.class,null,queryParams,1,"Adding");

Step 5: APIRequest is the method simplifies your process and act wisely based on your parameters. This method can handle the following arguments.

  • type : type of the request.
  • url : endpoint
  • responseModel : response model class.
  • body : request body.
  • params : URL parameters.
  • from : int value represent the source, because in a single page you can trigger multiple requests.
  • is_PDshow : boolean flag shows the visibility of the ProgressDialog.
  • message : Loader title message.
  • responseListener : It is an interface, it contains the callback methods (onSuccess, onFailure, onNetworkFailure).

In AndroidManifest.xml

Specify all the needed permissions. If you don't, permission requests fail silently. That's an Android thing.

For more information, check out my detailed guide here : http://droidmentor.com/retrofithelper-library/