diff options
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/iitems')
3 files changed, 53 insertions, 36 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 0c53a2b1..27263789 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/iitems/GenericIItems.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/iitems/GenericIItems.kt @@ -31,8 +31,6 @@ import com.pitchedapps.frost.facebook.FbCookie import com.pitchedapps.frost.injectors.ThemeProvider import com.pitchedapps.frost.prefs.Prefs import com.pitchedapps.frost.utils.launchWebOverlay -import org.koin.core.component.KoinComponent -import org.koin.core.component.inject /** * Created by Allan Wang on 30/12/17. @@ -74,13 +72,18 @@ interface ClickableIItemContract { */ open class HeaderIItem( val text: String?, - itemId: Int = R.layout.iitem_header -) : KauIItem<HeaderIItem.ViewHolder>(R.layout.iitem_header, ::ViewHolder, itemId) { - - class ViewHolder(itemView: View) : FastAdapter.ViewHolder<HeaderIItem>(itemView), - KoinComponent { - - private val themeProvider: ThemeProvider by inject() + itemId: Int = R.layout.iitem_header, + private val themeProvider: ThemeProvider +) : KauIItem<HeaderIItem.ViewHolder>( + R.layout.iitem_header, + { ViewHolder(it, themeProvider) }, + itemId +) { + + class ViewHolder( + itemView: View, + private val themeProvider: ThemeProvider + ) : FastAdapter.ViewHolder<HeaderIItem>(itemView) { val text: TextView by bindView(R.id.item_header_text) @@ -103,20 +106,23 @@ open class HeaderIItem( open class TextIItem( val text: String?, override val url: String?, - itemId: Int = R.layout.iitem_text -) : KauIItem<TextIItem.ViewHolder>(R.layout.iitem_text, ::ViewHolder, itemId), + itemId: Int = R.layout.iitem_text, + private val themeProvider: ThemeProvider +) : KauIItem<TextIItem.ViewHolder>(R.layout.iitem_text, { ViewHolder(it, themeProvider) }, itemId), ClickableIItemContract { - class ViewHolder(itemView: View) : FastAdapter.ViewHolder<TextIItem>(itemView), KoinComponent { - - private val themeProvider: ThemeProvider by inject() + class ViewHolder( + itemView: View, + private val themeProvider: ThemeProvider + ) : FastAdapter.ViewHolder<TextIItem>(itemView) { val text: TextView by bindView(R.id.item_text_view) override fun bindView(item: TextIItem, payloads: List<Any>) { text.setTextColor(themeProvider.textColor) text.text = item.text - text.background = createSimpleRippleDrawable(themeProvider.bgColor, themeProvider.nativeBgColor) + text.background = + createSimpleRippleDrawable(themeProvider.bgColor, themeProvider.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 8e0d5bec..f0fb1a28 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/iitems/NotificationIItem.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/iitems/NotificationIItem.kt @@ -40,19 +40,25 @@ import com.pitchedapps.frost.injectors.ThemeProvider import com.pitchedapps.frost.prefs.Prefs import com.pitchedapps.frost.utils.isIndependent import com.pitchedapps.frost.utils.launchWebOverlay -import org.koin.core.component.KoinComponent -import org.koin.core.component.inject /** * Created by Allan Wang on 27/12/17. */ -class NotificationIItem(val notification: FrostNotif, val cookie: String) : - KauIItem<NotificationIItem.ViewHolder>( - R.layout.iitem_notification, ::ViewHolder - ) { +class NotificationIItem( + val notification: FrostNotif, + val cookie: String, + private val themeProvider: ThemeProvider +) : KauIItem<NotificationIItem.ViewHolder>( + R.layout.iitem_notification, { ViewHolder(it, themeProvider) } +) { companion object { - fun bindEvents(adapter: ItemAdapter<NotificationIItem>, fbCookie: FbCookie, prefs: Prefs) { + fun bindEvents( + adapter: ItemAdapter<NotificationIItem>, + fbCookie: FbCookie, + prefs: Prefs, + themeProvider: ThemeProvider + ) { adapter.fastAdapter?.apply { selectExtension { isSelectable = false @@ -62,7 +68,11 @@ class NotificationIItem(val notification: FrostNotif, val cookie: String) : if (notif.unread) { adapter.set( position, - NotificationIItem(notif.copy(unread = false), item.cookie) + NotificationIItem( + notif.copy(unread = false), + item.cookie, + themeProvider + ) ) } // TODO temp fix. If url is dependent, we cannot load it directly @@ -101,10 +111,10 @@ class NotificationIItem(val notification: FrostNotif, val cookie: String) : } } - class ViewHolder(itemView: View) : FastAdapter.ViewHolder<NotificationIItem>(itemView), - KoinComponent { - - private val themeProvider: ThemeProvider by inject() + class ViewHolder( + itemView: View, + private val themeProvider: ThemeProvider + ) : FastAdapter.ViewHolder<NotificationIItem>(itemView) { private val frame: ViewGroup by bindView(R.id.item_frame) private val avatar: ImageView by bindView(R.id.item_avatar) 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 0fd39d5c..f9f9064b 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/iitems/TabIItem.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/iitems/TabIItem.kt @@ -30,22 +30,23 @@ import com.mikepenz.fastadapter.drag.IDraggable import com.pitchedapps.frost.R import com.pitchedapps.frost.facebook.FbItem import com.pitchedapps.frost.injectors.ThemeProvider -import org.koin.core.component.KoinComponent -import org.koin.core.component.inject /** * Created by Allan Wang on 26/11/17. */ -class TabIItem(val item: FbItem) : KauIItem<TabIItem.ViewHolder>( - R.layout.iitem_tab_preview, - { ViewHolder(it) } -), IDraggable { +class TabIItem(val item: FbItem, private val themeProvider: ThemeProvider) : + KauIItem<TabIItem.ViewHolder>( + R.layout.iitem_tab_preview, + { ViewHolder(it, themeProvider) } + ), + IDraggable { override val isDraggable: Boolean = true - class ViewHolder(itemView: View) : FastAdapter.ViewHolder<TabIItem>(itemView), KoinComponent { - - private val themeProvider: ThemeProvider by inject() + class ViewHolder( + itemView: View, + private val themeProvider: ThemeProvider + ) : FastAdapter.ViewHolder<TabIItem>(itemView) { val image: ImageView by bindView(R.id.image) val text: TextView by bindView(R.id.text) |