Skip to content

Releases: skydoves/PreferenceRoom

1.2.2

14 Aug 04:47
2c4424a
Compare
Choose a tag to compare

🎉 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

02 Aug 11:18
6449a9f
Compare
Choose a tag to compare

🎉 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

08 Mar 08:22
91c728d
Compare
Choose a tag to compare

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

30 Jan 15:48
ef51340
Compare
Choose a tag to compare

Support incremental annotation processing for kapt (#18)

1.1.8

16 Jun 13:44
c4c6f56
Compare
Choose a tag to compare
  • downgraded internal Gradle build tools version to '3.3.0'.
  • downgraded internal Gradle version to 4.10.1.

v1.1.7

27 Feb 04:41
a7799b0
Compare
Choose a tag to compare
  • implements addOnChangedListener method spec
  • base64 class from android open source util for using apache commons codes on android

v1.1.6

22 Feb 07:28
810e565
Compare
Choose a tag to compare

Encrypting an entity using @EncryptEntity annotation.

v1.1.5

04 Feb 18:01
Compare
Choose a tag to compare
publish v1.1.5

v1.1.4

15 Jan 15:11
Compare
Choose a tag to compare

Implemented OnChangedListener by auto-generation.

Migrate to AndroidX

20 Nov 14:26
2849bb0
Compare
Choose a tag to compare

Migrate to AndroidX