Skip to content

Instantly share code, notes, and snippets.

View rodolfoizidoro's full-sized avatar

Rodolfo Izidoro rodolfoizidoro

View GitHub Profile
class MovieListViewModel(private val repository: MovieRepository) : BaseViewModel() {
private val mMovies = StateMutableLiveData<List<Movie>, Throwable>()
val movies : StateLiveData<List<Movie>, Throwable> get() = mMovies
fun findMovies() {
jobs add launch {
mMovies.loading.value = true
try {
val response = repository.findMovies().await().results
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.LiveData
interface StateLiveData<R, E> {
fun observe(owner: LifecycleOwner, onSuccess: (R) -> Unit, onError: (E) -> Unit = {}, onLoading: (Boolean) -> Unit = {})
val loadingLiveData: LiveData<Boolean>
val successLiveData: LiveData<R>
val errorLiveData: LiveData<E>
}
viewModel.movies.observe(this, Observer { list ->
rvMovies.adapter = MoviesAdapter(list) {
flowController.openMovieDetail(it)
}
})
viewModel.progress.observe(this, Observer { visible ->
progress.show(visible)
})
private val mMovies = MutableLiveData<List<Movies>>()
private val mLoading = MutableLiveData<Boolean>()
private val mError = MutableLiveData<Thowable>()
val movies: LiveData<List<Movies>> get() = mMovies
val loading: LiveData<Boolean> get() = mLoading
val error: LiveData<Thowable> get() = mError
interface MoviesView {
fun showProgress()
fun hideProgress()
fun showMovies(movies : List<Movie>)
fun showError(error : Throwable)
}
//Abstração
class TestLiveData<T, Q> : TestLiveDataI<T, Q> {
val success = MutableLiveData<T>()
val loading = MutableLiveData<Boolean>()
val error = Event<Q>()
override fun successLiveData(): LiveData<T> = success
override fun loadingLiveData(): LiveData<Boolean> = loading
override fun errorLiveData(): LiveData<Q> = error
@rodolfoizidoro
rodolfoizidoro / favoritos.html
Created December 22, 2018 03:23
Estudos Ferias
<!DOCTYPE NETSCAPE-Bookmark-file-1>
<!-- This is an automatically generated file.
It will be read and overwritten.
DO NOT EDIT! -->
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<TITLE>Bookmarks</TITLE>
<H1>Bookmarks</H1>
<DL><p>
<DT><H3 ADD_DATE="1489432446" LAST_MODIFIED="1545425521" PERSONAL_TOOLBAR_FOLDER="true">Barra de favoritos</H3>
<DL><p>
@rodolfoizidoro
rodolfoizidoro / favoritos.md
Last active February 1, 2019 21:55
Lista de estudos nas férias . Importar no Chrome.
Name Link
Download Favoritos para importa no Google Chrome https://gist.github.com/rodolfoizidoro/f0d5051d9109eb7dc70c2dfcf42a67aa
MVVM with Kotlin — Android Architecture Components, Dagger 2, Retrofit and RxAndroid https://proandroiddev.com/mvvm-with-kotlin-android-architecture-components-dagger-2-retrofit-and-rxandroid-1a4ebb38c699
30 summertime Android libraries and tools which you don’t want to miss in 2018 https://medium.com/@mmbialas/30-summertime-android-libraries-and-tools-which-you-dont-want-to-miss-in-2018-fab053d69503
KeepSafe/TapTargetView An implementation of tap targets from the Material Design guidelines for feature discovery https://github.com/KeepSafe/TapTargetView
Material Intro View is a showcase android library. https://github.com/iammert/MaterialIntroView
Modern background execution in Android https://android-developers.googleblog.com/2018/10/modern-background-execution-in-android.html?m=1
Dominando o Data Binding no Android https://pt.slideshare.