Akbar
09/05/2019, 6:50 AMAkbar
09/05/2019, 10:10 AMam414
09/05/2019, 12:21 PMdata class Order(
@SerializedName("data")
val data: OData? = null,
@SerializedName("success")
val success: Boolean? = null,
@SerializedName("message")
var message: String? = null,
@SerializedName("order_item")
val orderItem: List<OrderItem>? = null
)
kevin.cianfarini
09/05/2019, 7:24 PMFlow
as the bridge between a VM and a fragment, how can I ensure that the callback I use for the flow is initialized before I need It? The way I'm approaching it now seems like an antipattern. private var loadedPosts: List<Post> = emptyList()
private lateinit var loadedPostsCallback: LoadedPostsCallback
val posts: Flow<List<Post>> = callbackFlow {
val callback = object : LoadedPostsCallback {
override fun setLoadedPosts(posts: List<Post>) {
loadedPosts = loadedPosts + posts
offer(loadedPosts)
}
}
loadedPostsCallback = callback
awaitClose()
}
Ronak Android
09/06/2019, 6:57 AMNeil
09/06/2019, 2:12 PMKevin Janvier Chinabalire
09/06/2019, 6:53 PMmatt tighe
09/06/2019, 8:46 PMViewModel
that converts a flow from my DB into a livedata for the view layer. the VM extends coroutine scope.
viewState.postValue(ViewState(loading = true))
this.launch {
repository.observeAll().collect { observedList ->
viewState.postValue(ViewState(list = observedList))
}
}
and then in my test I’d like to do something like this:
val expectedList = listOf(Thing())
coEvery { mockRepo.observeAll() } returns flow {
emit(expectedList)
}
viewModel.submitAction(Action.Refresh)
coVerify {
mockRepo.observeAll()
mockViewStateObserver.onChanged(ViewState(loading = true, list = listOf()))
mockViewStateObserver.onChanged(ViewState(loading = false, list = expectedList))
}
but the coVerify
coroutine completes before the second update to the LiveData
. anyone have suggestions besides injecting the test scope or delaying?Sam
09/09/2019, 10:51 AMjava.lang.ClassCastException: java.lang.Object cannot be cast to String[]
I want to cast Object to Array of Strings.
class BlockToday(val type: TodayType,var data:Any)
enum class TodayType{
BANNER,EVENTS,CATEGORIES,TOP_SALES
}
val images = arrayListOf<String>()
val block = BlockToday(TodayType.BANNER,images)
=> bindBanner(block.data)
fun bindBanner(data:Any){
val images = data as ArrayList<String> => Crash
}
Any ideas to resolve this problem. ??? ThanksAkbar
09/09/2019, 1:00 PMSam
09/10/2019, 8:49 AMarrayListOf
as parameter , only ArrayList can accept to use as parameter
1. class CategoriesViewHolder(context: Context,categories:ArrayList<Category>){}
2. val categories = arrayListOf<String>()
ThanksDoru N.
09/10/2019, 10:25 AM@BindingAdapter("goneUnless")
fun goneUnless(view: View, visible: Boolean) {
view.visibility = if (visible) VISIBLE else GONE
}
In the layout, it looks like this: app:goneUnless="@{!user.isAdult}"
The value supplied to this binding method is a LiveData which, obviously, its initial value is null.
The problem is that user property being initially null, databinding evaluates user.isAdult to false -> negated -> turns to true, but I would like the View to be gone at first, and only change visibility after I assign a value to user LiveData.
Any thoughts on handling this in a more generic manner?Slackbot
09/10/2019, 11:48 AMSergio C.
09/10/2019, 8:41 PMSam
09/11/2019, 7:07 AM<https://github.com/greenrobot/EventBus>
=> 2 years without update => Do you think it dead? Or anything can do the same things EventBus but written on pure Kotlin ???Adriano Celentano
09/11/2019, 8:39 AMrobjperez
09/11/2019, 9:56 AMJOHSE
09/11/2019, 8:51 PMfal
09/11/2019, 9:27 PMmukesh.kumar
09/11/2019, 9:31 PMBruno Garcia
09/12/2019, 12:03 AMandroid.compileOptions
But with kotlin DSL I get an error (there’s no setter):Sam
09/13/2019, 9:35 AMColor.White
Sam
09/13/2019, 10:27 AMapply plugin: 'com.android.library'
, right ?Kulwinder Singh
09/13/2019, 11:52 AMisSuccess
to see if post
or any other request is success or not. so thats why it return result OK(200) even if i have sent invalid values,
so in above extension function on Response
can i check isSuccess
variable from original json
?
Note: this extension function is called on Response
from retrofitSergio C.
09/14/2019, 4:32 PMz3ntu
09/15/2019, 2:32 PMMohamed Ibrahim
09/15/2019, 8:06 PMSam
09/16/2019, 6:37 AMSam
09/16/2019, 9:29 AMListener
, but I only want to implement one or two methods, not all of methods.
So what should I need to change ?
ThanksSlackbot
09/16/2019, 2:33 PM