Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Room Park Android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vladislav Bogdashkin
Room Park Android
Commits
7129b223
Commit
7129b223
authored
Oct 09, 2019
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
controller component injection in a new way
parent
8cee5e74
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
110 additions
and
29 deletions
+110
-29
BigantoBaseController.kt
...iganto/visual/roompark/conductor/BigantoBaseController.kt
+10
-6
ActivityModule.kt
...a/com/biganto/visual/roompark/di/dagger/ActivityModule.kt
+7
-3
ScreenController.kt
...l/roompark/presentation/screen/splash/ScreenController.kt
+38
-5
ScreenDI.kt
...to/visual/roompark/presentation/screen/splash/ScreenDI.kt
+45
-14
ScreenPresenter.kt
...al/roompark/presentation/screen/splash/ScreenPresenter.kt
+9
-1
ScreenViewState.kt
...al/roompark/presentation/screen/splash/ScreenViewState.kt
+1
-0
No files found.
app/src/main/java/com/biganto/visual/roompark/conductor/BigantoBaseController.kt
View file @
7129b223
...
...
@@ -31,6 +31,10 @@ abstract class BigantoBaseController<VS : BigantoBaseViewState,V: BigantoBaseCon
constructor
(
args
:
Bundle
):
super
(
args
)
val
inject
by
lazy
{
injectDependencies
()
}
protected
abstract
fun
injectDependencies
()
protected
val
detachDisposable
=
CompositeDisposable
()
abstract
override
fun
createPresenter
():
P
...
...
@@ -59,20 +63,20 @@ abstract class BigantoBaseController<VS : BigantoBaseViewState,V: BigantoBaseCon
// }
}
override
fun
onCreateView
(
inflater
:
LayoutInflater
,
container
:
ViewGroup
):
View
{
override
fun
onContextAvailable
(
context
:
Context
)
{
super
.
onContextAvailable
(
context
)
inject
}
// if (isInjected.not()) {
// ConductorInjection.inject(this)
// isInjected = true
// }
override
fun
onCreateView
(
inflater
:
LayoutInflater
,
container
:
ViewGroup
):
View
{
val
view
=
inflater
.
inflate
(
getLayoutId
(),
container
,
false
)
// instantiate the view
ButterKnife
.
bind
(
this
,
view
)
Timber
.
d
(
" ACTIVITY IS : ${activity?.localClassName} / ${activity?.localClassName}"
)
(
activity
as
RoomParkMainActivity
).
let
{
snackbar
=
ActivityModule
.
provideSnackBar
(
it
)
toolBar
=
it
snackbar
.
bindRootView
(
toolBar
.
coordinatorLayout
)
}
return
view
}
...
...
app/src/main/java/com/biganto/visual/roompark/di/dagger/ActivityModule.kt
View file @
7129b223
...
...
@@ -4,6 +4,7 @@ import android.app.Activity
import
android.content.Context
import
android.content.res.Resources
import
com.biganto.visual.roompark.base.BaseRoomParkActivity
import
com.biganto.visual.roompark.base.ICollapsingToolBar
import
com.biganto.visual.roompark.base.RoomParkMainActivity
import
com.biganto.visual.roompark.view_utils.snackbar.ISnackBarProvider
import
com.biganto.visual.roompark.view_utils.snackbar.SnackBarProvider
...
...
@@ -43,14 +44,17 @@ abstract class AppActivityModule {
@Module
internal
interface
MainActivityModule
{
@Binds
fun
bindMainActivity
(
activity
:
RoomParkMainActivity
):
Activity
}
fun
bindMainActivity
(
activity
:
RoomParkMainActivity
):
BaseRoomParkActivity
@Binds
fun
bindMainActivityToolbar
(
activity
:
RoomParkMainActivity
):
ICollapsingToolBar
}
@Module
internal
interface
BaseActivityModule
{
@Binds
fun
bindBaseActivity
(
activity
:
BaseRoomParkActivity
):
Activity
fun
bindBaseActivity
(
activity
:
BaseRoomParkActivity
):
BaseRoomParkActivity
}
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/splash/ScreenController.kt
View file @
7129b223
...
...
@@ -5,10 +5,12 @@ import android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
com.biganto.visual.roompark.R
import
com.biganto.visual.roompark.base.ICollapsingToolBar
import
com.biganto.visual.roompark.base.RoomParkApplication
import
com.biganto.visual.roompark.base.RoomParkMainActivity
import
com.biganto.visual.roompark.conductor.BigantoBaseController
import
com.google.android.material.snackbar.Snackbar
import
javax.inject.Inject
/**
* Created by Vladislav Bogdashkin on 30.09.2019.
...
...
@@ -20,26 +22,57 @@ class SplashScreenController :
,
SplashScreenPresenter
>()
,
SplashScreen
{
override
fun
injectDependencies
()
{
getComponent
()
}
@Inject
lateinit
var
tb
:
ICollapsingToolBar
// @Inject
// lateinit var snacky:ISnackBarProvider
lateinit
var
rpActivity
:
RoomParkMainActivity
fun
getComponent
()
=
DaggerSplashScreenComponent
.
factory
()
.
create
(
RoomParkApplication
.
component
,
this
)
.
create
(
RoomParkApplication
.
component
,
activity
as
RoomParkMainActivity
)
.
inject
(
this
)
// @Inject
// lateinit var ac: RoomParkMainActivity
override
fun
onCreateView
(
inflater
:
LayoutInflater
,
container
:
ViewGroup
):
View
{
val
v
=
super
.
onCreateView
(
inflater
,
container
)
rpActivity
=
activity
as
RoomParkMainActivity
snackbar
.
showSnackBar
(
"AZZZA"
,
Snackbar
.
LENGTH_LONG
)
return
v
}
override
fun
render
(
viewState
:
SplashScreenViewState
)
{
TODO
(
"not implemented"
)
//To change body of created functions use File | Settings | File Templates.
when
(
viewState
){
is
SplashScreenViewState
.
Idle
->
render
(
viewState
)
is
SplashScreenViewState
.
ToScreen
->
render
(
viewState
)
}
}
override
fun
createPresenter
():
SplashScreenPresenter
=
getComponent
().
presenter
private
fun
render
(
viewState
:
SplashScreenViewState
.
Idle
){
}
private
fun
render
(
viewState
:
SplashScreenViewState
.
ToScreen
){
snackbar
.
showSnackBar
(
viewState
.
message
,
Snackbar
.
LENGTH_LONG
)
tb
.
appBar
.
setBackgroundColor
(
resources
?.
getColor
(
R
.
color
.
colorAccentSecondary
)
?:
R
.
color
.
colorAccent
)
// snacky.showSnackBar("lul")
}
@Inject
lateinit
var
_p
:
SplashScreenPresenter
override
fun
createPresenter
():
SplashScreenPresenter
=
_p
override
fun
getLayoutId
():
Int
=
R
.
layout
.
splash_screen
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/splash/ScreenDI.kt
View file @
7129b223
import
android.content.Context
import
com.biganto.visual.roompark.base.ICollapsingToolBar
import
com.biganto.visual.roompark.base.RoomParkMainActivity
import
com.biganto.visual.roompark.di.dagger.ActivityModule
import
com.biganto.visual.roompark.di.dagger.AppActivityModule
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.Binds
import
dagger.BindsInstance
import
dagger.Component
import
dagger.Module
//package com.biganto.visual.roompark.presentation.screen.splash
//
...
...
@@ -26,8 +33,11 @@ import dagger.Component
//
//
@PerScreen
@Component
(
dependencies
=
[
AppComponent
::
class
])
@Component
(
modules
=
[
RoomParkActivityModule
::
class
,
ActivityModule
::
class
,
AppActivityModule
::
class
],
dependencies
=
[
AppComponent
::
class
])
interface
SplashScreenComponent
{
...
...
@@ -36,25 +46,46 @@ interface SplashScreenComponent {
@Component
.
Factory
interface
Factory
{
fun
create
(
appComponent
:
AppComponent
,
@BindsInstance
splashView
:
SplashScreenController
appComponent
:
AppComponent
,
@BindsInstance
activity
:
RoomParkMainActivity
):
SplashScreenComponent
}
val
presenter
:
SplashScreenPresenter
fun
inject
(
controller
:
SplashScreenController
)
// val roomParkActivity: RoomParkMainActivity
// val snackBar : ISnackBarProvider
}
@Module
abstract
class
RoomParkActivityModule
{
@PerScreen
@Binds
abstract
fun
provideContext
(
activity
:
RoomParkMainActivity
):
Context
}
//
//@Module
//abstract class SplashScreenModule{
//
//
// @PerScreen
// @Binds
// abstract fun presenter(presenter:SplashScreenPresenter):SplashScreenPresenter
//
//// fun snack(activity:RoomParkMainActivity) : ISnackBarProvider
//}
\ No newline at end of file
// abstract fun provideContext(activity: Activity): Context
// @Binds
// abstract fun provideSnack(snack:ISnackBarProvider) : ISnackBarProvider
@PerScreen
@Binds
abstract
fun
provideToolbar
(
activitiy
:
RoomParkMainActivity
):
ICollapsingToolBar
// @ContributesAndroidInjector(
// modules = [ActivityModule::class, AppActivityModule.MainActivityModule::class])
// abstract fun contributeMainActivityInjector(): RoomParkMainActivity
// @Binds
// abstract fun provideSnack(activitiy: RoomParkMainActivity):ISnackBarProvider
}
app/src/main/java/com/biganto/visual/roompark/presentation/screen/splash/ScreenPresenter.kt
View file @
7129b223
package
com.biganto.visual.roompark.presentation.screen.splash
import
com.biganto.visual.roompark.base.RoomParkMainActivity
import
com.biganto.visual.roompark.conductor.BigantoBasePresenter
import
io.reactivex.Observable
import
javax.inject.Inject
/**
...
...
@@ -8,12 +10,18 @@ import javax.inject.Inject
*/
class
SplashScreenPresenter
@Inject
constructor
()
class
SplashScreenPresenter
@Inject
constructor
(
var
acitivityContext
:
RoomParkMainActivity
// ,var context:Context
)
:
BigantoBasePresenter
<
SplashScreen
,
SplashScreenViewState
>()
{
override
fun
bindIntents
()
{
val
state
=
restoreStateObservable
.
mergeWith
(
Observable
.
just
(
SplashScreenViewState
.
ToScreen
(
acitivityContext
.
javaClass
.
toString
())))
subscribeViewState
(
state
.
cast
(
SplashScreenViewState
::
class
.
java
),
SplashScreen
::
render
)
}
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/splash/ScreenViewState.kt
View file @
7129b223
...
...
@@ -9,4 +9,5 @@ import com.biganto.visual.roompark.conductor.BigantoBaseViewState
sealed
class
SplashScreenViewState
:
BigantoBaseViewState
()
{
class
Idle
:
SplashScreenViewState
()
class
ToScreen
(
val
message
:
String
)
:
SplashScreenViewState
()
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment