diff options
author | Allan Wang <me@allanwang.ca> | 2020-02-23 16:06:45 -0800 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2020-02-23 16:06:45 -0800 |
commit | c8b54fd10a08ed53eb7d21578a4fe990fe14e3bc (patch) | |
tree | 0841d112c8c00504ce10ca72ef39e403b69c595c /app/src/main/kotlin/com/pitchedapps/frost/iitems/GenericIItems.kt | |
parent | 4d5aaf541dbfa7d521ebbc5f011a642c83c4b9c5 (diff) | |
download | frost-c8b54fd10a08ed53eb7d21578a4fe990fe14e3bc.tar.gz frost-c8b54fd10a08ed53eb7d21578a4fe990fe14e3bc.tar.bz2 frost-c8b54fd10a08ed53eb7d21578a4fe990fe14e3bc.zip |
Move prefs to service locator
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/iitems/GenericIItems.kt')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/iitems/GenericIItems.kt | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/iitems/GenericIItems.kt b/app/src/main/kotlin/com/pitchedapps/frost/iitems/GenericIItems.kt index ca8bf352..5b06443e 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/iitems/GenericIItems.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/iitems/GenericIItems.kt @@ -29,6 +29,8 @@ import com.mikepenz.fastadapter.select.selectExtension import com.pitchedapps.frost.R import com.pitchedapps.frost.utils.Prefs import com.pitchedapps.frost.utils.launchWebOverlay +import org.koin.core.KoinComponent +import org.koin.core.inject /** * Created by Allan Wang on 30/12/17. @@ -73,14 +75,16 @@ open class HeaderIItem( itemId: Int = R.layout.iitem_header ) : KauIItem<HeaderIItem.ViewHolder>(R.layout.iitem_header, ::ViewHolder, itemId) { - class ViewHolder(itemView: View) : FastAdapter.ViewHolder<HeaderIItem>(itemView) { + class ViewHolder(itemView: View) : FastAdapter.ViewHolder<HeaderIItem>(itemView), KoinComponent { + + private val prefs: Prefs by inject() val text: TextView by bindView(R.id.item_header_text) override fun bindView(item: HeaderIItem, payloads: MutableList<Any>) { - text.setTextColor(Prefs.accentColor) + text.setTextColor(prefs.accentColor) text.text = item.text - text.setBackgroundColor(Prefs.nativeBgColor) + text.setBackgroundColor(prefs.nativeBgColor) } override fun unbindView(item: HeaderIItem) { @@ -100,14 +104,16 @@ open class TextIItem( ) : KauIItem<TextIItem.ViewHolder>(R.layout.iitem_text, ::ViewHolder, itemId), ClickableIItemContract { - class ViewHolder(itemView: View) : FastAdapter.ViewHolder<TextIItem>(itemView) { + class ViewHolder(itemView: View) : FastAdapter.ViewHolder<TextIItem>(itemView),KoinComponent { + + private val prefs: Prefs by inject() val text: TextView by bindView(R.id.item_text_view) override fun bindView(item: TextIItem, payloads: MutableList<Any>) { - text.setTextColor(Prefs.textColor) + text.setTextColor(prefs.textColor) text.text = item.text - text.background = createSimpleRippleDrawable(Prefs.bgColor, Prefs.nativeBgColor) + text.background = createSimpleRippleDrawable(prefs.bgColor, prefs.nativeBgColor) } override fun unbindView(item: TextIItem) { |