Fuse


Source link: https://github.com/kittinunf/Fuse

Fuse

The simple generic LRU cache for Android, backed by both memory cache ( LruCache) and disk-based cache ( DiskLruCache) by Jake Wharton

TLDR

Here is how you might wanna use Fuse to cache your network call.

Fuse.init(cacheDir.path)  //jsonCache depends on Gson Fuse.jsonCache.get(URL("http://jsonplaceholder.typicode.com/users/1")) {
 result ->
  result.success {
 json ->

//do something with json object (result is Result<JsonObject, Exception>)
  
}
 
}
  //if you wanna know source of cache, can be either MEM(LruCache), DISK(DiskLruCache), NOT_FOUND(newly fetched) Fuse.stringCache.get(filesDir.resolve("json.txt")) {
 result, type ->
  //do something with string object (result is Result<String, Exception>)
  when (type) {

Cache.Type.NOT_FOUND ->

 Cache.Type.MEM ->

 Cache.Type.DISK ->

}
 
}

Yeah, that's about it.

Installation

Dependency

Gradle

repositories {

  jcenter() 
}
dependencies {

  compile 'com.github.kittinunf.fuse:fuse:<latest-version>' 
}

Detail Usage

Built-in Cache

By default, Fuse has built-in Byte, String and JSONObject cache by using Fuse.byteCache, Fuse.stringCache and Fuse.jsonCache respectively

Remove

You can remove specific cache by using Key

Fuse.bytesCache.remove("key") //same for stringCache and jsonCache

Advanced Usage

How it works?

  1. Fuse searches at 1st layer at LruCache (Memory), if found, delivers. If not found go to 2.
  2. Fuse searches at 2nd layer at DiskLruCache (Disk), if found delivers, If not found go to 3.
  3. Fuse performs fetch (by conformance with Fetcher interface), then store into LruCache and DiskCache, respectively. Therefore, subsequent uses will be much faster by going through 1 & 2.

License

Fuse is released under MIT, but as Fuse depends on LruCache and DiskLruCache. Licenses agreement on both dependencies applies.

Copyright 2011 The Android Open Source Project  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

Realm related features of the MPAndroidChart library.

Facebook-like "Like with Emoji" library for Android.

Lightweight Tooltip library for Android.

This library intended to simplify the work with action handling in android projects. Just collect actions in a handler and bind them to views.

An extended ViewPager that has the below features:

  • allows its Fragment pages to get notified when they are actually visible/invisible to the user
  • supports multiple levels of FragmentViewPagers
  • provides methods to control its paging

This Android library implements a vertical stepper form following Google Material Design guidelines.

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