Qachee


Source link: https://github.com/nicolasjafelle/Qachee

Qachee

Qachee is a generic cache system to use specially for Android Apps. It is just a LRU Memory cache with policy expiration and lots of useful methods.

Instructions - Maven Central

  1. Add this library in your build.gradle:
dependencies {

  compile 'com.github.nicolasjafelle:qachee:1.2' 
}

Instructions - Android Library Module

  1. Clone the git repo
  2. Import the "Qachee" module into your Android-gradle project.
  3. Add "Qachee" module in your settings.gradle
  4. DONE

How to Use it

First you need to extends the QacheeableObject which implements the Qacheeable interface, then you have to implements getKey, you can return a String value or anything that make your instance unique, like getClass().getSimpleName() + hashcode()

@Override public String getKey() {
  Log.i("HASHCHODE", "KEY VALUE FOR " + getName() + "= " + getClass().getSimpleName() + hashCode());
  return getClass().getSimpleName() + hashCode();
 
}

You can set the Expiration Time Policy, default is:

ExpirationTime.ONE_MINUTE 

Simple in your Application or any place use:

QacheeManager.getInstance().setExpirationTime(ExpirationTime.THIRTY_SECONDS);

Then just simple use QacheeManager to add, remove and get your Qacheeable objects.

Character character = QacheeManager.getInstance().get(getItem(position), Character.class, true);

OR...

// If toArray() returns empty means: there is nothing previously stored. // If toArray() returns null the stored data is no longer valid. List<Character> list = QacheeManager.getInstance().toArray(Character.class, true);
  if(list == null || list.isEmpty()) {
  new DemoTask(getActivity()).execute();
 
}
else {
  adapter = new CharacterAdapter(list);
  listView.setAdapter(adapter);
 
}

When your object is stored in the Qachee you do not need to re-add or update it, simple use it. REMEMBER always to check if the object is stored in Qachee, REMEMBER always work with Qachee, like this:

Character selectedCharacter = (Character) listView.getItemAtPosition(pos);
 selectedCharacter = (Character) QacheeManager.getInstance().get(selectedCharacter, true);

See Demo Sample

Google Play demo: link

Developed By

License

Copyright 2014 Nicolas Jafelle  Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License. You may obtain a copy of the License at
  http://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 

Resources

Material letter icon with circle background. Replicates android L contacts icon view.

Android library to inform EU users of the use of cookies. The alert can be shown via dialog or an overlay view.

Simple dot animation to show progress.

RectangleGridLayout is a container that arranges views into a grid of rectangles of the same size. The goal is to provide a grid-like container with better performance than says TableLayout.

Pull down to finish an Activity.

This is a sample application which displays Calendar as week view. Each week of the month is displayed.

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