aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/iitems
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2020-02-23 16:06:45 -0800
committerAllan Wang <me@allanwang.ca>2020-02-23 16:06:45 -0800
commitc8b54fd10a08ed53eb7d21578a4fe990fe14e3bc (patch)
tree0841d112c8c00504ce10ca72ef39e403b69c595c /app/src/main/kotlin/com/pitchedapps/frost/iitems
parent4d5aaf541dbfa7d521ebbc5f011a642c83c4b9c5 (diff)
downloadfrost-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')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/iitems/GenericIItems.kt18
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/iitems/NotificationIItem.kt14
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/iitems/TabIItem.kt8
3 files changed, 27 insertions, 13 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) {
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/iitems/NotificationIItem.kt b/app/src/main/kotlin/com/pitchedapps/frost/iitems/NotificationIItem.kt
index b2d328ec..828d2484 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/iitems/NotificationIItem.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/iitems/NotificationIItem.kt
@@ -38,6 +38,8 @@ import com.pitchedapps.frost.glide.GlideApp
import com.pitchedapps.frost.utils.Prefs
import com.pitchedapps.frost.utils.isIndependent
import com.pitchedapps.frost.utils.launchWebOverlay
+import org.koin.core.KoinComponent
+import org.koin.core.inject
/**
* Created by Allan Wang on 27/12/17.
@@ -93,7 +95,9 @@ class NotificationIItem(val notification: FrostNotif, val cookie: String) :
}
}
- class ViewHolder(itemView: View) : FastAdapter.ViewHolder<NotificationIItem>(itemView) {
+ class ViewHolder(itemView: View) : FastAdapter.ViewHolder<NotificationIItem>(itemView), KoinComponent {
+
+ private val prefs: Prefs by inject()
private val frame: ViewGroup by bindView(R.id.item_frame)
private val avatar: ImageView by bindView(R.id.item_avatar)
@@ -107,11 +111,11 @@ class NotificationIItem(val notification: FrostNotif, val cookie: String) :
override fun bindView(item: NotificationIItem, payloads: MutableList<Any>) {
val notif = item.notification
frame.background = createSimpleRippleDrawable(
- Prefs.textColor,
- Prefs.nativeBgColor(notif.unread)
+ prefs.textColor,
+ prefs.nativeBgColor(notif.unread)
)
- content.setTextColor(Prefs.textColor)
- date.setTextColor(Prefs.textColor.withAlpha(150))
+ content.setTextColor(prefs.textColor)
+ date.setTextColor(prefs.textColor.withAlpha(150))
val glide = glide
glide.load(notif.img)
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/iitems/TabIItem.kt b/app/src/main/kotlin/com/pitchedapps/frost/iitems/TabIItem.kt
index 186e6288..c1998c04 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/iitems/TabIItem.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/iitems/TabIItem.kt
@@ -30,6 +30,8 @@ import com.mikepenz.fastadapter.drag.IDraggable
import com.pitchedapps.frost.R
import com.pitchedapps.frost.facebook.FbItem
import com.pitchedapps.frost.utils.Prefs
+import org.koin.core.KoinComponent
+import org.koin.core.inject
/**
* Created by Allan Wang on 26/11/17.
@@ -41,14 +43,16 @@ class TabIItem(val item: FbItem) : KauIItem<TabIItem.ViewHolder>(
override val isDraggable: Boolean = true
- class ViewHolder(itemView: View) : FastAdapter.ViewHolder<TabIItem>(itemView) {
+ class ViewHolder(itemView: View) : FastAdapter.ViewHolder<TabIItem>(itemView), KoinComponent {
+
+ private val prefs: Prefs by inject()
val image: ImageView by bindView(R.id.image)
val text: TextView by bindView(R.id.text)
override fun bindView(item: TabIItem, payloads: MutableList<Any>) {
val isInToolbar = adapterPosition < 4
- val color = if (isInToolbar) Prefs.iconColor else Prefs.textColor
+ val color = if (isInToolbar) prefs.iconColor else prefs.textColor
image.setIcon(item.item.icon, 20, color)
if (isInToolbar)
text.invisible()