This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="utf-8"?> | |
| <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| xmlns:app="http://schemas.android.com/apk/res-auto" | |
| xmlns:tools="http://schemas.android.com/tools" | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent" | |
| tools:context=".view.MovieActivity"> | |
| <include | |
| android:id="@+id/errorView" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="utf-8"?> | |
| <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| xmlns:app="http://schemas.android.com/apk/res-auto" | |
| xmlns:tools="http://schemas.android.com/tools" | |
| android:layout_width="match_parent" | |
| android:layout_height="wrap_content" | |
| android:layout_marginTop="12dp"> | |
| <com.google.android.material.card.MaterialCardView | |
| android:layout_width="match_parent" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="utf-8"?> | |
| <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| xmlns:app="http://schemas.android.com/apk/res-auto" | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent"> | |
| <androidx.recyclerview.widget.RecyclerView | |
| android:id="@+id/recyclerView" | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Component(modules = [NetworkModule::class]) | |
| @Singleton | |
| interface AppComponent : ActivityDepsProvider { | |
| @Component.Builder | |
| interface Builder { | |
| fun build(): AppComponent | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Component(modules = [NetworkModule::class]) | |
| @Singleton | |
| interface AppComponent : ActivityDepsProvider { | |
| @Component.Builder | |
| interface Builder { | |
| fun build(): AppComponent | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Subcomponent(modules = [MovieActivityModule::class]) | |
| @MovieActivityScope | |
| interface MovieComponent { | |
| fun inject(movieActivity: MovieActivity) | |
| @Subcomponent.Builder | |
| interface Builder { | |
| @BindsInstance | |
| fun activity(appCompatActivity: AppCompatActivity): Builder |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Subcomponent(modules = [MovieActivityModule::class]) | |
| @MovieActivityScope | |
| interface MovieComponent { | |
| fun inject(movieActivity: MovieActivity) | |
| @Subcomponent.Builder | |
| interface Builder { | |
| @BindsInstance | |
| fun activity(appCompatActivity: AppCompatActivity): Builder |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @MovieActivityScope | |
| class MoviePresenter @Inject constructor( | |
| private val movieView: MovieContract.MovieView, | |
| private val scope: CoroutineScope, | |
| private val movieModel: MovieModel | |
| ) { | |
| fun onAttach() { | |
| callMoviesApi() | |
| observeOnClickStateFlow() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @MovieActivityScope | |
| class MovieModel @Inject constructor( | |
| private val movieApi: MovieApi | |
| ) { | |
| fun callMoviesApi(): Flow<MovieListResponse> { | |
| return flow { | |
| val carbonOffsetResponse = movieApi.getMoviesList("a427cfb730b4a73e67c646d8b44dd216") | |
| emit(carbonOffsetResponse) | |
| }.flowOn(Dispatchers.IO) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import com.app.coroutinesmvp.api.MovieApi | |
| import com.app.coroutinesmvp.model.MovieModel | |
| import com.nhaarman.mockitokotlin2.mock | |
| import com.nhaarman.mockitokotlin2.whenever | |
| import kotlin.test.assertEquals | |
| import kotlin.test.assertNull | |
| import kotlinx.coroutines.flow.catch | |
| import kotlinx.coroutines.flow.collect | |
| import kotlinx.coroutines.runBlocking |