CacheUtilsLibrary


Source link: https://github.com/westlinkin/CacheUtilsLibrary

CacheUtilsLibrary

This is a simple Android utils library to write any type of data into cache files and then read them later, using Gson to serialize and deserialize these data.

????? ???

##Gradle

compile 'com.lifeofcoding:cacheutilslibrary:1.1.0@aar' compile 'com.google.code.gson:gson:2.2.2' compile 'commons-io:commons-io:2.4'

If you have errors like:

duplication file during packaging of APK ... Path in archive: META-INF/LICENSE.txt ... 

Please add such code in your android entry of your build.gradle file:

packagingOptions {

  exclude 'META-INF/DEPENDENCIES'
  exclude 'META-INF/NOTICE'
  exclude 'META-INF/LICENSE'
  exclude 'META-INF/LICENSE.txt'
  exclude 'META-INF/NOTICE.txt'
  exclude 'META-INF/ASL2.0'
  exclude 'META-INF/MANIFEST.MF' 
}

##Configuration You need to configure CacheUtilsLibrary in your Application class.

public class MyApplication extends Application {

@Override
  public void onCreate() {

super.onCreate();

// configure CacheUtilsLibrary

CacheUtils.configureCache(this);

  
}
 
}

Don't forget to declare the MyApplication class in your AndroidManifest.xml file.

##Usage All sample code can be found in the MainActivity file. #####Cache String File

// write CacheUtils.writeFile(CACHE_FILE_STRING, CACHE_FILE_CONTENT_STRING);
  // read String fileContent = CacheUtils.readFile(CACHE_FILE_STRING);

#####Cache Map<String, T> File

// write CacheUtils.writeDataMapFile(CACHE_FILE_MAP, getCacheFileContentMap());
  // read Map<String, Object> mapData = CacheUtils.readDataMapFile(CACHE_FILE_MAP);
  // get mapData private static Map<String, Object> getCacheFileContentMap() {

  Map<String, Object> mapData = new HashMap<>();

  mapData.put("firstItem", "item0");

  mapData.put("secondItem", 1);

  mapData.put("thirdItem", false);

  return mapData; 
}

#####Cache List<Map<String, T> File

// write CacheUtils.writeDataMapsFile(CACHE_FILE_LIST_MAP, getCacheFileContentListMap());
  // read List<Map<String, Object>> listMapData = CacheUtils.readDataMapsFile(CACHE_FILE_LIST_MAP);
  // get listMapData private static List<Map<String, Object>> getCacheFileContentListMap() {

  List<Map<String, Object>> listMapData = new ArrayList<Map<String, Object>>();

for (int i = 0; i < 4; i++) {

Map<String, Object> item = new HashMap<>();

item.put("firstItemAt" + i, "item0At" + i);

item.put("secondItemAt" + i, 1 + i);

item.put("thirdItemAt" + i, i % 2 == 0);

listMapData.add(item);

  
}

  return listMapData; 
}

#####Cache Object File

// write CacheUtils.writeObjectFile(CACHE_FILE_OBJECT, MyClass.SAMPLE_MYCLASS_1);
  // read MyClass myClassSample = CacheUtils.readObjectFile(CACHE_FILE_OBJECT, new TypeToken<MyClass>(){

}
.getType());

You can see MyClass and MyClass.SAMPLE_MYCLASS_1 here and here.

#####Cache List<Object> File

// write CacheUtils.writeObjectFile(CACHE_FILE_LIST_OBJECT, getCacheFileContentListObject());
  // read List<MyClass> myClassList = CacheUtils.readObjectFile(CACHE_FILE_LIST_OBJECT, new TypeToken<List<MyClass>>(){

}
.getType());
  // get List<MyClass> data private static List<MyClass> getCacheFileContentListObject() {

  List<MyClass> listObject = new ArrayList<>();

  listObject.add(MyClass.SAMPLE_MYCLASS_1);

  listObject.add(MyClass.SAMPLE_MYCLASS_2);

  listObject.add(MyClass.SAMPLE_MYCLASS_3);

  return listObject; 
}
 

##License

Copyright 2015-2016 Wesley Lin  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

Simple view to show a kanji from it's SVG representation and animate the drawing.

This is an automatic scrolling view pager slider with circular scrolling which gives you functionality of adding images and adding description of your images along with the pager indicator.

A network abstraction layer over Volley, written in Kotlin and inspired by Moya for Swift.

Animated Pencil Action view for Android.

Markwon is a library for Android that renders markdown as system-native Spannables. It gives ability to display markdown in all TextView widgets (TextView, Button, Switch, CheckBox, etc), Notifications, Toasts, etc. No WebView is required. Library provides reasonable defaults for display style of markdown but also gives all the means to tweak the appearance if desired. All markdown features are supported (including limited support for inlined HTML code, markdown tables and images).

Flubber is an elegant solution for making animations in Android. The library is inspired by the Spring library for iOS. It supports all of the animations, curves and properties that are present in Spring. The library provides an interpolator called Spring which is similar to the iOS CASpringAnimation.

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