HttpBuster


Source link: https://github.com/bmutinda/HttpBuster

HttpBuster

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


How to use


  • Create an instance of HttpBuster with an api endpoint
Api api = new Api();
 api.setEndpoint("https://example.com/api/");
 HttpBuster httpBuster = HttpBuster.withApi(api).build();

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


Latest Version:


Installation


In your app build.gradle under repositories, include jitpack.io like below

allprojects{

repositories {

  maven {
 url "https://jitpack.io" 
}

}
 
}

Then in your dependecies add this line replacing { latest_version } with the latest version under releases

  compile 'com.github.bmutinda:httpbuster:{
latest_version
}
'

Example:

  compile 'com.github.bmutinda:httpbuster:1.0'

Resources

Material style circular progress bar for Android.

This is a UI lib for Android to create buttons with "shining" effects.

Official port of ExoPlayer for Amazon devices.

Sample code for creating a 360 video player on Android. Creates an OpenGL ES scene that renders a sphere textured with video frames from MediaPlayer playback.

An helper to circle reveal/unreveal a view easily, with translations and child animations.

Android Section Adapter allows you to easily create a RecyclerView.Adapter which will automatically sort your data into sections and add a header above each section.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes