Skip to content

Instantly share code, notes, and snippets.

View sberoch's full-sized avatar

Santiago Beroch sberoch

  • Zarate, Buenos Aires, Argentina
View GitHub Profile
class CharactersViewModel @ViewModelInject constructor(
private val repository: CharacterRepository
) : ViewModel() {
val characters: LiveData<Resource<List<Character>>> = repository.getCharacters()
}
class CharacterRepository @Inject constructor(
private val remoteDataSource: CharacterRemoteDataSource,
private val localDataSource: CharacterDao
) {
//...
}
@Module
@InstallIn(ApplicationComponent::class)
object AppModule {
@Singleton
@Provides
fun provideRetrofit(gson: Gson) : Retrofit = Retrofit.Builder()
.baseUrl("https://rickandmortyapi.com/api/")
.addConverterFactory(GsonConverterFactory.create(gson))
.build()
@AndroidEntryPoint
class CharacterDetailFragment : Fragment() {
//...
}
@AndroidEntryPoint
class MainActivity : AppCompatActivity() {
//...
}
{
"info": {
"count": 591,
"pages": 20,
"next": "https://rickandmortyapi.com/api/character/?page=2",
"prev": null
},
"results": [
// ...
]
@HiltAndroidApp
class MainApplication : Application()