diff --git a/examples/counter/build.gradle b/examples/counter/build.gradle index 8acec0a..4d5369a 100644 --- a/examples/counter/build.gradle +++ b/examples/counter/build.gradle @@ -33,18 +33,14 @@ buildscript { } dependencies { - kapt 'com.squareup.dagger:dagger-compiler:1.2.2' - compile project(':bansa') compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" compile 'co.trikita:anvil-sdk15:0.2.0' - compile 'com.squareup.dagger:dagger:1.2.2' compile 'io.reactivex:rxjava:1.0.16' + compile "uy.kohesive.injekt:injekt-core:1.12.+" compile 'io.reactivex:rxandroid:1.0.1' compile 'com.android.support:design:23.1.1' - compile 'com.jakewharton.rxbinding:rxbinding:0.3.0' - compile 'com.jakewharton.rxbinding:rxbinding-support-v4:0.3.0' testCompile 'junit:junit:4.12' testCompile 'org.assertj:assertj-core:1.7.1' diff --git a/examples/counter/src/main/java/com/brianegan/bansa/counter/ApplicationModule.java b/examples/counter/src/main/java/com/brianegan/bansa/counter/ApplicationModule.java deleted file mode 100644 index 908c36f..0000000 --- a/examples/counter/src/main/java/com/brianegan/bansa/counter/ApplicationModule.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.brianegan.bansa.counter; - -import dagger.Module; -import dagger.Provides; - -import android.content.Context; - -@Module( - includes = StoreModule.class, - injects = { - RootActivity.class - }, - library = true -) -public class ApplicationModule { - private final Context application; - - public ApplicationModule(Context application) { - this.application = application; - } - - @Provides - Context provideApplicationContext() { - return application; - } -} diff --git a/examples/counter/src/main/java/com/brianegan/bansa/counter/StoreModule.java b/examples/counter/src/main/java/com/brianegan/bansa/counter/StoreModule.java deleted file mode 100644 index 18102ff..0000000 --- a/examples/counter/src/main/java/com/brianegan/bansa/counter/StoreModule.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.brianegan.bansa.counter; - -import com.brianegan.bansa.Action; -import com.brianegan.bansa.CreateStoreKt; -import com.brianegan.bansa.Store; -import dagger.Module; -import dagger.Provides; -import rx.schedulers.Schedulers; - -import javax.inject.Singleton; - -@Module(library = true) -public class StoreModule { - public StoreModule() { - } - - @Provides - @Singleton - public Store provideStore() { - return CreateStoreKt.createStore( - new ApplicationState(), - ApplicationReducerKt.getApplicationReducer(), - Schedulers.newThread() - ); - } -} diff --git a/examples/counter/src/main/kotlin/com/brianegan/bansa/counter/Application.kt b/examples/counter/src/main/kotlin/com/brianegan/bansa/counter/Application.kt index ae33d5d..6f46eba 100644 --- a/examples/counter/src/main/kotlin/com/brianegan/bansa/counter/Application.kt +++ b/examples/counter/src/main/kotlin/com/brianegan/bansa/counter/Application.kt @@ -1,23 +1,27 @@ package com.brianegan.bansa.counter -import com.brianegan.bansa.counter.ApplicationModule -import com.brianegan.bansa.counter.StoreModule -import dagger.ObjectGraph +import com.brianegan.bansa.Action +import com.brianegan.bansa.Store +import com.brianegan.bansa.createStore +import uy.kohesive.injekt.Injekt +import uy.kohesive.injekt.InjektMain +import uy.kohesive.injekt.api.InjektRegistrar +import uy.kohesive.injekt.api.fullType +import uy.kohesive.injekt.api.get class Application : android.app.Application() { - var objectGraph: ObjectGraph? = null - - override fun onCreate() { - super.onCreate() - instance = this - objectGraph = ObjectGraph.create(ApplicationModule(this), StoreModule()) + companion object : InjektMain() { + override fun InjektRegistrar.registerInjectables() { + addSingleton( + fullType>(), + createStore(ApplicationState(), applicationReducer)); + } } - companion object { - private var instance: Application? = null + val store = Injekt.get(fullType>()) - fun getObjectGraph(): ObjectGraph? { - return instance?.objectGraph - } + override fun onCreate() { + super.onCreate() + store.dispatch(CounterActions.INIT) // Initialize the store } } diff --git a/examples/counter/src/main/kotlin/com/brianegan/bansa/counter/RootActivity.kt b/examples/counter/src/main/kotlin/com/brianegan/bansa/counter/RootActivity.kt index 9c83bbf..2826a7e 100644 --- a/examples/counter/src/main/kotlin/com/brianegan/bansa/counter/RootActivity.kt +++ b/examples/counter/src/main/kotlin/com/brianegan/bansa/counter/RootActivity.kt @@ -4,15 +4,15 @@ import android.os.Bundle import android.support.v7.app.AppCompatActivity import com.brianegan.bansa.Action import com.brianegan.bansa.Store -import javax.inject.Inject +import uy.kohesive.injekt.Injekt +import uy.kohesive.injekt.api.fullType +import uy.kohesive.injekt.api.get -public open class RootActivity : AppCompatActivity() { - @Inject lateinit var store: Store +open class RootActivity : AppCompatActivity() { + val store: Store = Injekt.get(fullType>()) override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - Application.getObjectGraph()?.inject(this) - store.dispatch(CounterActions.INIT) // Initialize the store - setContentView(RootView(this, store)) // Set the root view + setContentView(RootView(this, store)) } } diff --git a/examples/counter/src/main/kotlin/com/brianegan/bansa/counter/RootView.kt b/examples/counter/src/main/kotlin/com/brianegan/bansa/counter/RootView.kt index 9dd8092..779c396 100644 --- a/examples/counter/src/main/kotlin/com/brianegan/bansa/counter/RootView.kt +++ b/examples/counter/src/main/kotlin/com/brianegan/bansa/counter/RootView.kt @@ -13,7 +13,7 @@ import trikita.anvil.Anvil import trikita.anvil.DSL.* import trikita.anvil.RenderableView -public class RootView(c: Context, val store: Store) : RenderableView(c) { +class RootView(c: Context, val store: Store) : RenderableView(c) { override fun view() { template(buildPresentationModel()) } diff --git a/examples/counter/src/main/kotlin/com/brianegan/bansa/counter/createComponent.kt b/examples/counter/src/main/kotlin/com/brianegan/bansa/counter/createComponent.kt index 086b600..71c5a8a 100644 --- a/examples/counter/src/main/kotlin/com/brianegan/bansa/counter/createComponent.kt +++ b/examples/counter/src/main/kotlin/com/brianegan/bansa/counter/createComponent.kt @@ -12,6 +12,4 @@ fun connect( view(mapStoreToViewModel(store)) } } - - } diff --git a/examples/listOfTrendingGifs/build.gradle b/examples/listOfTrendingGifs/build.gradle index ef0ad6a..a6e1001 100644 --- a/examples/listOfTrendingGifs/build.gradle +++ b/examples/listOfTrendingGifs/build.gradle @@ -46,14 +46,13 @@ dependencies { compile 'io.reactivex:rxjava:1.0.16' compile 'io.reactivex:rxandroid:1.0.1' compile 'com.android.support:design:23.1.1' - compile 'com.github.bumptech.glide:glide:3.6.1' compile 'com.android.support:support-v4:23.0.2' + compile 'com.squareup.picasso:picasso:2.5.2' compile 'com.squareup.okhttp3:okhttp:3.0.1' compile 'com.squareup.moshi:moshi:1.1.0' testCompile "org.jetbrains.spek:spek:0.1.194" testCompile 'org.assertj:assertj-core:1.7.1' - compile 'com.squareup.picasso:picasso:2.5.2' }