Monet


Source link: https://github.com/akarapetsas/Monet

Monet

Monet is a wrapper of the Volley and the Jackson libraries. It’s offering a L1 memory caching by using the LRU Cache, apart from the L2 disk caching that Volley offers through the HTTP headers "Cache-Control" and "Expires". You can see the library in action by running the sample app.

Instatiation

For instantiating Monet you have either to extend the MonetApplication class and add the class package into the application tag of the AndroidManifest.xml file:

public class SampleApplication extends MonetApplication {
  
}
 <application

android:name=".SampleApplication"

Or, to call the Monet.INSTANCE.init(context) method, preferably when your application is starting:

import android.app.Application; import android.content.Context;  public class YourAppApplication extends Application {
  public static MonetApplication instance;
public void onCreate() {

super.onCreate();

 instance = this;
// Instantiate Monet once and only once when the application is starting.
Monet.INSTANCE.init(instance);
  
}

public static Context getContext() {

return instance;  
}
  
}

Example Usage

For executing a network call and receive the response:

public class ImagesFragment extends Fragment implements Response.Listener<Response>, ErrorListener {

public void yourMethod() {

 //create and execute a jackson request
JacksonRequest.<Response>builder()
  .setHttpMethod(Request.Method.GET)
  .setUrl(requestedUrl)
  .setResponseType(Response.class)
  .setListener(ImagesFragment.this)
  .setErrorListener(ImagesFragment.this)
  .setTag(ImagesFragment.class.getName())
  .execute();
  
}

 @Override  public void onErrorResponse(VolleyError error) {

  
}

@Override  public void onResponse(Response response) {

// process with the response  
}
 
}
  

Where Response is the POJO class which is using the Jackson lib and will bind the response. Also, for receiving either the succesfull or the error response you have to implement the onResponse and onErrorResponse callbacks respectively.

Run sample app

In order to run the sample app you have to register a new app with the Shutterstock API and replace the clied_id and the secret_id in the fields below that they are available in the CategoriesFragment class.

private final static String SHUTTERSTOCK_CLIENT_ID = "";  private final static String SHUTTERSTOCK_CLIENT_SECRET = "";

Features to be added soon:

  1. Support of Gson library.
  2. Configurable L1 disk cache.

Resources

Unofficial Material Up API Wrapper for Android.

An AutocompleteTextView that interacts with the Google Maps Places API to provide location results and caches selected results in a history file for later use,

A set of Android tools that facilitate apps development.

Makes it easy to put your asynchronous operations behind Android's Loader.

A draggable ImageView with possibility to transform it.

A View which looks like a Lollipop Pattern View.

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