Felipe Tavares
07/23/2019, 2:15 PMmoizest89
07/23/2019, 3:27 PMsealed
class like values?
I’ve found examples with Enum
class but not with sealed 😕vapoyan
07/24/2019, 6:43 AMdakinne
07/24/2019, 9:30 AMGilles Braun
07/24/2019, 12:14 PMStefan
07/24/2019, 12:24 PMKatie Levy
07/24/2019, 10:33 PMJoaquim Ley
07/25/2019, 1:16 PMFlowable<List<Model>>
— This Model
is a data class (hence I would assume equals()
works as expected). But for some reason I get multiple notifications on a db change (I’ve mapped it with distinctUntilChanged()
)
This question [1] is addressing the same but I’ve had no success with the suggestions, and the accepted answer is referencing exactly Object.equals
, I’ve also tried [2] using the suggestion as the distinct predicate, but with no success
Thank you in advance for your time
---
[1] https://stackoverflow.com/questions/48585491/room-flowable-invokes-multiple-times
[2] https://stackoverflow.com/questions/35272761/how-to-compare-two-arrays-in-kotlin/48769967#48769967Slackbot
07/25/2019, 10:33 PMmatt tighe
07/25/2019, 11:32 PMsealed class Animal
object Dog : Animal()
object Cat : Animal()
@Entity
data class Person(
val name: String
val favoriteTypeOfAnimal: Animal
)
writing a type converter doesn’t seem to do itSantosh Sharma
07/26/2019, 7:22 AMSlackbot
07/26/2019, 10:16 AMIve Vasiljevic
07/26/2019, 8:54 PMDialogFragment
with Navigation Component. I am aware that only two months ago Android introduced support for DialogFragments with Navigation Component, but if anyone has done it successfully please provide an example. Thank you!tseisel
07/27/2019, 3:40 PMObserver
interface for LiveData
only has one observe
function, why should we write Observer { ... }
and not directly a lambda ?
Also, wouldn't it be nice if the parameter of the Observer
lambda would take the nullability of the T
value from LiveData into account ?
val nonNullable: LiveData<String> = ...
nonNullable.observe(this) { value: String -> ... }
val nullable: LiveData<String?> = ...
nullable.observe(this) { value: String? -> ... }
Adam Powell
07/27/2019, 4:11 PMjw
07/28/2019, 1:24 AMandrew
07/28/2019, 2:14 AMashwini
07/28/2019, 8:08 AMMainCoroutineRule
to use the TestCoroutineScope
and relying on the latest Coroutine Testing Library
Here is the test :
@ExperimentalCoroutinesApi
@Test
fun testHomeIsLoadedWithShowsAndFavorites() {
runBlocking {
// Stubbing network and repository calls
whenever(tvMazeApi.getCurrentSchedule("US", currentDate))
.thenReturn(getFakeEpisodeList())
whenever(favoriteShowsRepository.allFavoriteShowIds())
.thenReturn(arrayListOf(1, 2))
}
mainCoroutineRule.runBlockingTest {
// call home viewmodel
homeViewModel.onScreenCreated()
// Check if loader is shown
assertThat(LiveDataTestUtil.getValue(homeViewModel.getHomeViewState())).isEqualTo(Loading)
// Observe on home view state live data
val homeViewState = LiveDataTestUtil.getValue(homeViewModel.getHomeViewState())
// Check for success data
assertThat(homeViewState is Success).isTrue()
val homeViewData = (homeViewState as Success).homeViewData
assertThat(homeViewData.episodes).isNotEmpty()
// compare the response with fake list
assertThat(homeViewData.episodes).hasSize(getFakeEpisodeList().size)
// compare the data and also order
assertThat(homeViewData.episodes).containsExactlyElementsIn(getFakeEpisodeViewDataList(true)).inOrder()
}
}
The other test is almost similar which tests for Shows without favorites. I am trying to test HomeViewModel
method as:
fun onScreenCreated() {
homeViewStateLiveData.value = Loading
val coroutineExceptionHandler = CoroutineExceptionHandler { _, exception ->
onError(exception)
}
viewModelScope.launch(coroutineExceptionHandler) {
// Get shows from network and favorites from room db on background thread
val favoriteShowsWithFavorites = withContext(<http://Dispatchers.IO|Dispatchers.IO>) {
val favoriteShowIds = favoriteShowsRepository.allFavoriteShowIds()
val episodes = tvMazeApi.getCurrentSchedule(COUNTRY_US, currentDate)
getShowsWithFavorites(episodes, favoriteShowIds)
}
// Return the combined result on main thread
withContext(Dispatchers.Main) {
onSuccess(favoriteShowsWithFavorites)
}
}
}
I cannot find the actual cause of why the tests if run separatly are passing and when the complete class is tested, one of them is failing. Pls help if I am missing somethingMagnus W
07/28/2019, 3:42 PMval fixedPath = "/storage/emulated/0/AnkiDroid/collection.media/主人_B_zh.mp3"
val myURI = Uri.fromFile(File(fixedPath)
I'm trying to load a file to my mediaPlayer directly using this URI, bit I get permission denied
Reference here: https://developer.android.com/preview/privacy/scoped-storage#opt-out-of-filtered-viewlocke
07/29/2019, 11:27 PMMagnus W
07/30/2019, 6:51 PMjava.lang.RuntimeException: Unable to start activity ComponentInfo{cafe.gophers.mynavigationapplication/cafe.gophers.mynavigationapplication.MainActivity}: java.lang.SecurityException: Permission not granted for: CardContentProvider.query /notes (cafe.gophers.mynavigationapplication)
I have added the permissions I found on github for CardContentProvider, but that didn't workIve Vasiljevic
07/31/2019, 9:26 AMNikolai
08/01/2019, 4:06 PMNir Golan
08/01/2019, 6:38 PMgirafferson
08/01/2019, 10:12 PMDaniel Rodak
08/02/2019, 6:40 AMMockito
. When I want to verify that a method with function as parameter was called, it always complains about strange difference. The difference is in the first brackets, it's like contex of the test method. Using Captors
didn't help, because I mock the injected interface it will return nullandrew
08/04/2019, 3:21 PMjames
08/05/2019, 1:16 AMandroid:text="@{viewModel.message(context::getString)}"
where my viewModel
class has a function like:
fun message(getStringFunc: (Int) -> String)
Slackbot
08/05/2019, 7:02 AMRiushin
08/05/2019, 2:42 PMRiushin
08/05/2019, 2:42 PMPablichjenkov
08/05/2019, 6:43 PMRiushin
08/06/2019, 8:46 AMPablichjenkov
08/06/2019, 2:59 PMuserAgent
. You have to send the headers manually when you call the load() method.
The only type of headers the system handles for you is the Cookies. If you use the CookieManager you can inject your Cookies there and it will take care of the rest. The benefits is that the same CookieManager is a Singleton used by Chrome App too. So you can re-use Cookies-Login Tokens between your app and Chrome seamlessly.
Cookies are saved by url hostname. If the redirect url has a different hostname, then the original request Cookies are not sent.
With the rest of the header types am not sure whats the behavior but is probably the same as the cookies. Maybe for security reasons they do not transfer the original Url headers to the redirected Url.
In such a case you would have to do it on your own.