From 1840d89ca5ff4855d43b03a9a1c802f8c1ebd3c7 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sun, 23 Feb 2020 16:05:48 -0800 Subject: Move pref module to pref class --- .../kotlin/ca/allanwang/kau/sample/SampleTestApp.kt | 7 ++++++- .../src/main/kotlin/ca/allanwang/kau/sample/KPrefSample.kt | 7 +++++++ sample/src/main/kotlin/ca/allanwang/kau/sample/SampleApp.kt | 13 ++++++------- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/sample/src/androidTest/kotlin/ca/allanwang/kau/sample/SampleTestApp.kt b/sample/src/androidTest/kotlin/ca/allanwang/kau/sample/SampleTestApp.kt index ceb551b..2bf5ca3 100644 --- a/sample/src/androidTest/kotlin/ca/allanwang/kau/sample/SampleTestApp.kt +++ b/sample/src/androidTest/kotlin/ca/allanwang/kau/sample/SampleTestApp.kt @@ -62,7 +62,12 @@ class SampleTestApp : Application() { androidLogger() } androidContext(this@SampleTestApp) - modules(listOf(prefFactoryModule(), SampleApp.prefModule())) + modules( + listOf( + prefFactoryModule(), + KPrefSample.module() + ) + ) } } diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/KPrefSample.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/KPrefSample.kt index 97e8075..4ac9928 100644 --- a/sample/src/main/kotlin/ca/allanwang/kau/sample/KPrefSample.kt +++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/KPrefSample.kt @@ -18,6 +18,7 @@ package ca.allanwang.kau.sample import android.graphics.Color import ca.allanwang.kau.kpref.KPref import ca.allanwang.kau.kpref.KPrefFactory +import org.koin.dsl.module /** * Created by Allan Wang on 2017-06-07. @@ -34,4 +35,10 @@ class KPrefSample(factory: KPrefFactory) : KPref("pref_sample", factory = factor var seekbar: Int by kpref("seekbar", 20) var time12: Int by kpref("time_12", 315) var time24: Int by kpref("time_24", 2220) + + companion object { + fun module() = module { + single { KPrefSample(get()) } + } + } } diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/SampleApp.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/SampleApp.kt index 2537090..597894a 100644 --- a/sample/src/main/kotlin/ca/allanwang/kau/sample/SampleApp.kt +++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/SampleApp.kt @@ -36,7 +36,12 @@ class SampleApp : Application() { androidLogger() } androidContext(this@SampleApp) - modules(listOf(prefFactoryModule(), prefModule())) + modules( + listOf( + prefFactoryModule(), + KPrefSample.module() + ) + ) } } @@ -46,11 +51,5 @@ class SampleApp : Application() { KPrefFactoryAndroid(get()) } } - - fun prefModule(): Module = module { - single { - KPrefSample(get()) - } - } } } -- cgit v1.2.3