PreferenceRoom Versions Save

:truck: Android processing library for managing SharedPreferences persistence efficiently and structurally.

1.2.2

2 years ago

🎉 Released a new version 1.2.2! 🎉

What's New?

  • Fixed: @PreferenceFunction annotation doesn't work with objects. (#20)
  • Added Consumer Proguard-rules internally. We don't need to add rules manually for dependency injection.

1.2.1

3 years ago

🎉 Released a new version 1.2.1! 🎉

What's New?

  • Bump the javapoet version to 1.13.0 internally.
  • Added new lines in long code statements from generated.

1.2.0

4 years ago

Released a new version 1.2.0.

We can inject dependencies using Dagger instead of using @InjectPreference annotation.

Here is the way to migrate Dagger.

1. If you using PreferenceEntity without PreferenceComponent.

  @Provides
  @Singleton
  fun provideInitialEntity(context: Context): Preference_InitialEntity {
    return Preference_InitialEntity.getInstance(context)
  }

  @Provides
  @Singleton
  fun provideSettingEntity(context: Context): Preference_SettingEntity {
    return Preference_SettingEntity.getInstance(context)
  }

1. If you using PreferenceEntity with PreferenceComponent.

1. Add method for injecting an instance of PreferenceComponent to Dagger's Builder.

@Singleton
@Component( ... )
interface AppComponent : AndroidInjector<DaggerApplication> {

  @Component.Builder
  interface Builder {
    @BindsInstance fun application(application: Application): Builder
+   @BindsInstance fun preferenceRoom(prefAppComponent: PrefAppComponent): Builder
    fun build(): AppComponent
  }
}

2. Inject an initialized PreferenceComponent that generated by the compiler.

The most important thing is the appComponent should be initialized lazily or in the onCreate. Because the Context is null when initializing properties in the Application class.

class MyApplication: DaggerApplication() {

  private val appComponent by lazy {
    DaggerAppComponent.builder()
      .application(this)
+     .preferenceRoom(PreferenceComponent_PrefAppComponent.init(this))
      .build()
  }
}

3. Make entity providing abstract methods in the PreferenceComponent

@PreferenceComponent(entities = [InitialEntity::class, SettingEntity::class])
interface PrefAppComponent {
  // provides entities
  fun initialEntity(): InitialEntity
  fun settingEntity(): SettingEntity

4. Provide instances of the instances on the module.

I just created a new module: PreferenceModule.

@Module
class PreferenceModule {

  @Provides
  @Singleton
  fun provideInitialEntity(prefAppComponent: PrefAppComponent): Preference_InitialEntity {
    return prefAppComponent.initialEntity() as Preference_InitialEntity
  }

  @Provides
  @Singleton
  fun provideSettingEntity(prefAppComponent: PrefAppComponent): Preference_SettingEntity {
    return prefAppComponent.settingEntity() as Preference_SettingEntity
  }
}

5. It's finished. And you can inject dependency using @Inject annotation by dagger.

class SnsViewModel @Inject constructor(
  val initialEntity: Preference_InitialEntity,
  val settingEntity: Preference_SettingEntity
) : ViewModel() {

1.1.9

4 years ago

Support incremental annotation processing for kapt (#18)

1.1.8

4 years ago
  • downgraded internal Gradle build tools version to '3.3.0'.
  • downgraded internal Gradle version to 4.10.1.

v1.1.7

5 years ago
  • implements addOnChangedListener method spec
  • base64 class from android open source util for using apache commons codes on android

v1.1.6

5 years ago

Encrypting an entity using @EncryptEntity annotation.

v1.1.5

5 years ago

v1.1.4

5 years ago

Implemented OnChangedListener by auto-generation.

V1.1.3

5 years ago

Migrate to AndroidX