Fixed
Status Update
Comments
fs...@gmail.com <fs...@gmail.com> #2
Trying to find a temporary work-a-round I found that `MediatorLiveData` also doesn't work, as it internally also calls observeForever/removeObserver.
The only work-a-round I found is very hacky and only works on this specific scenario is to `post` to a Handler to `removeObserver` later.
It works only on this case because the background processing only happens when the network call is successful (a.k.a. the LiveData won't values anymore).
The only work-a-round I found is very hacky and only works on this specific scenario is to `post` to a Handler to `removeObserver` later.
It works only on this case because the background processing only happens when the network call is successful (a.k.a. the LiveData won't values anymore).
yb...@google.com <yb...@google.com> #3
Thank you for a report!
Yeah, your work around is fine for now. This is going to be fixed in alpha-9.
Yeah, your work around is fine for now. This is going to be fixed in alpha-9.
de...@gmail.com <de...@gmail.com> #4
Also, you can try go down to alpha-5, it may be fine there.
yb...@google.com <yb...@google.com> #5
hi "se...@google.com"
it seems that rolling back to alpha-5 solved it, and I'll be looking forward to alpha-9.
Is this bug brand new or something the team was already aware of?
thanks.
it seems that rolling back to alpha-5 solved it, and I'll be looking forward to alpha-9.
Is this bug brand new or something the team was already aware of?
thanks.
yb...@google.com <yb...@google.com> #6
No, we weren't aware of that. But we added tests for underlying issue.
yb...@google.com <yb...@google.com> #7
Great. Super happy to help!
Description
Version used: 1.0
Devices/Android versions reproduced on: NA
I have one entity that contains a set of enums. For example:
@Entity
data class Person(
@field:PrimaryKey val id: Int,
val name: String,
val favouriteDays: Set<Day>)
enum class Day {
MONDAY,
TUESDAY,
WEDNESDAY,
THURSDAY,
FRIDAY,
SATURDAY,
SUNDAY
}
I want to store this entity in a single table. In many cases, especially with enums, we could use a single bit mask to save the list as a number in the database.
Here's one example of what I wanted to do:
object DayCollectionTypeConverter {
@JvmStatic
@TypeConverter
fun daysConverter(days: Set<Day>): Int {
var value = 0
for (day in days) {
value += (1 shl day.ordinal)
}
return value
}
@JvmStatic
@TypeConverter
fun daysConverter(value: Int): Set<Day> {
val set = mutableSetOf<Day>()
for (day in Day.values()) {
if (value and 1 shl day.ordinal != 0) {
set.add(day)
}
}
return set
}
}
That code doesn't work as intended because @TypeConverter would allow me to convert one Day object, but not a collection (or set, list, etc) of Days.
I suggest a new annotation is created so the developer can specify how to save a Collection into a single column in the same table.