File tree Expand file tree Collapse file tree 12 files changed +123
-18
lines changed
java/com/codandotv/streamplayerapp Expand file tree Collapse file tree 12 files changed +123
-18
lines changed Original file line number Diff line number Diff line change 11dependencies {
22 implementation(project(Dependencies .Module .core_networking))
3+ implementation(Dependencies .Koin .koin)
34 Dependencies .Kotlin .list.forEach { implementation(it) }
45 Dependencies .Support .list.forEach { implementation(it) }
5-
66 Dependencies .UnitTest .list.forEach { testImplementation(it) }
77 Dependencies .AndroidTest .list.forEach { androidTestImplementation(it) }
8- }
8+ }
Original file line number Diff line number Diff line change 1010 android : label =" @string/app_name"
1111 android : supportsRtl =" true"
1212 android : theme =" @style/Theme.StreamPlayerApp"
13- tools : targetApi =" 31" >
13+ tools : targetApi =" 31"
14+ android : name =" .CustomApplication" >
1415 <activity
15- android : name =" .MainActivity "
16+ android : name =" .presentation.ListMovieActivity "
1617 android : exported =" true" >
1718 <intent-filter >
1819 <action android : name =" android.intent.action.MAIN" />
Original file line number Diff line number Diff line change 1+ package com.codandotv.streamplayerapp
2+
3+ import android.app.Application
4+ import com.codandotv.streamplayerapp.di.AppModule
5+ import org.koin.android.ext.koin.androidContext
6+ import org.koin.core.context.startKoin
7+
8+ class CustomApplication : Application () {
9+
10+ override fun onCreate () {
11+ super .onCreate()
12+ startKoin{
13+ androidContext(this @CustomApplication.applicationContext)
14+ modules(AppModule .module)
15+ }
16+ }
17+ }
Original file line number Diff line number Diff line change @@ -8,10 +8,8 @@ interface ListMovieRepository {
88}
99
1010class ListMovieRepositoryImpl (
11- private val service : ListMovieService
11+ // private val service : ListMovieService
1212) : ListMovieRepository {
1313
14- override fun getMovies (): ListMovie =
15- service.getMovies()
16- .toListMovie()
14+ override fun getMovies (): ListMovie = ListMovie (" " )
1715}
Original file line number Diff line number Diff line change 1+ package com.codandotv.streamplayerapp.di
2+
3+ import android.content.res.Resources
4+ import org.koin.android.ext.koin.androidContext
5+ import org.koin.dsl.module
6+
7+ object AppModule {
8+
9+ val module = module {
10+ single<Resources > { androidContext().resources }
11+ }
12+ }
Original file line number Diff line number Diff line change 1+ package com.codandotv.streamplayerapp.di
2+
3+ import com.codandotv.streamplayerapp.data.ListMovieRepository
4+ import com.codandotv.streamplayerapp.data.ListMovieRepositoryImpl
5+ import com.codandotv.streamplayerapp.domain.ListMovieAnalytics
6+ import com.codandotv.streamplayerapp.domain.ListMovieAnalyticsImpl
7+ import com.codandotv.streamplayerapp.domain.ListMovieUseCase
8+ import com.codandotv.streamplayerapp.domain.ListMovieUseCaseImpl
9+ import com.codandotv.streamplayerapp.presentation.ListMovieUiModelImpl
10+ import com.codandotv.streamplayerapp.presentation.ListMovieUimodel
11+ import com.codandotv.streamplayerapp.presentation.ListMovieViewModel
12+ import org.koin.androidx.viewmodel.dsl.viewModel
13+ import org.koin.dsl.module
14+
15+ object ListMovieModule {
16+ val module = module {
17+ viewModel {
18+ ListMovieViewModel (
19+ uiModel = get(),
20+ useCase = get(),
21+ analytics = get()
22+ )
23+ }
24+ factory<ListMovieUseCase > {
25+ ListMovieUseCaseImpl (
26+ repository = get()
27+ )
28+ }
29+
30+ factory<ListMovieAnalytics > {
31+ ListMovieAnalyticsImpl ()
32+ }
33+
34+ factory<ListMovieRepository > {
35+ ListMovieRepositoryImpl ()
36+ }
37+
38+
39+ factory<ListMovieUimodel > {
40+ ListMovieUiModelImpl (
41+ resources = get()
42+ )
43+ }
44+ }
45+ }
Original file line number Diff line number Diff line change @@ -11,7 +11,8 @@ class ListMovieUseCaseImpl(
1111 private val repository : ListMovieRepository
1212) : ListMovieUseCase{
1313
14- override fun getMovies (): ListMovie =
15- repository.getMovies()
16-
14+ override fun getMovies (): ListMovie {
15+ println (" >>>>>>> Curta o video!!!" )
16+ return repository.getMovies()
17+ }
1718}
Original file line number Diff line number Diff line change @@ -2,13 +2,26 @@ package com.codandotv.streamplayerapp.presentation
22
33import android.os.Bundle
44import androidx.appcompat.app.AppCompatActivity
5+ import androidx.lifecycle.ViewModel
6+ import com.codandotv.streamplayerapp.R
7+ import com.codandotv.streamplayerapp.di.ListMovieModule
8+ import com.codandotv.streamplayerapp.domain.model.ListMovie
9+ import org.koin.androidx.viewmodel.ext.android.viewModel
10+ import org.koin.core.context.loadKoinModules
11+ import org.koin.core.context.unloadKoinModules
12+ import org.koin.dsl.module
513
6-
7- class ListMovieActivity : AppCompatActivity (){
8- val viewModel = ListMovieViewModel ()
9-
14+ class ListMovieActivity : AppCompatActivity () {
15+ private val viewModel : ListMovieViewModel by viewModel()
1016 override fun onCreate (savedInstanceState : Bundle ? ) {
1117 super .onCreate(savedInstanceState)
18+ setContentView(R .layout.activity_main)
19+ loadKoinModules(ListMovieModule .module)
1220 viewModel.curtaVideo()
1321 }
22+
23+ override fun onDestroy () {
24+ unloadKoinModules(ListMovieModule .module)
25+ super .onDestroy()
26+ }
1427}
Original file line number Diff line number Diff line change 11package com.codandotv.streamplayerapp.presentation
22
3- class ListMovieUimodel {
3+ import android.content.res.Resources
4+
5+ interface ListMovieUimodel {
6+ }
7+
8+ class ListMovieUiModelImpl (
9+ private val resources : Resources
10+ ) : ListMovieUimodel{
11+
12+
13+
14+
15+
416}
Original file line number Diff line number Diff line change 11package com.codandotv.streamplayerapp.presentation
22
3+ import androidx.lifecycle.ViewModel
34import com.codandotv.streamplayerapp.domain.ListMovieAnalytics
45import com.codandotv.streamplayerapp.domain.ListMovieUseCase
56import com.codandotv.streamplayerapp.domain.model.ListMovie
67
78sealed class ListMovieState {
8- data class Success (val listMovie : ListMovie )
9+ data class Success (val listMovie : ListMovie )
910}
1011
1112class ListMovieViewModel (
1213 private val uiModel : ListMovieUimodel ,
1314 private val useCase : ListMovieUseCase ,
1415 private val analytics : ListMovieAnalytics
15- ) {
16+ ) : ViewModel() {
1617 fun curtaVideo () {
1718 useCase.getMovies()
1819 }
You can’t perform that action at this time.
0 commit comments