Mathbl
01/31/2018, 3:15 PMlateinit var
ex.:
@BindView(R.id.swipe_refresh_layout) lateinit var swipeRefreshLayout: SwipeRefreshLayout
, that's fine right?
To be able to show the loading animation of SwipeRefreshLayout programmatically, I use this method:
fun showLoading() {
<http://swipeRefreshLayout.post|swipeRefreshLayout.post>({
swipeRefreshLayout.isRefreshing = true
})
}
This is inside a fragment, inside a viewpager/tabs. Thing is, I have a case (I supposed that it's because I unbind in onDestroyView) where sometimes the swipeRefreshLayout variable is null once inside the post block. It seems it has to do with the tab/fragment not being visible so I thought I'd check inside post if (isAdded) but no luck there. Any idea?Aditya
02/01/2018, 1:56 PMnino
02/01/2018, 4:42 PMagrosner
02/01/2018, 4:52 PMmansonheart
02/01/2018, 9:07 PMkotlinx.coroutines
. Channel in the listener has sClosedForSend
is true. Can i keep channel active? Sample:katien
02/02/2018, 12:17 AMViral
02/02/2018, 6:06 AMAlisson Morais
02/02/2018, 10:22 AMnicopasso
02/02/2018, 1:28 PM@Entity
data class Customer(
@PrimaryKey
var id: Int,
var name: String,
var paymentAccounts: List<PaymentAccount>,
var addresses: List<Address> )
What we want to acheive is a generic solution for TypeConverters.
This is the first not-a-100%-correct solution we came up with:
fun <T> fromList(list: T?): String? {
list?.let {
val gson = Gson()
val type = object: TypeToken<T>(){}.type
val json = gson.toJson(list, type)
return json
} ?: run {
return null
}
}
fun <T> toList(json: String?): T? {
json?.let {
val gson = Gson()
val type = object: TypeToken<T>(){}.type
val list = gson.fromJson<T>(json, type)
return list
} ?: run {
return null
}
}
@TypeConverter
fun fromPaymentAccountList(list: List<PaymentAccount>?) = fromList(list)
@TypeConverter
fun toPaymentAccountList(json: String?) = toList<List<PaymentAccount>>(json)
@TypeConverter
fun fromAddressList(list: List<Address>?) = fromList(list)
@TypeConverter
fun toAddressList(json: String?) = toList<List<Address>>(json)
With this approach we have only one big problem: no compilation errors, no other errors BUT all the properties in the data class are converted to `LinkedTreeMap`s instead of proper objects.
Our Customer class fortunately is not so complicated but we have other classes with list of objects and each object contains another list of other objects. It makes no sense to me to write a converter for each type that I want to persist with Room. Is there a solution to this problem?
p.s.: we've also tried to create a generic TypeConverter method by using a reified generic with inline functions but at build time, we had multiple convertion errorseric
02/02/2018, 4:36 PMTypeToken<T>(){}
will only be a TypeToken<Object> because of type erasure.Aditya
02/02/2018, 7:54 PMVir
02/03/2018, 8:40 PMVir
02/03/2018, 8:44 PMkingsley
02/04/2018, 9:08 AMX
) on that red dot if everything is indeed setup properlyTamás
02/04/2018, 9:52 PMelaborate tissue
02/05/2018, 11:34 AMGreg Stepniewski
02/05/2018, 1:44 PMasync(UI) {
delay(10)
viewState.onNext(...)
}
I guess an alternative to delay would be bg { Thread.sleep(10) }
?oday
02/05/2018, 2:10 PMwithoutclass
02/05/2018, 4:21 PMSlackbot
02/06/2018, 7:52 AMnino
02/06/2018, 8:11 AMclockworkant
02/06/2018, 10:08 AMwithLatestFrom(o1, o2)
temp_man
02/06/2018, 5:12 PMSlackbot
02/06/2018, 9:25 PMManjee
02/07/2018, 12:54 AMaris
02/07/2018, 3:25 PMaris
02/07/2018, 3:26 PMaris
02/07/2018, 3:27 PMdgngulcan
02/07/2018, 3:45 PMsakaroz
02/07/2018, 5:12 PMsakaroz
02/07/2018, 5:12 PMmiha-x64
02/07/2018, 5:15 PM