Akatsuki


Source link: https://github.com/tom91136/Akatsuki

Akatsuki

Akatsuki is a light weight Android library that handles state restoration and argument passing via annotations. The library automatically generates source files through JSR269 to ensure almost 1 zero performance impact.

###Key features:

State restoration

  • Retain state with @Retained
  • Supports all types allowed in Bundle and a few more
  • Supports inheritance
  • Supports generic parameters
  • Custom type support with TypeConverter and @TransformationTemplate
  • Compatible with other parcel and binding libraries
  • Per class and global configuration via @RetainConfig

Argument passing

  • Pass arguments with @Arg
  • Supports inheritance, builders will be generated for all subclasses
  • Supports Activity, Fragment, and Service
  • Custom builder support with ArgConcludingBuilder
  • Supports chained, checked, unchecked, and type safe builders
  • Per class and global configuration via @ArgConfig

Good to know

  • @Retained and @Arg can be used together
  • Annotation based configuration via @AkatsukiConfig

In short, this library handles most Android IPC boilerplate that would otherwise be tedious to write and maintain.

Example usage:

public class MainActivity extends Activity {

@Retained String myString;
  @Retained int myInt;
  @Retained android.accounts.Account account; // implements Parcelable

@Override
  protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

Akatsuki.restore(this, savedInstanceState);

//everything restored!


// you want to start AnotherActivity and pass some stuff:

Builders.AnotherActivity().theAnswer("42").startActivity(this);

  
}

@Override
  protected void onSaveInstanceState(Bundle outState) {

super.onSaveInstanceState(outState);

Akatsuki.save(this, outState);

  
}
 
}
  // in another activity class public class AnotherActivity extends Activity {

// @Args and @Retained can be used together
  @Arg @Retained String theAnswer;

@Override
  protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

Akatsuki.restore(this, savedInstanceState);

// theAnswer is retrieved from the intent and persisted in case of any change
  
}

@Override
  protected void onSaveInstanceState(Bundle outState) {

super.onSaveInstanceState(outState);

Akatsuki.save(this, outState);

  
}
 
}
 

1Reflection is used only once to locate the generated classes.

For documentation and additional information see the wiki

Download

The compiler is written in Java 8 so make sure you have JDK8 or higher installed(use java -version to check)

Gradle dependencies:

dependencies {
  compile 'com.sora.util.akatsuki:akatsuki-api:0.2.0'  apt 'com.sora.util.akatsuki:akatsuki-compiler:0.2.0' 
}

Optional parceler support:

compile 'com.sora.util.akatsuki:akatsuki-parceler:0.2.0@aar'

Please pay special attention to the build script:

// your source/target compatibility remains 1_7, do NOT change it to 1_8 compileOptions {
  sourceCompatibility JavaVersion.VERSION_1_7  targetCompatibility JavaVersion.VERSION_1_7 
}
 // exception: do keep 1_8 if you happen to be using retrolambda
Sample app(.apk)

Showcasing ( Fragment + NumberPicker/ EditText)

Snapshot builds

Snapshot builds are released on JitPack:

repositories {

  //...
  maven {
 url "https://jitpack.io" 
}
 
}
 dependencies {

  compile 'com.github.tom91136.akatsuki:akatsuki-api:<commit>'
  apt 'com.github.tom91136.akatsuki:akatsuki-compiler:<commit>' 
}
 

Substitute <commit> with the latest commit hash, you can look them up in the commit history here

The first sync/build will take a long time, be patient.

Proguard

Please use the following rules if you have proguard enabled in your build script:

-dontwarn com.sora.util.akatsuki.** -keep class com.sora.util.akatsuki.** {
 *; 
}
 -keep class **$$BundleRetainer {
 *; 
}
 -keepclasseswithmembernames class * {

  @com.sora.util.akatsuki.* <fields>; 
}

Special thanks

Special thanks to ersin-ertan for testing the library and reporting bugs

License

Copyright 2015 WEI CHEN 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

A custom widget that looks like a task manager on Android 5.0.

A simple rotatable menu for Android.

Sliding Selection List

Features:

  • level based menu with recyclerview and viewpager
  • custom transitions
  • multiple selection and single selection combinations

A library to show view for comments for Android.

A memcached-like Java cache, focused on portability, great for Android.

Provides the Floating Action Button Transition as specified in the Material Design Guide in a simple library.

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