Create an App which shows the GitHub users in a list.
[Module: app]
- User Interface (UI) Display
- Use MVVM architecture.
- There are two pages,
ListFragment
andUserDetailFragment
, which can be switched through NAVIGATION. - The drop-down list will reload the data, and swipe up will load the data until the number of data reaches 100.
- Use the Glide library to load images.
[Module: github-user-sdk]
- GitHub user API wrapper, used via
UserInfoRepository
. - WebAPI is implemented by Volley and Gson libraries.
suspend fun getUserDetail(userName: String, listener: ResultListener<UserDetail>)
suspend fun getUserList(since: Int, perPage: Int, listener: ResultListener<List<User>>)
Volley
Gson
Coroutines Codelab
The dependency injection relationship must be defined in MyApplication first.
class MyApplication : Application(){
private val viewModelModule = module{
viewModel{ YourViewModel(get())} //This 'get()' is the repository that will be injected into the view model
}
private val repoModule = module{
single{ YourRepository(get())} //This 'get()' is the androidContext that will be passed into the view model
}
override fun onCreate() {
super.onCreate()
startKoin {
androidContext(this@MultiLanguagesApplication)
modules(
listOf(
viewModelModule,
repoModule
)
)
}
}
}
- File
UserInfoRepositoryTest