typedvalue

Introduction: Tiny library to simplify access to SharedPreferences, Bundle or any other key-value storage
More: Author   ReportBugs   
Tags:

Build Status Download License

TypedValue is a tiny library project to simplify access to SharedPreferences, Bundle or any other key-value storage with it's own KeyValueDelegate

Common values are available out of the box:

Date module contains custom TypedValues for managing dates:

For java.time entities ThreeTen library is used.

Demo app

image

The sample application demonstrates:

  • Convenient way to manage application preferences: AppPreferences and AppPreferencesImpl

    Any calls (get(), set(), asObservable(), etc.) of each preference can be easily find via interface properties

     interface AppPreferences {
       val animationTypeValue: AnimationTypeValue
       val scaleValue: FloatValue
       val messageShownValue: BoolValue
     }
    
     class AppPreferencesImpl(app: Application) : AppPreferences {
       private val delegate = PreferenceDelegate(PreferenceManager.getDefaultSharedPreferences(app))
    
       override val animationTypeValue: AnimationTypeValue by lazy { AnimationTypeValue(delegate, KEY_ANIMATION_TYPE, AnimationType.CONFETTI) }
       override val scaleValue: FloatValue by lazy { FloatValue(delegate, KEY_SCALE, 0.8f) }
       override val messageShownValue: BoolValue by lazy { BoolValue(delegate, KEY_MESSAGE_SHOWN) }
    
       private companion object {
         const val KEY_ANIMATION_TYPE = ".key_animation_type"
         const val KEY_SCALE = ".key_scale"
         const val KEY_MESSAGE_SHOWN = ".key_message_shown"
       }
     }
    

Installation

Add the following dependency to your build.gradle file:

dependencies {
    implementation 'io.denison:typedvalue:${LATEST_VERSION}'
    implementation 'io.denison:typedvalue-date:${LATEST_VERSION}'
}

License

Please see LICENSE

Apps
About Me
GitHub: Trinea
Facebook: Dev Tools