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 {
//Rx Relay
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
testImplementation 'junit:junit:4.12'
......
......@@ -2,6 +2,7 @@ package com.biganto.visual.roompark.base
import android.util.Log
import com.biganto.visual.roompark.BuildConfig
import com.biganto.visual.roompark.di.dagger.AppComponent
import com.biganto.visual.roompark.di.dagger.DaggerAppComponent
import com.crashlytics.android.Crashlytics
import com.squareup.picasso.Picasso
......@@ -14,10 +15,19 @@ import timber.log.Timber
*/
class RoomParkApplication : DaggerApplication() {
companion object {
lateinit var component: AppComponent
private set
}
override fun applicationInjector(): AndroidInjector<out DaggerApplication> {
return DaggerAppComponent.builder()
.context(this)
.build()
component = DaggerAppComponent.factory()
.create(this) as AppComponent
// .context(this)
// .build()
return component
}
override fun onCreate() {
......
......@@ -9,16 +9,17 @@ import butterknife.BindView
import butterknife.ButterKnife
import com.biganto.visual.roompark.BuildConfig
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.snackbar.ISnackBarProvider
import com.bluelinelabs.conductor.Conductor
import com.bluelinelabs.conductor.Router
import com.bluelinelabs.conductor.RouterTransaction
import com.crashlytics.android.Crashlytics
import com.google.android.material.appbar.AppBarLayout
import com.google.android.material.appbar.CollapsingToolbarLayout
import com.google.android.material.bottomnavigation.BottomNavigationView
import io.fabric.sdk.android.Fabric
import javax.inject.Inject
import kotlin.concurrent.thread
class RoomParkMainActivity(
) : BaseRoomParkActivity()
......@@ -26,8 +27,10 @@ class RoomParkMainActivity(
,IConductorActivity
,IBottomNavigation{
@Inject
lateinit var snackbarProvider: ISnackBarProvider
// @Inject
// lateinit var snackbarProvider: ISnackBarProvider
private lateinit var router: Router
......@@ -52,7 +55,16 @@ class RoomParkMainActivity(
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) {
......
......@@ -14,17 +14,14 @@ import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.base.ICollapsingToolBar
import com.biganto.visual.roompark.base.RoomParkMainActivity
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.hannesdorfmann.mosby3.mvi.MviBasePresenter
import io.reactivex.disposables.CompositeDisposable
import javax.inject.Inject
/**
* Created by Vladislav Bogdashkin on 28.05.2018.
*/
@PerScreen
abstract class BigantoBaseController<VS : BigantoBaseViewState,V: BigantoBaseContract<VS>,P : MviBasePresenter<V,VS>>
: BigantoMviController<V, P> {
......@@ -36,29 +33,43 @@ abstract class BigantoBaseController<VS : BigantoBaseViewState,V: BigantoBaseCon
abstract override fun createPresenter(): P
abstract fun getSnackBar(): ISnackBarProvider
@LayoutRes
protected abstract fun getLayoutId(): Int
@StringRes
protected abstract fun getToolbarTitleId(): Int
@Inject
private lateinit var roomParkActivity:RoomParkMainActivity
protected val toolBar: ICollapsingToolBar = roomParkActivity
protected val snackbar: ISnackBarProvider = roomParkActivity.snackbarProvider
lateinit var toolBar: ICollapsingToolBar
lateinit var snackbar: ISnackBarProvider
override fun onDetach(view: View) {
detachDisposable.clear()
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 {
// if (isInjected.not()) {
// ConductorInjection.inject(this)
// isInjected = true
// }
val view = inflater.inflate(getLayoutId(), container, false)
// instantiate the view
ButterKnife.bind(this, view)
toolBar= activity as RoomParkMainActivity
snackbar= getSnackBar()
return view
}
......
......@@ -30,14 +30,13 @@ abstract class ActivityModule {
@JvmStatic
@Provides
fun provideSnackBar(activity: Activity): ISnackBarProvider{
fun provideSnackBar(activity: Activity): ISnackBarProvider {
return SnackBarProvider(activity)
}
}
}
@Module
abstract class AppActivityModule {
......
package com.biganto.visual.roompark.di.dagger
import android.app.Application
import com.biganto.visual.roompark.base.RoomParkApplication
import dagger.BindsInstance
import dagger.Component
import dagger.android.AndroidInjectionModule
import dagger.android.AndroidInjector
......@@ -25,14 +23,15 @@ import javax.inject.Singleton
AndroidSupportInjectionModule::class,
// MappingProvider::class,
ActivityModule::class,
AppActivityModule ::class])
interface AppComponent : AndroidInjector<RoomParkApplication>{
@Component.Builder
interface Builder{
@Component.Factory
interface Factory:AndroidInjector.Factory<RoomParkApplication>{
@BindsInstance
fun context(application: Application): Builder
// @BindsInstance
// fun context(application: Application): Factory
// @BindsInstance
// fun retrofitModule(retrofit: RetrofitModule):Builder
......@@ -43,8 +42,9 @@ interface AppComponent : AndroidInjector<RoomParkApplication>{
// fun retrofit(
// retorfitModule: RetrofitModule):Builder
//
// fun build(): AppComponent
fun build(): AppComponent
}
......
......@@ -12,4 +12,9 @@ import javax.inject.Scope
*/
@Scope
@Retention(AnnotationRetention.RUNTIME)
annotation class PerScreen
\ No newline at end of file
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
import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.view_utils.snackbar.SnackBarMessageType.*
import com.google.android.material.snackbar.Snackbar
import javax.inject.Inject
/**
* Created by Vladislav Bogdashkin on 06.05.2019.
......@@ -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
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