Skip to content

Commit 6c45cb2

Browse files
Issue 1 - initial structure
1 parent 4e80f05 commit 6c45cb2

File tree

12 files changed

+123
-18
lines changed

12 files changed

+123
-18
lines changed

app/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
dependencies {
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+
}

app/src/main/AndroidManifest.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
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" />
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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+
}

app/src/main/java/com/codandotv/streamplayerapp/data/ListMovieRepository.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@ interface ListMovieRepository {
88
}
99

1010
class 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
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
}

app/src/main/java/com/codandotv/streamplayerapp/domain/ListMovieUseCase.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff 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
}

app/src/main/java/com/codandotv/streamplayerapp/presentation/ListMovieActivity.kt

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,26 @@ package com.codandotv.streamplayerapp.presentation
22

33
import android.os.Bundle
44
import 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
}
Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
package 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
}

app/src/main/java/com/codandotv/streamplayerapp/presentation/ListMovieViewModel.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
package com.codandotv.streamplayerapp.presentation
22

3+
import androidx.lifecycle.ViewModel
34
import com.codandotv.streamplayerapp.domain.ListMovieAnalytics
45
import com.codandotv.streamplayerapp.domain.ListMovieUseCase
56
import com.codandotv.streamplayerapp.domain.model.ListMovie
67

78
sealed class ListMovieState {
8-
data class Success(val listMovie : ListMovie)
9+
data class Success(val listMovie: ListMovie)
910
}
1011

1112
class 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
}

0 commit comments

Comments
 (0)