All Projects â†’ Sserra90 â†’ Bulldog

Sserra90 / Bulldog

Android library to simplify reading and writing to SharedPreferences, never write code like this anymore prefs.edit().putString("someKey","someString").apply()

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to Bulldog

Preferenceroom
🚚 Android processing library for managing SharedPreferences persistence efficiently and structurally.
Stars: ✭ 341 (+156.39%)
Mutual labels:  annotation-processor, preferences, sharedpreferences
simple-preferences
Android Library to simplify SharedPreferences use with code generation.
Stars: ✭ 48 (-63.91%)
Mutual labels:  sharedpreferences, annotation-processor
Prefser
Wrapper for Android SharedPreferences with object serialization and RxJava Observables
Stars: ✭ 228 (+71.43%)
Mutual labels:  preferences, sharedpreferences
Colorpreference
A custom preference item for easy implementation of a color picker in Android's preference screen.
Stars: ✭ 299 (+124.81%)
Mutual labels:  preferences, sharedpreferences
Typedpreferences
Preference wrappers for primitive types for Android
Stars: ✭ 191 (+43.61%)
Mutual labels:  preferences, sharedpreferences
PowerPreference
💟 A Powerful library to control and simplify the usage of shared preference in Android.
Stars: ✭ 95 (-28.57%)
Mutual labels:  preferences, sharedpreferences
Parceler
📊 Android Parcelables made easy through code generation.
Stars: ✭ 3,589 (+2598.5%)
Mutual labels:  annotation-processor, boilerplate
Materialpreferences
A highly flexible set of lovely looking views that provides functionality of preferences.
Stars: ✭ 495 (+272.18%)
Mutual labels:  preferences, sharedpreferences
Binaryprefs
Rapidly fast and lightweight re-implementation of SharedPreferences which stores each preference in files separately, performs disk operations via NIO with memory mapped byte buffers and works IPC (between processes). Written from scratch.
Stars: ✭ 484 (+263.91%)
Mutual labels:  preferences, sharedpreferences
Hawk
✔ Secure, simple key-value storage for Android
Stars: ✭ 3,827 (+2777.44%)
Mutual labels:  preferences, sharedpreferences
Multiplatform Preferences
Kotlin Multi Platform Preferences, for android an ios : SharedPreferences & NSUserDefault
Stars: ✭ 76 (-42.86%)
Mutual labels:  preferences, sharedpreferences
Android State
A utility library for Android to save objects in a Bundle without any boilerplate.
Stars: ✭ 857 (+544.36%)
Mutual labels:  annotation-processor, boilerplate
Kripton
A Java/Kotlin library for Android platform, to manage bean's persistence in SQLite, SharedPreferences, JSON, XML, Properties, Yaml, CBOR.
Stars: ✭ 110 (-17.29%)
Mutual labels:  annotation-processor, sharedpreferences
Create Elm App
🍃 Create Elm apps with zero configuration
Stars: ✭ 1,650 (+1140.6%)
Mutual labels:  boilerplate
React Native Template
Minimal template with best practices and automation scripts for improved developer experience.
Stars: ✭ 131 (-1.5%)
Mutual labels:  boilerplate
React Redux Graphql Apollo Bootstrap Webpack Starter
react js + redux + graphQL + Apollo + react router + hot reload + devTools + bootstrap + webpack starter
Stars: ✭ 127 (-4.51%)
Mutual labels:  boilerplate
Koa Vue Fullstack
A lightweight boilerplate for a universal webapp based on koa, mongodb, node, vue, and webpack
Stars: ✭ 126 (-5.26%)
Mutual labels:  boilerplate
Universal Native Boilerplate
Build apps for every native platform with React and React Native
Stars: ✭ 131 (-1.5%)
Mutual labels:  boilerplate
Fraternate
Fraternate is a standalone copy of the GitHub organization and user interaction framework. Built with Mongo dB | Node.js® | Express.js | Handlebars.js | Bootstrap.
Stars: ✭ 130 (-2.26%)
Mutual labels:  boilerplate
React Mobx State Tree
Create React App with MobX State Tree, Styled Components and GraphQL
Stars: ✭ 127 (-4.51%)
Mutual labels:  boilerplate

Bulldog

Please check https://sserra.gitbook.io/bulldog/ for full documentation.

Medium https://medium.com/@Sserra90/announcing-bulldog-never-use-sharedpreferences-anymore-92cd32249314

Why Bulldog?

  • Avoid boilerplate, error prone code, improve productivity.
  • Write less code, avoid bugs.
  • Easily organize your preferences.

Motivation

Android library to simplify reading and writing to SharedPreferences, never write code like this anymore prefs.edit().putString("someKey","someString").apply()

How to use it

Add dependencies to build.gradle

 kapt "com.github.Sserra90.bulldog:bulldog-processor:$bulldog"
 implementation "com.github.Sserra90.bulldog:bulldog-runtime:$bulldog"

Create a spec with wanted properties and default values like the this:

@Bulldog(name = "UserSettings")
object UserModel {
    const val id: Int = 20 // Default value
    const val email: String = "[email protected]"
    const val likes: Long = 20L
    const val isPremium: Boolean = false
    const val minutesLeft: Float = 24.5F
}

Init Bulldog context in your application class.

bullDogCtx = applicationContext

Bulldog will generate a class from this specification with the name UserSettings. Use it like a normal object to access values, under the hood it uses Kotlin delegated properties to read and writes values to SharedPreferences.

UserSettings().apply {
    id = 2
    email = "[email protected]"
}
Log.d("PREFS", UserSettings().id)
Log.d("PREFS", UserSettings().toString())

If no name is specified in @Bulldog annotation, the generated class will have the name of the spec object prefixed with Bulldog.

Read values

Just access object property like a normal object

Log.d("UserId", UserSettings().id)

Write values

UserSettings().apply{
    id = 4
    Log.d("UserId", id)
}

Clear values

Bulldog generates a clear method for each entry

UserSettings().apply{
    clearId()
    Log.d("UserId", id) // Will return the default value
}

Print information

Bulldog also generates a toString() human readable implementation

Log.d("PREFS", UserSettings().toString())
// Ouput
// UserSettings  id=20, [email protected], likes=20, isPremium=false minutesLeft=24.

Enum support

Bulldog supports Enum type using the @Enum annotation.

@Bulldog(name = "UserSettings")
object UserModel {
    @Enum(value = Roles.user)
    val role: Roles = Roles.USER
}

enum class Roles{
  ADMIN, USER;
  
  companion object {
        const val user = "USER"
        const val admin = "ADMIN"
    }
}

You just need annotate the field the enum field and pass a default value.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].