All Projects → vinted → preferx

vinted / preferx

Licence: MIT license
A reactive SharedPreferences library for Kotlin

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to preferx

Preference-Rhythm
Android library makes using Shared Preference easier.
Stars: ✭ 16 (+23.08%)
Mutual labels:  sharedpreferences, rxjava2
Prefser
Wrapper for Android SharedPreferences with object serialization and RxJava Observables
Stars: ✭ 228 (+1653.85%)
Mutual labels:  sharedpreferences, rxjava2
Typedvalue
Tiny library to simplify access to SharedPreferences, Bundle or any other key-value storage
Stars: ✭ 18 (+38.46%)
Mutual labels:  sharedpreferences, rxjava2
iMoney
iMoney 金融项目
Stars: ✭ 55 (+323.08%)
Mutual labels:  sharedpreferences, rxjava2
Starwars
A sample modular Android app written in Kotlin using Rx, Koin, Coroutines, Dagger 2 and Architecture components
Stars: ✭ 41 (+215.38%)
Mutual labels:  rxjava2
android-template
Template for android development at Tiki
Stars: ✭ 17 (+30.77%)
Mutual labels:  rxjava2
YTS
YTS site sample app written in Java & Kotlin, implemented with MVP pattern and powered by Rx.
Stars: ✭ 42 (+223.08%)
Mutual labels:  rxjava2
rxjava2 retrofit2
rxjava2+retrofit2 网络封装
Stars: ✭ 19 (+46.15%)
Mutual labels:  rxjava2
flickr-android
A small sample app to showcase architecting app using Clean Architecture and MVVM
Stars: ✭ 25 (+92.31%)
Mutual labels:  rxjava2
epub-viewer
android epub viewer
Stars: ✭ 32 (+146.15%)
Mutual labels:  rxjava2
MVVM-Demo
This demo for MVVM Design pattern for android
Stars: ✭ 20 (+53.85%)
Mutual labels:  rxjava2
ElegantData
像操作Room一样操作 SharedPreferences 和 File 文件.
Stars: ✭ 18 (+38.46%)
Mutual labels:  sharedpreferences
Kotlin-MVVM-JetPack
[DEPRECATED. USE https://github.com/egek92/Kotlin-MVVM-Jetpack-Hilt-Coroutines-Flow] Clean Android architecture guidelines that are based on MVVM + Offline 1st approach with LiveData and Room
Stars: ✭ 73 (+461.54%)
Mutual labels:  rxjava2
DailyBugle
📰Modern MVVM Android application following single activity architecture which fetches news from 🕷️ news API. this repository contains some best practices ⚡ of android development
Stars: ✭ 17 (+30.77%)
Mutual labels:  sharedpreferences
RxHttp
基于RxJava2+Retrofit+OkHttp4.x封装的网络请求类库,亮点多多,完美兼容MVVM(ViewModel,LiveData),天生支持网络请求和生命周期绑定,天生支持多BaseUrl,支持文件上传下载进度监听,支持断点下载,支持Glide和网络请求公用一个OkHttpClient⭐⭐⭐
Stars: ✭ 25 (+92.31%)
Mutual labels:  rxjava2
client-java
Asynchronous client for Java-based agents
Stars: ✭ 17 (+30.77%)
Mutual labels:  rxjava2
AndroidCleanArchitecture
Android Project with clean android architecture contain Dagger, Retrofit, Retrofit, Android archtecture components, LiveData with MVVM architecture
Stars: ✭ 22 (+69.23%)
Mutual labels:  rxjava2
NewsApiMvvm
Architecture Components + MVVM + Kotlin + RxJava2 + Dagger2
Stars: ✭ 33 (+153.85%)
Mutual labels:  rxjava2
KVStorage
Android 结构化KV存储框架,基于 yaml 生成 java 结构化存储类
Stars: ✭ 228 (+1653.85%)
Mutual labels:  sharedpreferences
GuildWars2 APIViewer
Guild Wars 2 API Viewer: An Android application used for viewing various Guild Wars 2 API endpoint responses. Developed utilizing MVVM architecture, in conjunction with Databinding, Dagger 2, Retrofit 2, and RxJava 2.
Stars: ✭ 53 (+307.69%)
Mutual labels:  rxjava2

Build Status

PrefeRx

This is a reactive SharedPreferences library for Kotlin

  • allows to integrate & manage your preferences with RxJava
  • easily stores primitives, enums and other serializable objects

Download

dependencies {
  implementation 'com.vinted:preferx:<version>'
}

Supported types

Library supports default SharedPreferences types with default fallback values when preference was not yet set or was cleared.

  sharedPreferences.intPreference("counter", 0)

  sharedPreferences.stringPreference("string", "")

  sharedPreferences.booleanPreference("seen", false)

  sharedPreferences.longPreference("timestamp", 0L)

It also allows easy storing of enums and objects.

  sharedPreferences.enumPreference("notifications", Frequency.ALL)

  sharedPreferences.objectPreference(
    name = "current_user"
    defaultValue = User.ANONYMOUS,
    serializer = someSerializer,
    clazz = User::class
  )

Basic example

class ExampleActivity : Activity {

  private val sharedPreferences by lazy {
    getSharedPreferences("app-pref", Context.MODE_PRIVATE)
  }

  private val sessionCounter : IntPreference by lazy {
    sharedPreferences.intPreference("counter", 0)
  }

  @Override
  public fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.simple_activity)

    val incrementedCount = sessionCounter.get() + 1
    sessionCounter.set(incrementedCount)

    counter_view.text = "Application was started $incrementedCount times"
  }
}

RxJava example

class ExampleActivity : Activity {

  ...

  private var disposable: Disposable? = null

  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)

    Observable.just(stringPreference.get())
      .concatWith(stringPreference.onChangeObservable)
      .subscribe {
          text_view.text = it
      }
    }.apply { disposable = this }
  }

  override fun onDestroy() {
    disposable?.dispose()
    super.onDestroy()
  }

  ...
}

For more usage examples see:

Caveats

  • When EnumSerializer fails to resolve enum value for any reason it will fallback to default value
  • When using EntitySerializer one must ensure that it returns value. In case of null it will fallback to default value.

License

MIT License

Copyright (c) 2021 Vinted UAB

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
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].