Commit faa2c7ce authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

remove assisted inject dependencies as unneccessary

reomve ConductorInjector as outdated
update injection presenter mechanism
parent 2bcdb6fa
...@@ -110,7 +110,9 @@ dependencies { ...@@ -110,7 +110,9 @@ dependencies {
//Rx Relay //Rx Relay
implementation "com.jakewharton.rxrelay2:rxrelay:$rxRelayVersion" implementation "com.jakewharton.rxrelay2:rxrelay:$rxRelayVersion"
//Assist Injected
compileOnly 'com.squareup.inject:assisted-inject-annotations-dagger2:0.5.0'
kapt 'com.squareup.inject:assisted-inject-processor-dagger2:0.5.0'
//Tests //Tests
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
......
...@@ -2,6 +2,7 @@ package com.biganto.visual.roompark.base ...@@ -2,6 +2,7 @@ package com.biganto.visual.roompark.base
import android.util.Log import android.util.Log
import com.biganto.visual.roompark.BuildConfig import com.biganto.visual.roompark.BuildConfig
import com.biganto.visual.roompark.di.dagger.AppComponent
import com.biganto.visual.roompark.di.dagger.DaggerAppComponent import com.biganto.visual.roompark.di.dagger.DaggerAppComponent
import com.crashlytics.android.Crashlytics import com.crashlytics.android.Crashlytics
import com.squareup.picasso.Picasso import com.squareup.picasso.Picasso
...@@ -14,10 +15,19 @@ import timber.log.Timber ...@@ -14,10 +15,19 @@ import timber.log.Timber
*/ */
class RoomParkApplication : DaggerApplication() { class RoomParkApplication : DaggerApplication() {
companion object {
lateinit var component: AppComponent
private set
}
override fun applicationInjector(): AndroidInjector<out DaggerApplication> { override fun applicationInjector(): AndroidInjector<out DaggerApplication> {
return DaggerAppComponent.builder() component = DaggerAppComponent.factory()
.context(this) .create(this) as AppComponent
.build() // .context(this)
// .build()
return component
} }
override fun onCreate() { override fun onCreate() {
......
...@@ -9,16 +9,17 @@ import butterknife.BindView ...@@ -9,16 +9,17 @@ import butterknife.BindView
import butterknife.ButterKnife import butterknife.ButterKnife
import com.biganto.visual.roompark.BuildConfig import com.biganto.visual.roompark.BuildConfig
import com.biganto.visual.roompark.R import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.presentation.screen.splash.SplashScreenController
import com.biganto.visual.roompark.view_utils.app_bar.DragControlAppBarLayoutBehaviour import com.biganto.visual.roompark.view_utils.app_bar.DragControlAppBarLayoutBehaviour
import com.biganto.visual.roompark.view_utils.snackbar.ISnackBarProvider
import com.bluelinelabs.conductor.Conductor import com.bluelinelabs.conductor.Conductor
import com.bluelinelabs.conductor.Router import com.bluelinelabs.conductor.Router
import com.bluelinelabs.conductor.RouterTransaction
import com.crashlytics.android.Crashlytics import com.crashlytics.android.Crashlytics
import com.google.android.material.appbar.AppBarLayout import com.google.android.material.appbar.AppBarLayout
import com.google.android.material.appbar.CollapsingToolbarLayout import com.google.android.material.appbar.CollapsingToolbarLayout
import com.google.android.material.bottomnavigation.BottomNavigationView import com.google.android.material.bottomnavigation.BottomNavigationView
import io.fabric.sdk.android.Fabric import io.fabric.sdk.android.Fabric
import javax.inject.Inject import kotlin.concurrent.thread
class RoomParkMainActivity( class RoomParkMainActivity(
) : BaseRoomParkActivity() ) : BaseRoomParkActivity()
...@@ -26,8 +27,10 @@ class RoomParkMainActivity( ...@@ -26,8 +27,10 @@ class RoomParkMainActivity(
,IConductorActivity ,IConductorActivity
,IBottomNavigation{ ,IBottomNavigation{
@Inject
lateinit var snackbarProvider: ISnackBarProvider
// @Inject
// lateinit var snackbarProvider: ISnackBarProvider
private lateinit var router: Router private lateinit var router: Router
...@@ -52,7 +55,16 @@ class RoomParkMainActivity( ...@@ -52,7 +55,16 @@ class RoomParkMainActivity(
router = Conductor.attachRouter(this, conductorContainer, savedInstanceState) router = Conductor.attachRouter(this, conductorContainer, savedInstanceState)
snackbarProvider.bindRootView(rootView = coordinatorLayout) thread(start=true ) {
Thread.sleep(1000L)
runOnUiThread{
router.setRoot(RouterTransaction.with(SplashScreenController()))
}
}
// snackbarProvider.bindRootView(rootView = coordinatorLayout)
} }
override fun displayBackButton(show: Boolean) { override fun displayBackButton(show: Boolean) {
......
...@@ -14,17 +14,14 @@ import com.biganto.visual.roompark.R ...@@ -14,17 +14,14 @@ import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.base.ICollapsingToolBar import com.biganto.visual.roompark.base.ICollapsingToolBar
import com.biganto.visual.roompark.base.RoomParkMainActivity import com.biganto.visual.roompark.base.RoomParkMainActivity
import com.biganto.visual.roompark.conductor.mosby.mvi.BigantoMviController import com.biganto.visual.roompark.conductor.mosby.mvi.BigantoMviController
import com.biganto.visual.roompark.di.dagger.PerScreen
import com.biganto.visual.roompark.view_utils.snackbar.ISnackBarProvider import com.biganto.visual.roompark.view_utils.snackbar.ISnackBarProvider
import com.hannesdorfmann.mosby3.mvi.MviBasePresenter import com.hannesdorfmann.mosby3.mvi.MviBasePresenter
import io.reactivex.disposables.CompositeDisposable import io.reactivex.disposables.CompositeDisposable
import javax.inject.Inject
/** /**
* Created by Vladislav Bogdashkin on 28.05.2018. * Created by Vladislav Bogdashkin on 28.05.2018.
*/ */
@PerScreen
abstract class BigantoBaseController<VS : BigantoBaseViewState,V: BigantoBaseContract<VS>,P : MviBasePresenter<V,VS>> abstract class BigantoBaseController<VS : BigantoBaseViewState,V: BigantoBaseContract<VS>,P : MviBasePresenter<V,VS>>
: BigantoMviController<V, P> { : BigantoMviController<V, P> {
...@@ -36,29 +33,43 @@ abstract class BigantoBaseController<VS : BigantoBaseViewState,V: BigantoBaseCon ...@@ -36,29 +33,43 @@ abstract class BigantoBaseController<VS : BigantoBaseViewState,V: BigantoBaseCon
abstract override fun createPresenter(): P abstract override fun createPresenter(): P
abstract fun getSnackBar(): ISnackBarProvider
@LayoutRes @LayoutRes
protected abstract fun getLayoutId(): Int protected abstract fun getLayoutId(): Int
@StringRes
protected abstract fun getToolbarTitleId(): Int
@Inject lateinit var toolBar: ICollapsingToolBar
private lateinit var roomParkActivity:RoomParkMainActivity lateinit var snackbar: ISnackBarProvider
protected val toolBar: ICollapsingToolBar = roomParkActivity
protected val snackbar: ISnackBarProvider = roomParkActivity.snackbarProvider
override fun onDetach(view: View) { override fun onDetach(view: View) {
detachDisposable.clear() detachDisposable.clear()
super.onDetach(view) super.onDetach(view)
} }
private var isInjected = false
override fun onRestoreViewState(view: View, savedViewState: Bundle) {
super.onRestoreViewState(view, savedViewState)
// try {
// ConductorInjection.inject(this)
// isInjected = true
// } catch (ignored: Throwable) {
// delay injection until onCreateView
// }
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup): View { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup): View {
// if (isInjected.not()) {
// ConductorInjection.inject(this)
// isInjected = true
// }
val view = inflater.inflate(getLayoutId(), container, false) val view = inflater.inflate(getLayoutId(), container, false)
// instantiate the view // instantiate the view
ButterKnife.bind(this, view) ButterKnife.bind(this, view)
toolBar= activity as RoomParkMainActivity
snackbar= getSnackBar()
return view return view
} }
......
...@@ -30,14 +30,13 @@ abstract class ActivityModule { ...@@ -30,14 +30,13 @@ abstract class ActivityModule {
@JvmStatic @JvmStatic
@Provides @Provides
fun provideSnackBar(activity: Activity): ISnackBarProvider{ fun provideSnackBar(activity: Activity): ISnackBarProvider {
return SnackBarProvider(activity) return SnackBarProvider(activity)
} }
} }
} }
@Module @Module
abstract class AppActivityModule { abstract class AppActivityModule {
......
package com.biganto.visual.roompark.di.dagger package com.biganto.visual.roompark.di.dagger
import android.app.Application
import com.biganto.visual.roompark.base.RoomParkApplication import com.biganto.visual.roompark.base.RoomParkApplication
import dagger.BindsInstance
import dagger.Component import dagger.Component
import dagger.android.AndroidInjectionModule import dagger.android.AndroidInjectionModule
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
...@@ -25,14 +23,15 @@ import javax.inject.Singleton ...@@ -25,14 +23,15 @@ import javax.inject.Singleton
AndroidSupportInjectionModule::class, AndroidSupportInjectionModule::class,
// MappingProvider::class, // MappingProvider::class,
ActivityModule::class, ActivityModule::class,
AppActivityModule ::class]) AppActivityModule ::class])
interface AppComponent : AndroidInjector<RoomParkApplication>{ interface AppComponent : AndroidInjector<RoomParkApplication>{
@Component.Builder @Component.Factory
interface Builder{ interface Factory:AndroidInjector.Factory<RoomParkApplication>{
@BindsInstance // @BindsInstance
fun context(application: Application): Builder // fun context(application: Application): Factory
// @BindsInstance // @BindsInstance
// fun retrofitModule(retrofit: RetrofitModule):Builder // fun retrofitModule(retrofit: RetrofitModule):Builder
...@@ -43,8 +42,9 @@ interface AppComponent : AndroidInjector<RoomParkApplication>{ ...@@ -43,8 +42,9 @@ interface AppComponent : AndroidInjector<RoomParkApplication>{
// fun retrofit( // fun retrofit(
// retorfitModule: RetrofitModule):Builder // retorfitModule: RetrofitModule):Builder
//
// fun build(): AppComponent
fun build(): AppComponent
} }
......
...@@ -13,3 +13,8 @@ import javax.inject.Scope ...@@ -13,3 +13,8 @@ import javax.inject.Scope
@Scope @Scope
@Retention(AnnotationRetention.RUNTIME) @Retention(AnnotationRetention.RUNTIME)
annotation class PerScreen annotation class PerScreen
@Scope
@Retention(AnnotationRetention.RUNTIME)
annotation class ActivityScope
\ No newline at end of file
package com.biganto.visual.roompark.presentation.screen.splash
import com.biganto.visual.roompark.conductor.BigantoBaseContract
/**
* Created by Vladislav Bogdashkin on 30.09.2019.
*/
interface SplashScreen : BigantoBaseContract<SplashScreenViewState> {
}
\ No newline at end of file
package com.biganto.visual.roompark.presentation.screen.splash
import DaggerSplashScreenComponent
import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.base.RoomParkApplication
import com.biganto.visual.roompark.conductor.BigantoBaseController
import com.biganto.visual.roompark.view_utils.snackbar.SnackBarProvider
/**
* Created by Vladislav Bogdashkin on 30.09.2019.
*/
class SplashScreenController :
BigantoBaseController<SplashScreenViewState
, SplashScreen
, SplashScreenPresenter>()
, SplashScreen {
// @Inject
// lateinit var rpActivity:RoomParkMainActivity
fun getComponent() = DaggerSplashScreenComponent
.factory()
.create(RoomParkApplication.component,this)
override fun getSnackBar() = SnackBarProvider(activity!!)//getComponent().snack(activity)
override fun render(viewState: SplashScreenViewState) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun createPresenter(): SplashScreenPresenter = getComponent().presenter
override fun getLayoutId(): Int = R.layout.splash_screen
}
\ No newline at end of file
import com.biganto.visual.roompark.di.dagger.AppComponent
import com.biganto.visual.roompark.di.dagger.PerScreen
import com.biganto.visual.roompark.presentation.screen.splash.SplashScreenController
import com.biganto.visual.roompark.presentation.screen.splash.SplashScreenPresenter
import dagger.BindsInstance
import dagger.Component
//package com.biganto.visual.roompark.presentation.screen.splash
//
//import com.biganto.visual.roompark.di.dagger.AppComponent
//import com.biganto.visual.roompark.di.dagger.PerScreen
//import dagger.Component
//import dagger.Provides
//
///**
// * Created by Vladislav Bogdashkin on 30.09.2019.
// */
//
//@PerScreen
//@Component(dependencies = [AppComponent::class])
//interface SplashComponent {
// @Provides
// fun presenter(): SplashScreenPresenter
//}
//
@PerScreen
@Component( dependencies = [AppComponent::class])
interface SplashScreenComponent {
// fun baseComponent(@BindsInstance appComponent:AppComponent):AppComponent
@Component.Factory
interface Factory{
fun create(
appComponent: AppComponent,
@BindsInstance splashView:SplashScreenController
):SplashScreenComponent
}
val presenter: SplashScreenPresenter
}
//
//@Module
//abstract class SplashScreenModule{
//
//
// @PerScreen
// @Binds
// abstract fun presenter(presenter:SplashScreenPresenter):SplashScreenPresenter
//
//// fun snack(activity:RoomParkMainActivity) : ISnackBarProvider
//}
\ No newline at end of file
package com.biganto.visual.roompark.presentation.screen.splash
import com.biganto.visual.roompark.conductor.BigantoBasePresenter
import javax.inject.Inject
/**
* Created by Vladislav Bogdashkin on 30.09.2019.
*/
class SplashScreenPresenter @Inject constructor()
: BigantoBasePresenter<SplashScreen, SplashScreenViewState>() {
override fun bindIntents() {
val state = restoreStateObservable
subscribeViewState(state.cast(SplashScreenViewState::class.java), SplashScreen::render)
}
}
\ No newline at end of file
package com.biganto.visual.roompark.presentation.screen.splash
import com.biganto.visual.roompark.conductor.BigantoBaseViewState
/**
* Created by Vladislav Bogdashkin on 30.09.2019.
*/
sealed class SplashScreenViewState : BigantoBaseViewState() {
class Idle : SplashScreenViewState()
}
\ No newline at end of file
...@@ -6,6 +6,7 @@ import androidx.core.content.ContextCompat ...@@ -6,6 +6,7 @@ import androidx.core.content.ContextCompat
import com.biganto.visual.roompark.R import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.view_utils.snackbar.SnackBarMessageType.* import com.biganto.visual.roompark.view_utils.snackbar.SnackBarMessageType.*
import com.google.android.material.snackbar.Snackbar import com.google.android.material.snackbar.Snackbar
import javax.inject.Inject
/** /**
* Created by Vladislav Bogdashkin on 06.05.2019. * Created by Vladislav Bogdashkin on 06.05.2019.
...@@ -13,7 +14,7 @@ import com.google.android.material.snackbar.Snackbar ...@@ -13,7 +14,7 @@ import com.google.android.material.snackbar.Snackbar
class SnackBarProvider constructor(val activity: Activity) : ISnackBarProvider { class SnackBarProvider @Inject constructor(val activity: Activity) : ISnackBarProvider {
override val isRootBounded: Boolean override val isRootBounded: Boolean
get() = rootView != null get() = rootView != null
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment