aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2021-04-17 19:03:47 -0700
committerAllan Wang <me@allanwang.ca>2021-04-17 19:03:47 -0700
commita56dbf0f61e80225f0d86af43ea0f1d6efa5e66a (patch)
tree38dc6437ba4b669991dc61c92c87e27939e9a608 /app/src/main/kotlin
parente1ae3536102a5bb83a3c73c3731eb4af56b96914 (diff)
downloadfrost-a56dbf0f61e80225f0d86af43ea0f1d6efa5e66a.tar.gz
frost-a56dbf0f61e80225f0d86af43ea0f1d6efa5e66a.tar.bz2
frost-a56dbf0f61e80225f0d86af43ea0f1d6efa5e66a.zip
Injection checkpoint
Diffstat (limited to 'app/src/main/kotlin')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt13
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/LoginActivity.kt8
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/SelectorActivity.kt4
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/fragments/RecyclerFragments.kt4
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/iitems/NotificationIItem.kt35
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/views/AccountItem.kt11
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt19
7 files changed, 58 insertions, 36 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt
index bcb43299..5d41be29 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt
@@ -67,13 +67,13 @@ import com.pitchedapps.frost.utils.frostSnackbar
import com.pitchedapps.frost.utils.frostUriFromFile
import com.pitchedapps.frost.utils.isIndirectImageUrl
import com.pitchedapps.frost.utils.logFrostEvent
+import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.CoroutineExceptionHandler
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
-import org.koin.android.ext.android.inject
import java.io.File
import java.io.FileNotFoundException
import java.io.IOException
@@ -84,13 +84,17 @@ import kotlin.math.max
/**
* Created by Allan Wang on 2017-07-15.
*/
+@AndroidEntryPoint
class ImageActivity : KauBaseActivity() {
@Inject
lateinit var activityThemer: ActivityThemer
- private val prefs: Prefs by inject()
- private val themeProvider: ThemeProvider by inject()
+ @Inject
+ lateinit var prefs: Prefs
+
+ @Inject
+ lateinit var themeProvider: ThemeProvider
@Volatile
internal var errorRef: Throwable? = null
@@ -412,7 +416,8 @@ internal enum class FabStates(
*
*/
fun update(fab: FloatingActionButton, themeProvider: ThemeProvider) {
- val tint = if (backgroundTint != Int.MAX_VALUE) backgroundTint else themeProvider.accentColor
+ val tint =
+ if (backgroundTint != Int.MAX_VALUE) backgroundTint else themeProvider.accentColor
val iconColor = iconColorProvider(themeProvider)
if (fab.isHidden) {
fab.setIcon(iicon, color = iconColor)
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/LoginActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/LoginActivity.kt
index 72d17eb7..949f1ddd 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/LoginActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/LoginActivity.kt
@@ -47,6 +47,7 @@ import com.pitchedapps.frost.utils.launchNewTask
import com.pitchedapps.frost.utils.logFrostEvent
import com.pitchedapps.frost.utils.uniqueOnly
import com.pitchedapps.frost.web.LoginWebView
+import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import kotlinx.coroutines.channels.Channel
@@ -55,21 +56,24 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.suspendCancellableCoroutine
import kotlinx.coroutines.withContext
import kotlinx.coroutines.withTimeout
-import org.koin.android.ext.android.inject
import java.net.UnknownHostException
+import javax.inject.Inject
import kotlin.coroutines.resume
/**
* Created by Allan Wang on 2017-06-01.
*/
+@AndroidEntryPoint
class LoginActivity : BaseActivity() {
+ @Inject
+ lateinit var cookieDao: CookieDao
+
private val toolbar: Toolbar by bindView(R.id.toolbar)
private val web: LoginWebView by bindView(R.id.login_webview)
private val swipeRefresh: SwipeRefreshLayout by bindView(R.id.swipe_refresh)
private val textview: AppCompatTextView by bindView(R.id.textview)
private val profile: ImageView by bindView(R.id.profile)
- private val cookieDao: CookieDao by inject()
private lateinit var profileLoader: RequestManager
private val refreshChannel = Channel<Boolean>(10)
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/SelectorActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/SelectorActivity.kt
index f2e00aae..a891c7c9 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/SelectorActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/SelectorActivity.kt
@@ -47,8 +47,8 @@ class SelectorActivity : BaseActivity() {
setContentView(R.layout.activity_selector)
recycler.layoutManager = GridLayoutManager(this, 2)
recycler.adapter = adapter
- adapter.add(cookies().map { AccountItem(it) })
- adapter.add(AccountItem(null)) // add account
+ adapter.add(cookies().map { AccountItem(it, themeProvider) })
+ adapter.add(AccountItem(null, themeProvider)) // add account
adapter.addEventHook(object : ClickEventHook<AccountItem>() {
override fun onBind(viewHolder: RecyclerView.ViewHolder): View? =
(viewHolder as? AccountItem.ViewHolder)?.itemView
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/fragments/RecyclerFragments.kt b/app/src/main/kotlin/com/pitchedapps/frost/fragments/RecyclerFragments.kt
index b282b36c..28962230 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/fragments/RecyclerFragments.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/fragments/RecyclerFragments.kt
@@ -37,9 +37,9 @@ class NotificationFragment : FrostParserFragment<FrostNotifs, NotificationIItem>
override fun getDoc(cookie: String?) = frostJsoup(cookie, "${FbItem.NOTIFICATIONS.url}?more")
override fun toItems(response: ParseResponse<FrostNotifs>): List<NotificationIItem> =
- response.data.notifs.map { NotificationIItem(it, response.cookie) }
+ response.data.notifs.map { NotificationIItem(it, response.cookie, themeProvider) }
override fun bindImpl(recyclerView: FrostRecyclerView) {
- NotificationIItem.bindEvents(adapter, fbCookie, prefs)
+ NotificationIItem.bindEvents(adapter, fbCookie, prefs, themeProvider)
}
}
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 f7f71fcb..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,11 +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/views/AccountItem.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/AccountItem.kt
index 6eebd36f..e15538b8 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/views/AccountItem.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/views/AccountItem.kt
@@ -38,17 +38,14 @@ import com.pitchedapps.frost.facebook.profilePictureUrl
import com.pitchedapps.frost.glide.FrostGlide
import com.pitchedapps.frost.glide.GlideApp
import com.pitchedapps.frost.injectors.ThemeProvider
-import org.koin.core.component.KoinComponent
-import org.koin.core.component.inject
/**
* Created by Allan Wang on 2017-06-05.
*/
-class AccountItem(val cookie: CookieEntity?) :
- KauIItem<AccountItem.ViewHolder>(R.layout.view_account, { ViewHolder(it) }, R.id.item_account),
- KoinComponent {
-
- private val themeProvider: ThemeProvider by inject()
+class AccountItem(
+ val cookie: CookieEntity?,
+ private val themeProvider: ThemeProvider
+) : KauIItem<AccountItem.ViewHolder>(R.layout.view_account, { ViewHolder(it) }, R.id.item_account) {
override fun bindView(holder: ViewHolder, payloads: List<Any>) {
super.bindView(holder, payloads)
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt
index fadbadf9..bcfcc109 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt
@@ -42,23 +42,30 @@ import com.pitchedapps.frost.injectors.jsInject
import com.pitchedapps.frost.prefs.Prefs
import com.pitchedapps.frost.utils.L
import com.pitchedapps.frost.utils.isFacebookUrl
+import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.coroutineScope
-import org.koin.core.component.KoinComponent
-import org.koin.core.component.inject
+import javax.inject.Inject
/**
* Created by Allan Wang on 2017-05-29.
*/
+@AndroidEntryPoint
class LoginWebView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
-) : WebView(context, attrs, defStyleAttr), KoinComponent {
+) : WebView(context, attrs, defStyleAttr) {
+
+ @Inject
+ lateinit var fbCookie: FbCookie
+
+ @Inject
+ lateinit var prefs: Prefs
+
+ @Inject
+ lateinit var themeProvider: ThemeProvider
- private val fbCookie: FbCookie by inject()
- private val prefs: Prefs by inject()
- private val themeProvider: ThemeProvider by inject()
private val completable: CompletableDeferred<CookieEntity> = CompletableDeferred()
private lateinit var progressCallback: (Int) -> Unit