HttpBuster

General

Category
Free
Tag
Networking
License
MIT License
Registered
Dec 2, 2016
Favorites
4
Link
https://github.com/bmutinda/HttpBuster
See also
FARLA
droidQuery
okhttp-utils
retrofit2-kotlin
rx-receiver

Additional

Language
Java
Version
1.3.3 (Feb 14, 2017)
Created
Nov 25, 2015
Updated
Jan 24, 2018 (Retired)
Owner
Mutinda Boniface (bmutinda)
Contributor
Mutinda Boniface (bmutinda)
1
Activity
Badge
Generate
Download
Source code
APK file

Promotion

HttpBuster

A very simple way to do http requests in Android using okHttp


Thats it. Now you are ready to make http requests to your api endpoint.

Make GET request

a.) Without any request parameters

httpBuster.makeGetRequest("jokes/random", null, new ApiCallback() {
    @Override
    public void done(BusterResponse response, JSONObject jsonObject, Exception exception) {
        Log.e(TAG, "GET without params done");
    }
});

b.) With request parameters

HashMap<String, Object> map = new HashMap<>();
map.put("firstName", "Mutinda");
map.put("lastName", "Boniface");
httpBuster.makeGetRequest("jokes/random", map, new ApiCallback() {
    @Override
    public void done(BusterResponse response, JSONObject jsonObject, Exception exception) {
        Log.e(TAG, "GET with params done");
    }
});

NB:

  1. The same applies for POST, PUT, DELETE requests
  2. We recommend using a single HttpBuster instance for the entire application- You can do this by intializing your HttpBuster instance via the Application class

Make FILE UPLOAD request

// Add files to be upload 
List<RequestFile> files = new ArrayList<>();
String file = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath()+"/no_picture.png";
files.add( new RequestFile("photo", file, MediaType.parse("image/PNG")) );

// add optional payload (this is optional)
HashMap<String, Object> map = new HashMap<>();
map.put("name", "Mutinda Boniface");

httpBuster.makeMultipartRequest("photo-upload/", map, files, new ApiCallback() {
    @Override
    public void done(BusterResponse response, JSONObject jsonObject, Exception exception) {
        Log.e(TAG,  "POST MULTIPART - Response =" +(response!=null? response.getString() :"Not reachable" ));
    }
});

Have a look at the demo app for a complete app using the Library Demo app