diff options
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 | 27 |
1 files changed, 17 insertions, 10 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..1262c078 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/iitems/GenericIItems.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/iitems/GenericIItems.kt @@ -27,8 +27,11 @@ import com.mikepenz.fastadapter.GenericItem import com.mikepenz.fastadapter.IAdapter import com.mikepenz.fastadapter.select.selectExtension import com.pitchedapps.frost.R +import com.pitchedapps.frost.facebook.FbCookie 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. @@ -41,20 +44,20 @@ interface ClickableIItemContract { val url: String? - fun click(context: Context) { + fun click(context: Context, fbCookie: FbCookie) { val url = url ?: return - context.launchWebOverlay(url) + context.launchWebOverlay(url, fbCookie) } companion object { - fun bindEvents(adapter: IAdapter<GenericItem>) { + fun bindEvents(adapter: IAdapter<GenericItem>, fbCookie: FbCookie) { adapter.fastAdapter?.apply { selectExtension { isSelectable = false } onClickListener = { v, _, item, _ -> if (item is ClickableIItemContract) { - item.click(v!!.context) + item.click(v!!.context, fbCookie) true } else false @@ -73,14 +76,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 +105,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) { |