This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sdfdsfsf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class RealDeepLinkLauncher(val topActivityProvider: Provider<Activity>) : DeepLinkLauncher { | |
| override fun launch(deepLink: HttpUrl) { | |
| if (deepLink.pathSize() == 2) { | |
| val fullRepoPath = deepLink.pathSegments()[0] + "/" + deepLink.pathSegments()[1] | |
| RepoDetailActivity.start(topActivityProvider.get(), fullRepoPath) | |
| return | |
| } | |
| if (deepLink.pathSize() == 1) { | |
| val login = deepLink.pathSegments()[0] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ViewModelFactory @Inject constructor(val providersMap: Map<Class<*>, Provider<ViewModel>>) | |
| : ViewModelProvider.Factory { | |
| override fun <T : ViewModel> create(aClass: Class<T>): T { | |
| val provider = providersMap[aClass] ?: throw IllegalArgumentException("No $aClass provider") | |
| return provider.get() as T | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Test | |
| fun writePostAndReadInList() { | |
| val testObserver = postDao.getAll().test() | |
| testObserver.assertValue { it.isEmpty() } | |
| val post = TestUtil.createPost(id = 42) | |
| postDao.insert(post) | |
| testObserver.assertValue { it.size == 1 } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Contacts(val names: List<String>) | |
| data class Parameters(val namePrefix: String = "") | |
| class GetContactsUseCase { | |
| fun loadContacts(parameters: Parameters, onLoad: (Contacts) -> Unit) { /* Implementation detail */ } | |
| } | |
| class ContactsViewModel(val getContactsUseCase: GetContactsUseCase) : ViewModel() { | |
| // TODO When to call getContactsUseCase.loadContacts? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ContactsViewModel(val getContactsUseCase: GetContactsUseCase) : ViewModel() { | |
| private val contactsLiveData = MutableLiveData<Contacts>() | |
| init { | |
| getContactsUseCase.loadContacts(Parameters()) { contactsLiveData.value = it } | |
| } | |
| fun contacts(): LiveData<Contacts> = contactsLiveData | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ContactsViewModel(val getContactsUseCase: GetContactsUseCase) : ViewModel() { | |
| private val contactsLiveData by lazy { | |
| val liveData = MutableLiveData<Contacts>() | |
| getContactsUseCase.loadContacts(Parameters()) { liveData.value = it } | |
| return@lazy liveData | |
| } | |
| fun contacts(): LiveData<Contacts> = contactsLiveData | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class GetContactsUseCase { | |
| fun loadContacts(parameters: Parameters): Flowable<Contacts> { /* Implementation detail */ } | |
| } | |
| class ContactsViewModel(val getContactsUseCase: GetContactsUseCase) : ViewModel() { | |
| fun contacts(parameters: Parameters): LiveData<Contacts> { | |
| return getContactsUseCase.loadContacts(parameters).toLiveData() | |
| } | |
| } |
OlderNewer