AndroidQuickUtils


Source link: https://github.com/cesarferreira/AndroidQuickUtils

QuickUtils

This repository offers a set of random useful classes to deal with repetitive tasks in the Android Framework. Intended to help you getting your Android applications off the ground quickly, by offering ready-to-use components and utility classes that wrap a lot of the boilerplate that’s involved when writing Android apps.

Main features

  • REST - Simple REST requests and automatic parse
  • Cache Magic - Easily serialize and cache your objects to disk using key/value pairs
  • Async Image Loader - Image downloading and caching

Installation

Including in your project via Gradle:

dependencies {

  compile 'com.cesarferreira.quickutils:library:2.+' 
}

Usage

Init the library in your Application class

public class SampleApplication extends Application {

@Override
  public void onCreate() {

super.onCreate();

 QuickUtils.init(this);

  
}
 
}
 

REST

Simple REST requests and automatic parse

Gson Entity

public class Tweet {

  @SerializedName("title")
  public String title;
  @SerializedName("amount_of_retweets")
  public long retweetsTotal; 
}

The Request

 QuickUtils.rest.connect()

 .GET() // POST() // PUT()

 .load("https://path/to/the/tweets")

 .as(new TypeToken<List<Tweet>>() {

}
)

 .withCallback(callback);

Post with Header and Body params

Header requestHeader = new Header.Builder()

  .add("Authorization", "Bearer Jhahdau2819ajsbdkasdkasdkashjdkahs")

  .build();
  Body requestBody = new Body.Builder()

 .add("email", "[email protected]")

 .build();
  QuickUtils.rest.connect()

 .POST(requestHeader, requestBody)

 .load(url)

 .as(new TypeToken<List<Person>>() {

}
)

 .withCallback(callback);

Cache magic!

Easily serialize and cache your objects to disk using key/value pairs.

Save

sync

QuickUtils.cacheMagic.save("somePerson", new Person("john doe"));

async

QuickUtils.cacheMagic.save("somePerson", new Person("john doe"), new SaveToCacheCallback() {
(...)
}
);

Read

sync

QuickUtils.cacheMagic.read("somePerson", null);

async

QuickUtils.cacheMagic.readAsync("somePerson", new TypeToken<Person>() {

}
, new ReadFromCacheCallback<Person>() {
(...)
}
);

Delete

QuickUtils.cacheMagic.delete("somePerson");
 // deleteAsync also works

Erases ALL the key/values that are stored

QuickUtils.cacheMagic.deleteAll();

Exists

Check if a key/value exists

boolean personExists = QuickUtils.cacheMagic.existsKey("somePerson");

Async Image Loader

Image downloading and caching

// Simple QuickUtils.imageCache.load(IMAGE_URL, imageView);
  // or more complete QuickUtils.imageCache.load(IMAGE_URL, imageView, R.drawable.dummy, R.drawable.error);

Using the util methods

All you need to do is to specify the category and the method you want to use.

QuickUtils.__category__.__method__

E.g.

// Log something QuickUtils.log.e("this is an error");
 // Make the smartphone vibrate for the amount of time you want QuickUtils.system.vibrate(1000);
 // Convert pounds to KG QuickUtils.math.poundsToKg(weight);
 // Does that file exists? QuickUtils.sdcard.exists(someFile);
 // Encode a string QuickUtils.security.encodeBase64(someString);
 // Save data QuickUtils.prefs.save(key, value);
 // Retrieve saved data QuickUtils.prefs.getString(key, defaultValue);
 QuickUtils.prefs.getInt(key, defaultValue);
 // Remove saved data QuickUtils.prefs.remove(key);
 //  Etc. (hundreds more methods)

More Documentation

Take a look at our wiki.

Contributing

Contributions welcome via Github pull requests.

License

QuickUtils is available under the MIT license. See the LICENSE file for more info.

Resources

An example for Redux architecture on Android.

ImageZipper is an image compression library which helps you to compress your images both in default and custom way. It allows you to control you the width, height, format, orientation and quality of Image. It ease out the task to send images to the server. Functions for encoding image to base64 and decoding base64 to image also available.

A custom alert library for android. Similar to SCLAlertView-Swift library.

A light-weight android library that can be quickly integrated into any app to use android utils.

Chameleon is a CSS like framework for Android. Chameleon can read styles in JSON format and apply them on views in Android. Not only can you choose from the variety of styles provided by the library but also add your own styles by changing just one file.

The icing on the cake is, once set up, themes can be updated without pushing a new version of your app to the playstore. So, your users can see your changes on the fly.

An android wrapper for openweathermap that uses Retrofit 2 under the hood.

You need an API Key to use the OpenWeatherMap API. Head on over to their website if you don't already have one.

Features

Get Current weather by:

  1. City Name
  2. City ID
  3. Geographic Coordinates
  4. Zip Code

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