Restart inject module when the app is created

This commit is contained in:
len 2016-06-15 17:58:28 +02:00
parent a82e1d0e45
commit cd92569355
3 changed files with 4 additions and 14 deletions

View file

@ -5,6 +5,8 @@ import org.acra.ACRA
import org.acra.annotation.ReportsCrashes
import timber.log.Timber
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.InjektScope
import uy.kohesive.injekt.registry.default.DefaultRegistrar
@ReportsCrashes(
formUri = "http://tachiyomi.kanade.eu/crash_report",
@ -17,7 +19,9 @@ open class App : Application() {
override fun onCreate() {
super.onCreate()
Injekt = InjektScope(DefaultRegistrar())
Injekt.importModule(AppModule(this))
if (BuildConfig.DEBUG) Timber.plant(Timber.DebugTree())
setupAcra()

View file

@ -5,8 +5,6 @@ import android.content.Context
import android.content.Intent
import android.os.Build
import android.os.SystemClock
import eu.kanade.tachiyomi.App
import eu.kanade.tachiyomi.AppModule
import eu.kanade.tachiyomi.BuildConfig
import eu.kanade.tachiyomi.CustomRobolectricGradleTestRunner
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
@ -19,9 +17,6 @@ import org.robolectric.Shadows.shadowOf
import org.robolectric.annotation.Config
import org.robolectric.shadows.ShadowAlarmManager
import org.robolectric.shadows.ShadowApplication
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.InjektScope
import uy.kohesive.injekt.registry.default.DefaultRegistrar
@Config(constants = BuildConfig::class, sdk = intArrayOf(Build.VERSION_CODES.LOLLIPOP))
@RunWith(CustomRobolectricGradleTestRunner::class)
@ -35,8 +30,6 @@ class LibraryUpdateAlarmTest {
fun setup() {
app = ShadowApplication.getInstance()
context = spy(app.applicationContext)
Injekt = InjektScope(DefaultRegistrar())
Injekt.importModule(AppModule(context as App))
alarmManager = shadowOf(context.getSystemService(Context.ALARM_SERVICE) as AlarmManager)
}

View file

@ -2,7 +2,6 @@ package eu.kanade.tachiyomi.data.library
import android.app.Application
import android.content.Context
import eu.kanade.tachiyomi.AppModule
import eu.kanade.tachiyomi.BuildConfig
import eu.kanade.tachiyomi.CustomRobolectricGradleTestRunner
import eu.kanade.tachiyomi.data.database.models.Chapter
@ -23,9 +22,7 @@ import rx.Observable
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.InjektModule
import uy.kohesive.injekt.api.InjektRegistrar
import uy.kohesive.injekt.api.InjektScope
import uy.kohesive.injekt.api.addSingleton
import uy.kohesive.injekt.registry.default.DefaultRegistrar
import java.util.*
@Config(constants = BuildConfig::class)
@ -48,10 +45,6 @@ class LibraryUpdateServiceTest {
addSingleton(Mockito.mock(SourceManager::class.java, RETURNS_DEEP_STUBS))
}
}
// Restart injections for each test
Injekt = InjektScope(DefaultRegistrar())
Injekt.importModule(AppModule(app))
Injekt.importModule(module)
service = Robolectric.setupService(LibraryUpdateService::class.java)