Simple Network Library


Source link: https://github.com/ahmed-adel-said/SimpleNetworkLibrary

Simple Network Library

Android Simple Network Library for HTTP and Image Requests with cool features implemented with Simple Demo using some Material Design UI Elements.


Most Common Library Features:

  1. Making HTTP Requests with different Request Types like GET, POST, PUT, DELETE and PATCH.
  2. Making HTTP Requests with different Content Types like JSON and XML.
  3. Caching HTTP Request on Memory.
  4. Handling Multiple Requests in a Thread Safe Mechanism.
  5. Making Image Requests Synchronous and Asynchronous with helpful observers to handle most cases.
  6. Caching Image Bitmaps on Memory.
  7. Creating a Test Case for NetworkRequest class using JUnit testing framework.

Most Common Simple Demo Application Features:

  1. Using some Material Design UI Elements like CoordinatorLayout, CardView, AppBarLayout, SwipeRefreshLayout, RecyclerView and Transition.
  2. Handling Pull To Refresh and Load More mechanism.

User Documentation :

  1. For simple integration all you have to do is to add the following command in your root build.gradle at the end of repositories:
 allprojects {

repositories {

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

}
  
}

and after this, add the Simple Library Network dependency:

 dependencies {

 compile 'com.github.ahmed-adel-said:SimpleNetworkLibrary:-SNAPSHOT'  
}
  1. To initialize HTTP request:
networkRequest = NetworkRequest.getInstance(context)
// base url

  .baseUrl(String baseUrl)

  // endpoint

  .endpoint(String endpoint)

  // request types: GET, POST, PUT, DELETE and PATCH.

  .requestType(RequestType requestType)

  // content types: JSON and XML

  .contentType(ContentType contentType)

  // decode url if the url has spaces like %20%

  .decodedUrl(boolean decodedUrl)

  // add params to your request

  .params(Map<String, String> params)

  // add headers to your request

  .headers(Map<String, String> headers)

  // add json body as a body to your POST, PUT, DELETE and PATCH requests

  .bodyJsonObject(JSONObject bodyJsonObject)

  // OnNetworkRequestResponseListener is a listener that used to observe the success and error response

  .onNetworkRequestResponseListener(OnNetworkRequestResponseListener onNetworkRequestResponseListener);
  1. To fire the request after initializing it:
networkRequest.fireRequest();
  1. To initialize image HTTP request and load the required image:
userImageView.setImageUrl(
// image url
String url,

  // fall back image resource if the image url is not correct and there is an error occurred while downloading the image

  Integer fallbackResource,

  // loading image resource that is appeared during the download of the image 

  Integer loadingResource,

  // OnCompleteImageListener is a listener that used to observe the success downloaded bitmap

  OnCompleteImageListener onCompleteImageListener);
  1. OnNetworkRequestResponseListener is a observer that used to handle the response of network request calls:
OnNetworkRequestResponseListener() {

@Override

public void onSuccessResponse(String response, ContentType contentType, boolean isCached) {

 
}

 @Override

public void onErrorResponse(String error, String message, int code) {

 
}

  
}
);
  1. OnCompleteImageListener is a listener that helps the developer to get the image bitmap if he/she makes an only image single request not a multiple image requests as in the recycler view adapter as an example.:
OnCompleteImageListener() {

 @Override

 public void onComplete(Bitmap bitmap) {

}

}
)

Resources

sdp

An android SDK that provides a new size unit - sdp (scalable dp). This size unit scales with the screen size. It can help Android developers with supporting multiple screens.

Use it carefully! for example, in most cases you still need to design a different layout for tablets.

Faker provides fake data to your Android apps. Now it's very handy to make screenshots of your apps without worrying with Google Play copyright infringments. Faker helps you to populate your views with random data quickly and painlessly.

The purpose of this repo is to demonstrate the functionality of the YouTube Library for Android which acts as an API for the main YouTube application.

Herald provides a very simple way to initialize logger objects and does all magic for you. You can annotate any field of some class with a @Log annotation to let Herald inject suitable logger in this field. It does not matter whether it is a static field or not.

An extension for ResideMenu.

A simple and useful android library to use custom fonts in android apps without adding fonts into asset/resource folder. Also by using this library developer should not have to worry about Typeface object creation for every new font that he use.

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