Bulldog
Android library to simplify reading and writing to SharedPreferences, never write code like this anymore prefs.edit().putString("someKey","someString").apply()
Install / Use
/learn @Sserra90/BulldogREADME
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 = "johndoe@gmail.com"
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 = "abc@gmail.com"
}
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=sergioserra@gmail.com, 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.
Related Skills
qqbot-channel
347.2kQQ 频道管理技能。查询频道列表、子频道、成员、发帖、公告、日程等操作。使用 qqbot_channel_api 工具代理 QQ 开放平台 HTTP 接口,自动处理 Token 鉴权。当用户需要查看频道、管理子频道、查询成员、发布帖子/公告/日程时使用。
docs-writer
100.1k`docs-writer` skill instructions As an expert technical writer and editor for the Gemini CLI project, you produce accurate, clear, and consistent documentation. When asked to write, edit, or revie
model-usage
347.2kUse CodexBar CLI local cost usage to summarize per-model usage for Codex or Claude, including the current (most recent) model or a full model breakdown. Trigger when asked for model-level usage/cost data from codexbar, or when you need a scriptable per-model summary from codexbar cost JSON.
Design
Campus Second-Hand Trading Platform \- General Design Document (v5.0 \- React Architecture \- Complete Final Version)1\. System Overall Design 1.1. Project Overview This project aims t
