This Android Kotlin project using an classic architecture MVP with repository pattern, DI (Dagger2), Retrofit and Room.
I am providing the Repository with all necessary dependencies
@Singleton
@Component(modules = [
ApplicationModule::class,
RepositoryModule::class,
RetrofitModule::class,
SharedPrefsModule::class,
RoomModule::class])
interface ApplicationComponent : AndroidInjector<SampleApplication> {
fun inject(applicationContext: Context)
fun provideRepository(): Repository
}
Samples:
//Acesso Local (Database):
mRepository.local()?.getDatabase()?.breedDao()?.insertBreeds(entities)
//Acesso Local (Prefs):
repository.local()?
.getPrefs();
//Acesso Remote (WebService)
mRepository.remote()?.getRetrofit()?.create(API::class.java)
Room Persistence Library: https://developer.android.com/topic/libraries/architecture/room.html
Retrofit: http://square.github.io/retrofit/
MVP: https://medium.com/android-dev-br/desmistificando-o-mvc-e-mvp-no-android-abe927d01df7
RxAndroid : https://github.com/ReactiveX/RxAndroid
Butter Knife : http://jakewharton.github.io/butterknife/
Dagger 2 : https://google.github.io/dagger/
