File tree Expand file tree Collapse file tree 7 files changed +103
-0
lines changed
java/cz/skywal/mutimoduleexmaple/dummy_service
home/src/main/java/cz/skywall/multimoduleexample/home/ui/home Expand file tree Collapse file tree 7 files changed +103
-0
lines changed Original file line number Diff line number Diff line change 1+ /build
Original file line number Diff line number Diff line change 1+ plugins {
2+ id ' com.android.library'
3+ id ' kotlin-android'
4+ id ' kotlin-android-extensions'
5+ id ' kotlin-kapt'
6+ }
7+
8+ apply from : ' ../core_dependencies.gradle'
9+ apply from : ' ../test_dependencies.gradle'
10+
11+
12+ android {
13+ compileSdkVersion 29
14+ buildToolsVersion " 29.0.3"
15+
16+ defaultConfig {
17+ minSdkVersion 23
18+ targetSdkVersion 29
19+ versionCode 1
20+ versionName " 1.0"
21+
22+ testInstrumentationRunner " androidx.test.runner.AndroidJUnitRunner"
23+ }
24+
25+ buildTypes {
26+ release {
27+ minifyEnabled false
28+ proguardFiles getDefaultProguardFile(' proguard-android-optimize.txt' ), ' proguard-rules.pro'
29+ }
30+ }
31+ }
32+
33+ dependencies {
34+ implementation project(" :core" )
35+
36+ kapt ' com.google.dagger:dagger-compiler:2.27'
37+ }
Original file line number Diff line number Diff line change 1+ <manifest xmlns : android =" http://schemas.android.com/apk/res/android"
2+ package =" cz.skywal.mutimoduleexmaple.dummy_service" >
3+
4+ <application >
5+ <service android : name =" .DummyService" />
6+ </application >
7+ </manifest >
Original file line number Diff line number Diff line change 1+ package cz.skywal.mutimoduleexmaple.dummy_service
2+
3+ import android.app.Application
4+ import android.app.Service
5+ import android.content.Intent
6+ import android.os.IBinder
7+ import android.util.Log
8+ import cz.skywal.mutimoduleexmaple.dummy_service.injection.DaggerDummyServiceComponent
9+ import cz.skywall.multimoduleexample.core.injection.CoreComponentHolder
10+
11+ class DummyService : Service () {
12+
13+ override fun onCreate () {
14+ super .onCreate()
15+ DaggerDummyServiceComponent
16+ .factory()
17+ .create(CoreComponentHolder .getInstance(applicationContext as Application ))
18+ .inject(this )
19+
20+ Log .d(" DummyService" , " I'm alive" )
21+ }
22+
23+ override fun onBind (intent : Intent ? ): IBinder ? {
24+ return null
25+ }
26+ }
Original file line number Diff line number Diff line change 1+ package cz.skywal.mutimoduleexmaple.dummy_service.injection
2+
3+ import cz.skywal.mutimoduleexmaple.dummy_service.DummyService
4+ import cz.skywall.multimoduleexample.core.injection.CoreComponent
5+ import dagger.Component
6+
7+ @DummyServiceScope
8+ @Component(
9+ dependencies = [
10+ CoreComponent ::class
11+ ]
12+ )
13+ interface DummyServiceComponent {
14+
15+ @Component.Factory
16+ interface Factory {
17+ fun create (coreComponent : CoreComponent ): DummyServiceComponent
18+ }
19+
20+ fun inject (service : DummyService )
21+ }
Original file line number Diff line number Diff line change 1+ package cz.skywal.mutimoduleexmaple.dummy_service.injection
2+
3+ import javax.inject.Scope
4+
5+ @Scope
6+ @Retention(AnnotationRetention .RUNTIME )
7+ annotation class DummyServiceScope
Original file line number Diff line number Diff line change 11package cz.skywall.multimoduleexample.home.ui.home
22
3+ import android.content.Intent
34import android.content.SharedPreferences
45import android.os.Bundle
56import android.view.LayoutInflater
67import android.view.View
78import android.view.ViewGroup
89import android.widget.TextView
10+ import cz.skywal.mutimoduleexmaple.dummy_service.DummyService
911import cz.skywall.multimoduleexample.home.base.BaseFragment
1012import cz.skywall.multimoduleexample.home.data.repository.DummyRepository
1113import cz.skywall.multimoduleexample.home.data.repository.DummyRepository2
@@ -37,6 +39,8 @@ class HomeFragment : BaseFragment() {
3739
3840 override fun inject () {
3941 homeComponent.plus(HomeFragmentModule ()).inject(this )
42+
43+ requireActivity().startService(Intent (requireActivity(), DummyService ::class .java))
4044 }
4145
4246 override fun onViewCreated (view : View , savedInstanceState : Bundle ? ) {
You can’t perform that action at this time.
0 commit comments