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:36:31 -0800
committerAllan Wang <me@allanwang.ca>2020-02-23 16:36:31 -0800
commit0dfc1b3e6542b9deca6c56236b46e71e4c6976f5 (patch)
treed16e4c34b86b0cc236fce32baa38d71f3b7adfbf /app/src/main/kotlin/com/pitchedapps/frost/iitems
parentcd69ccf7c49f486a6c90a7cee0d32a74ea00247d (diff)
downloadfrost-0dfc1b3e6542b9deca6c56236b46e71e4c6976f5.tar.gz
frost-0dfc1b3e6542b9deca6c56236b46e71e4c6976f5.tar.bz2
frost-0dfc1b3e6542b9deca6c56236b46e71e4c6976f5.zip
Remove singleton pattern for fbcookie
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/iitems')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/iitems/GenericIItems.kt9
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/iitems/NotificationIItem.kt5
2 files changed, 8 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 8459fdf0..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,6 +27,7 @@ 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
@@ -43,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
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 828d2484..8624fff0 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/iitems/NotificationIItem.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/iitems/NotificationIItem.kt
@@ -31,6 +31,7 @@ import com.mikepenz.fastadapter.adapters.ItemAdapter
import com.mikepenz.fastadapter.diff.DiffCallback
import com.mikepenz.fastadapter.select.selectExtension
import com.pitchedapps.frost.R
+import com.pitchedapps.frost.facebook.FbCookie
import com.pitchedapps.frost.facebook.FbItem
import com.pitchedapps.frost.facebook.parsers.FrostNotif
import com.pitchedapps.frost.glide.FrostGlide
@@ -50,7 +51,7 @@ class NotificationIItem(val notification: FrostNotif, val cookie: String) :
) {
companion object {
- fun bindEvents(adapter: ItemAdapter<NotificationIItem>) {
+ fun bindEvents(adapter: ItemAdapter<NotificationIItem>, fbCookie: FbCookie) {
adapter.fastAdapter?.apply {
selectExtension {
isSelectable = false
@@ -64,7 +65,7 @@ class NotificationIItem(val notification: FrostNotif, val cookie: String) :
)
}
// TODO temp fix. If url is dependent, we cannot load it directly
- v!!.context.launchWebOverlay(if (notif.url.isIndependent) notif.url else FbItem.NOTIFICATIONS.url)
+ v!!.context.launchWebOverlay(if (notif.url.isIndependent) notif.url else FbItem.NOTIFICATIONS.url, fbCookie)
true
}
}