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
93891452
Commit
93891452
authored
Sep 30, 2019
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
successfully move to dagger 2
remove koin dependencies
parent
d4de5bcd
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
306 additions
and
81 deletions
+306
-81
build.gradle
app/build.gradle
+10
-8
DaggerActivity.kt
...n/java/com/biganto/visual/roompark/base/DaggerActivity.kt
+25
-0
RoomParkApplication.kt
...a/com/biganto/visual/roompark/base/RoomParkApplication.kt
+10
-5
RoomParkMainActivity.kt
.../com/biganto/visual/roompark/base/RoomParkMainActivity.kt
+7
-4
ActivityModule.kt
...a/com/biganto/visual/roompark/di/dagger/ActivityModule.kt
+67
-0
AppComponent.kt
...ava/com/biganto/visual/roompark/di/dagger/AppComponent.kt
+68
-0
ContextModule.kt
...va/com/biganto/visual/roompark/di/dagger/ContextModule.kt
+99
-0
PerScreen.kt
...n/java/com/biganto/visual/roompark/di/dagger/PerScreen.kt
+15
-0
AppModule.kt
...ain/java/com/biganto/visual/roompark/di/koin/AppModule.kt
+0
-63
authUseCase.kt
...om/biganto/visual/roompark/domain/use_case/authUseCase.kt
+4
-1
dependencies.gradle
dependencies.gradle
+1
-0
No files found.
app/build.gradle
View file @
93891452
...
...
@@ -67,14 +67,6 @@ dependencies {
implementation
"org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
implementation
'androidx.core:core-ktx:1.1.0'
//Koin
implementation
"org.koin:koin-core:$koinVersion"
implementation
"org.koin:koin-core-ext:$koinVersion"
implementation
"org.koin:koin-android:$koinVersion"
implementation
"org.koin:koin-android-scope:$koinVersion"
implementation
"org.koin:koin-androidx-scope:$koinVersion"
//Material
implementation
"com.google.android.material:material:$materialVersion"
...
...
@@ -108,6 +100,16 @@ dependencies {
implementation
"com.jakewharton:butterknife:$butterKnifeVersion"
kapt
"com.jakewharton:butterknife-compiler:$butterKnifeVersion"
//Dagger2
implementation
"com.google.dagger:dagger:$daggerVersion"
kapt
"com.google.dagger:dagger-compiler:$daggerVersion"
implementation
"com.google.dagger:dagger-android:$daggerVersion"
implementation
"com.google.dagger:dagger-android-support:$daggerVersion"
kapt
"com.google.dagger:dagger-android-processor:$daggerVersion"
//Tests
testImplementation
'junit:junit:4.12'
androidTestImplementation
'androidx.test:runner:1.2.0'
...
...
app/src/main/java/com/biganto/visual/roompark/base/DaggerActivity.kt
0 → 100644
View file @
93891452
package
com.biganto.visual.roompark.base
import
android.os.Bundle
import
android.os.PersistableBundle
import
dagger.android.support.DaggerAppCompatActivity
import
io.reactivex.disposables.CompositeDisposable
/**
* Created by Vladislav Bogdashkin on 30.09.2019.
*/
abstract
class
BaseRoomParkActivity
:
DaggerAppCompatActivity
(){
protected
val
disposable
=
CompositeDisposable
()
override
fun
onCreate
(
savedInstanceState
:
Bundle
?,
persistentState
:
PersistableBundle
?)
{
super
.
onCreate
(
savedInstanceState
,
persistentState
)
}
override
fun
onDestroy
()
{
super
.
onDestroy
()
disposable
.
clear
()
}
override
fun
onAttachedToWindow
()
{
super
.
onAttachedToWindow
()
}
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/base/RoomParkApplication.kt
View file @
93891452
package
com.biganto.visual.roompark.base
import
android.app.Application
import
android.util.Log
import
com.biganto.visual.roompark.BuildConfig
import
com.biganto.visual.roompark.di.
koin.initDI
import
com.biganto.visual.roompark.di.
dagger.DaggerAppComponent
import
com.crashlytics.android.Crashlytics
import
com.squareup.picasso.Picasso
import
dagger.android.AndroidInjector
import
dagger.android.DaggerApplication
import
timber.log.Timber
/**
* Created by Vladislav Bogdashkin on 03.09.2019.
*/
class
RoomParkApplication
:
Application
()
{
class
RoomParkApplication
:
DaggerApplication
()
{
override
fun
applicationInjector
():
AndroidInjector
<
out
DaggerApplication
>
{
return
DaggerAppComponent
.
builder
()
.
context
(
this
)
.
build
()
}
override
fun
onCreate
()
{
super
.
onCreate
()
initDI
()
if
(
BuildConfig
.
DEBUG
)
Timber
.
plant
(
Timber
.
DebugTree
())
else
Timber
.
plant
(
CrashlyticsTree
())
...
...
app/src/main/java/com/biganto/visual/roompark/base/RoomParkMainActivity.kt
View file @
93891452
...
...
@@ -3,10 +3,10 @@ package com.biganto.visual.roompark.base
import
android.os.Bundle
import
android.view.View
import
android.view.ViewGroup
import
androidx.appcompat.app.AppCompatActivity
import
androidx.appcompat.widget.Toolbar
import
androidx.coordinatorlayout.widget.CoordinatorLayout
import
butterknife.BindView
import
butterknife.ButterKnife
import
com.biganto.visual.roompark.BuildConfig
import
com.biganto.visual.roompark.R
import
com.biganto.visual.roompark.view_utils.app_bar.DragControlAppBarLayoutBehaviour
...
...
@@ -18,15 +18,16 @@ 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
org.koin.android.scope.currentScope
import
javax.inject.Inject
class
RoomParkMainActivity
(
)
:
AppCompat
Activity
()
)
:
BaseRoomPark
Activity
()
,
ICollapsingToolBar
,
IConductorActivity
,
IBottomNavigation
{
private
val
snackbarProvider
:
ISnackBarProvider
by
currentScope
.
inject
()
@Inject
lateinit
var
snackbarProvider
:
ISnackBarProvider
private
lateinit
var
router
:
Router
...
...
@@ -45,6 +46,8 @@ class RoomParkMainActivity(
setContentView
(
R
.
layout
.
activity_main
)
ButterKnife
.
bind
(
this
)
setSupportActionBar
(
topAppBar
)
router
=
Conductor
.
attachRouter
(
this
,
conductorContainer
,
savedInstanceState
)
...
...
app/src/main/java/com/biganto/visual/roompark/di/dagger/ActivityModule.kt
0 → 100644
View file @
93891452
package
com.biganto.visual.roompark.di.dagger
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.RoomParkMainActivity
import
com.biganto.visual.roompark.view_utils.snackbar.ISnackBarProvider
import
com.biganto.visual.roompark.view_utils.snackbar.SnackBarProvider
import
dagger.Binds
import
dagger.Module
import
dagger.Provides
import
dagger.android.ContributesAndroidInjector
/**
* Created by Vladislav Bogdashkin on 31.07.2019.
*/
@Module
abstract
class
ActivityModule
{
@Binds
abstract
fun
providesContext
(
activity
:
Activity
):
Context
@Module
companion
object
{
@JvmStatic
@Provides
fun
provideResources
(
activity
:
Activity
)
:
Resources
=
activity
.
resources
@JvmStatic
@Provides
fun
provideSnackBar
(
activity
:
Activity
):
ISnackBarProvider
{
return
SnackBarProvider
(
activity
)
}
}
}
@Module
abstract
class
AppActivityModule
{
@Module
internal
interface
MainActivityModule
{
@Binds
fun
bindMainActivity
(
activity
:
RoomParkMainActivity
):
Activity
}
@Module
internal
interface
BaseActivityModule
{
@Binds
fun
bindBaseActivity
(
activity
:
BaseRoomParkActivity
):
Activity
}
@ContributesAndroidInjector
(
modules
=
[
ActivityModule
::
class
,
MainActivityModule
::
class
])
abstract
fun
contributeMainActivityInjector
():
RoomParkMainActivity
@ContributesAndroidInjector
(
modules
=
[
ActivityModule
::
class
,
BaseActivityModule
::
class
])
abstract
fun
contributeBaseActivityInjector
():
BaseRoomParkActivity
}
app/src/main/java/com/biganto/visual/roompark/di/dagger/AppComponent.kt
0 → 100644
View file @
93891452
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
import
dagger.android.support.AndroidSupportInjectionModule
import
javax.inject.Singleton
/**
* Created by Vladislav Bogdashkin on 13.06.2018.
*/
@Singleton
@Component
(
modules
=
[
AppModule
::
class
,
DataModule
::
class
,
// RetrofitModule::class,
// AppVersionModule::class,
AndroidInjectionModule
::
class
,
AndroidSupportInjectionModule
::
class
,
// MappingProvider::class,
ActivityModule
::
class
,
AppActivityModule
::
class
])
interface
AppComponent
:
AndroidInjector
<
RoomParkApplication
>{
@Component
.
Builder
interface
Builder
{
@BindsInstance
fun
context
(
application
:
Application
):
Builder
// @BindsInstance
// fun retrofitModule(retrofit: RetrofitModule):Builder
// @BindsInstance
// @Named("retrofit")
// fun retrofit(
// retorfitModule: RetrofitModule):Builder
fun
build
():
AppComponent
}
// fun cache(): ICachedStore
// fun context(): Context
// fun db(): IDb
// fun api(): IApi
// fun roomApi(): IRoomParkApi
// fun fileModule(): FilesModule
//// fun appLifeCycle(): AppLifecycleListener
// fun networkMonitor(): INetworkMonitor
// fun versionMonitor(): IAppVersionControl
// fun versionNotifier(): IAppVersionNotifier
//
// fun estateRepo() : IEstateRepository
// fun tourRepo() : ITourRepository
// fun userRepo() : IUserRepository
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/di/dagger/ContextModule.kt
0 → 100644
View file @
93891452
package
com.biganto.visual.roompark.di.dagger
import
dagger.Module
import
dagger.Provides
/**
* Created by Vladislav Bogdashkin on 13.06.2018.
*/
const
val
USER_CACHE_LIMIT_SIZE
=
3
const
val
USER_CACHE_LIMIT_SECONDS_INACTIVE
=
30L
const
val
TOURS_CACHE_LIMIT_SIZE
=
500
const
val
TOURS_CACHE_LIMIT_SECONDS_INACTIVE
=
200L
const
val
ESTATES_CACHE_LIMIT_SIZE
=
100
const
val
ESTATES_CACHE_LIMIT_SECONDS_INACTIVE
=
200L
const
val
FILES_CACHE_LIMIT_SIZE
=
10000
const
val
FILES_CACHE_LIMIT_SECONDS_INACTIVE
=
60L
const
val
DATABASE_VERSION
=
6
@Module
class
AppModule
()
{
}
@Module
()
class
DataModule
()
{
/*
@Provides
@Singleton
fun provieApi(@Named("bigantoApi") retorfit:Retrofit): IApi {
return RetrofitRepository(retorfit)
}
@Provides
@Singleton
fun provieRoomParkApi(@Named("roomParkApi") retorfit:Retrofit): IRoomParkApi {
return RoomParkRetrofitRepository(retorfit)
}
@Provides
@Singleton
fun provideDb(context:Application): IDb {
return RequeryRepository(getRequeryDataStore(context))
}
@Provides
@Singleton
fun provideFileModule(context:Application): FilesModule {
return FilesModule(context)
}
@Provides
@Singleton
fun providesNetworkListener(context:Application): INetworkMonitor {
return LiveNetworkMonitor(context)
}
@Provides
@Singleton
fun getRequeryDataStore(context:Application): KotlinReactiveEntityStore<Persistable> {
Timber.d("Kotlin store creating..")
val source = DatabaseSource(context, Models.DEFAULT, "BigantoPerfect", DATABASE_VERSION)
source.setLoggingEnabled(false)
// if ( BuildConfig.DEBUG) {
// // use this in development mode to drop and recreate the tables on every upgrade
// source.setTableCreationMode(TableCreationMode.DROP_CREATE)
// }
val store = KotlinEntityDataStore<Persistable>(source.configuration)
Timber.d("Kotlin store %s",source)
return KotlinReactiveEntityStore(store)
// // override onUpgrade to handle migrating to a new version
// val configuration = source.configuration
// return ReactiveSupport.toReactiveStore(
// EntityDataStore<Persistable>(configuration))
}
*/
}
//
//@Singleton // <-- YES
//class MyServiceImpl @Inject // <-- YES
//constructor(private val apiService: ApiService)// <-- YES
// : MyService
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/di/dagger/PerScreen.kt
0 → 100644
View file @
93891452
package
com.biganto.visual.roompark.di.dagger
import
javax.inject.Scope
/**
* Created by Vladislav Bogdashkin on 14.06.2018.
*/
/**
* Custom Scope for each Screen
*/
@Scope
@Retention
(
AnnotationRetention
.
RUNTIME
)
annotation
class
PerScreen
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/di/koin/AppModule.kt
deleted
100644 → 0
View file @
d4de5bcd
package
com.biganto.visual.roompark.di.koin
import
com.biganto.visual.roompark.base.RoomParkApplication
import
com.biganto.visual.roompark.base.RoomParkMainActivity
import
com.biganto.visual.roompark.domain.contract.AuthContract
import
com.biganto.visual.roompark.domain.model.AuthInfoModel
import
com.biganto.visual.roompark.view_utils.snackbar.SnackBarProvider
import
io.reactivex.rxjava3.core.Completable
import
io.reactivex.rxjava3.core.Observable
import
org.koin.android.ext.koin.androidContext
import
org.koin.android.ext.koin.androidLogger
import
org.koin.core.context.startKoin
import
org.koin.core.qualifier.named
import
org.koin.dsl.module
/**
* Created by Vladislav Bogdashkin on 03.09.2019.
*/
fun
RoomParkApplication
.
initDI
(){
startKoin
{
androidLogger
()
androidContext
(
this
@initDI
)
modules
(
listOf
(
appModule
,
scopesModule
))
}
}
val
appModule
=
module
{
}
val
dataModule
=
module
{
single
<
AuthContract
>{
object
:
AuthContract
{
override
fun
signIn
(
email
:
String
,
password
:
String
):
Observable
<
AuthInfoModel
>
{
TODO
(
"not implemented"
)
//To change body of created functions use File | Settings | File Templates.
}
override
fun
signOut
():
Completable
{
TODO
(
"not implemented"
)
//To change body of created functions use File | Settings | File Templates.
}
}}
}
val
scopesModule
=
module
{
scope
(
named
<
RoomParkMainActivity
>()){
scoped
{
SnackBarProvider
(
get
())
}
}
}
val
presenterScope
=
module
{
scope
(
named
<
RoomParkMainActivity
>()){
//<- Presenter?
scoped
{
StartUpData
(
"ja pesik!"
)
}
}
}
data class
StartUpData
(
val
helloText
:
String
)
app/src/main/java/com/biganto/visual/roompark/domain/use_case/authUseCase.kt
View file @
93891452
package
com.biganto.visual.roompark.domain.use_case
import
com.biganto.visual.roompark.di.dagger.PerScreen
import
com.biganto.visual.roompark.domain.contract.AuthContract
/**
* Created by Vladislav Bogdashkin on 24.09.2019.
*/
@PerScreen
class
AuthUseCase
(
val
auth
:
AuthContract
by
currentScope
.
get
<>
val
auth
Contract
:
AuthContract
){
}
\ No newline at end of file
dependencies.gradle
View file @
93891452
...
...
@@ -21,4 +21,5 @@ ext {
rxJavaVersion
=
'3.0.0-RC3'
mosbyMviConductorVersion
=
'3.1.0'
butterKnifeVersion
=
'10.2.0'
daggerVersion
=
'2.24'
}
\ 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