diff options
author | Allan Wang <me@allanwang.ca> | 2021-04-17 17:55:45 -0700 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2021-04-17 17:55:45 -0700 |
commit | 2c20f85be14abfd45017b2b0f3a0f5d7c7886b90 (patch) | |
tree | c7278b37ad4fae7009dc1c167db97db98432866d /app/src/main/kotlin/com/pitchedapps | |
parent | d96d1d06a7c1581b97c042f2a74e7cd5b1c2546e (diff) | |
download | frost-2c20f85be14abfd45017b2b0f3a0f5d7c7886b90.tar.gz frost-2c20f85be14abfd45017b2b0f3a0f5d7c7886b90.tar.bz2 frost-2c20f85be14abfd45017b2b0f3a0f5d7c7886b90.zip |
Injection checkpoint
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps')
5 files changed, 48 insertions, 22 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/SettingsActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/SettingsActivity.kt index a845e748..6bdbb68d 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/SettingsActivity.kt @@ -58,19 +58,28 @@ import com.pitchedapps.frost.utils.frostNavigationBar import com.pitchedapps.frost.utils.launchNewTask import com.pitchedapps.frost.utils.loadAssets import com.pitchedapps.frost.utils.setFrostTheme +import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.NonCancellable import kotlinx.coroutines.launch -import org.koin.android.ext.android.inject +import javax.inject.Inject /** * Created by Allan Wang on 2017-06-06. */ +@AndroidEntryPoint class SettingsActivity : KPrefActivity() { - val fbCookie: FbCookie by inject() - val notifDao: NotificationDao by inject() - val prefs: Prefs by inject() - val themeProvider: ThemeProvider by inject() + @Inject + lateinit var fbCookie: FbCookie + + @Inject + lateinit var prefs: Prefs + + @Inject + lateinit var themeProvider: ThemeProvider + + @Inject + lateinit var notifDao: NotificationDao private var resultFlag = Activity.RESULT_CANCELED @@ -230,7 +239,11 @@ class SettingsActivity : KPrefActivity() { fun themeExterior(animate: Boolean = true) { if (animate) bgCanvas.fade(themeProvider.bgColor) else bgCanvas.set(themeProvider.bgColor) - if (animate) toolbarCanvas.ripple(themeProvider.headerColor, RippleCanvas.MIDDLE, RippleCanvas.END) + if (animate) toolbarCanvas.ripple( + themeProvider.headerColor, + RippleCanvas.MIDDLE, + RippleCanvas.END + ) else toolbarCanvas.set(themeProvider.headerColor) frostNavigationBar(prefs, themeProvider) } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/glide/GlideUtils.kt b/app/src/main/kotlin/com/pitchedapps/frost/glide/GlideUtils.kt index 7d9694fe..6962cf52 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/glide/GlideUtils.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/glide/GlideUtils.kt @@ -28,10 +28,9 @@ import com.bumptech.glide.module.AppGlideModule import com.bumptech.glide.request.RequestOptions import com.pitchedapps.frost.facebook.FbCookie import okhttp3.Interceptor -import okhttp3.OkHttpClient import okhttp3.Response import org.koin.core.component.KoinComponent -import org.koin.core.component.inject +import javax.inject.Inject /** * Created by Allan Wang on 28/12/17. @@ -62,12 +61,12 @@ class FrostGlideModule : AppGlideModule() { } } -private fun getFrostHttpClient(): OkHttpClient = - OkHttpClient.Builder().addInterceptor(FrostCookieInterceptor()).build() +// private fun getFrostHttpClient(): OkHttpClient = +// OkHttpClient.Builder().addInterceptor(FrostCookieInterceptor()).build() -class FrostCookieInterceptor : Interceptor, KoinComponent { - - private val fbCookie: FbCookie by inject() +class FrostCookieInterceptor @Inject internal constructor( + private val fbCookie: FbCookie +) : Interceptor, KoinComponent { override fun intercept(chain: Interceptor.Chain): Response { val origRequest = chain.request() diff --git a/app/src/main/kotlin/com/pitchedapps/frost/intro/IntroMainFragments.kt b/app/src/main/kotlin/com/pitchedapps/frost/intro/IntroMainFragments.kt index 8a9016f6..7ff1df1d 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/intro/IntroMainFragments.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/intro/IntroMainFragments.kt @@ -35,8 +35,8 @@ import com.pitchedapps.frost.R import com.pitchedapps.frost.activities.IntroActivity import com.pitchedapps.frost.injectors.ThemeProvider import com.pitchedapps.frost.prefs.Prefs -import org.koin.android.ext.android.inject -import org.koin.core.component.inject +import dagger.hilt.android.AndroidEntryPoint +import javax.inject.Inject import kotlin.math.abs /** @@ -48,10 +48,14 @@ import kotlin.math.abs /** * The core intro fragment for all other fragments */ +@AndroidEntryPoint abstract class BaseIntroFragment(val layoutRes: Int) : Fragment() { - protected val prefs: Prefs by inject() - protected val themeProvider: ThemeProvider by inject() + @Inject + lateinit var prefs: Prefs + + @Inject + lateinit var themeProvider: ThemeProvider val screenWidth get() = resources.displayMetrics.widthPixels diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostViewPager.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostViewPager.kt index e3a23e12..0ef3223d 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostViewPager.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostViewPager.kt @@ -22,18 +22,22 @@ import android.util.AttributeSet import android.view.MotionEvent import androidx.viewpager.widget.ViewPager import com.pitchedapps.frost.prefs.Prefs +import dagger.hilt.android.AndroidEntryPoint import org.koin.core.component.KoinComponent -import org.koin.core.component.inject +import javax.inject.Inject /** * Created by Allan Wang on 2017-07-07. * * Basic override to allow us to control swiping */ +@AndroidEntryPoint class FrostViewPager @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : ViewPager(context, attrs), KoinComponent { - private val prefs: Prefs by inject() + @Inject + lateinit var prefs: Prefs + var enableSwipe = true override fun onInterceptTouchEvent(ev: MotionEvent?) = diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt index cf4f7456..dc375a8d 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt @@ -34,25 +34,31 @@ import com.pitchedapps.frost.prefs.Prefs import com.pitchedapps.frost.utils.L import com.pitchedapps.frost.utils.createFreshFile import com.pitchedapps.frost.utils.isFacebookUrl +import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext import org.koin.core.component.KoinComponent -import org.koin.core.component.inject import java.io.File +import javax.inject.Inject /** * Created by Allan Wang on 2018-01-05. * * A barebone webview with a refresh listener */ +@AndroidEntryPoint class DebugWebView @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 ) : WebView(context, attrs, defStyleAttr), KoinComponent { - private val prefs: Prefs by inject() - private val themeProvider: ThemeProvider by inject() + @Inject + lateinit var prefs: Prefs + + @Inject + lateinit var themeProvider: ThemeProvider + var onPageFinished: (String?) -> Unit = {} init { |