Skip to content

Instantly share code, notes, and snippets.

View vikasmain's full-sized avatar
🎯
Focusing

Vikas Bajpayee vikasmain

🎯
Focusing
View GitHub Profile
<?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"
<?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"
<?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"
@Component(modules = [NetworkModule::class])
@Singleton
interface AppComponent : ActivityDepsProvider {
@Component.Builder
interface Builder {
fun build(): AppComponent
}
}
@Component(modules = [NetworkModule::class])
@Singleton
interface AppComponent : ActivityDepsProvider {
@Component.Builder
interface Builder {
fun build(): AppComponent
}
}
@Subcomponent(modules = [MovieActivityModule::class])
@MovieActivityScope
interface MovieComponent {
fun inject(movieActivity: MovieActivity)
@Subcomponent.Builder
interface Builder {
@BindsInstance
fun activity(appCompatActivity: AppCompatActivity): Builder
@Subcomponent(modules = [MovieActivityModule::class])
@MovieActivityScope
interface MovieComponent {
fun inject(movieActivity: MovieActivity)
@Subcomponent.Builder
interface Builder {
@BindsInstance
fun activity(appCompatActivity: AppCompatActivity): Builder
@MovieActivityScope
class MoviePresenter @Inject constructor(
private val movieView: MovieContract.MovieView,
private val scope: CoroutineScope,
private val movieModel: MovieModel
) {
fun onAttach() {
callMoviesApi()
observeOnClickStateFlow()
@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)
}
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