Status Update
Comments
je...@google.com <je...@google.com>
as...@google.com <as...@google.com> #2
be...@google.com <be...@google.com> #3
be...@ridewithvia.com <be...@ridewithvia.com> #4
private void refreshAllLiveData() {
AppDataBase YOUR_DATABASE_WHICH_YOU_BUILD = .....
SupportSQLiteDatabase writableDatabase = YOUR_DATABASE_WHICH_YOU_BUILD.getOpenHelper().getWritableDatabase();
//get the database count;
Cursor cursor = writableDatabase.query("SELECT count(*) FROM sqlite_master WHERE type = 'table' AND name != 'android_metadata' AND name != 'room_master_table';");
int tableCount = 0;
while(cursor.moveToNext()) {
tableCount = cursor.getInt(0);
}
for (int i = 0; i < tableCount; i++) {
//update version table with the incremented count because room modification log stores tables with ids instead of names
writableDatabase.execSQL("INSERT OR REPLACE INTO room_table_modification_log VALUES(null, "+(i)+")");
}
YOUR_DATABASE_WHICH_YOU_BUILD.getInvalidationTracker().refreshVersionsAsync();
}
-----
This is a workaroud for refreshing all live datas, I still prefer to use a proper API you implemented.
Thanx
lp...@google.com <lp...@google.com>
lp...@google.com <lp...@google.com> #5
lp...@google.com <lp...@google.com> #6
(I think part of the reason this logic might get confused is because in bytecode this method has the compose compiler generated parameters for $composer and $changed, whereas these don't exist in source, but I don't see what changed in this space between 1.9.20 and 2.0.20)
js...@google.com <js...@google.com> #7
I don't see what changed in this space between 1.9.20 and 2.0.20
One major change between two is whether K2 Lint is used by default or not, and I remember there was/is an issue about binary resolution, in particular, when there are synthetic parameters generated by Compose compiler plugin. I'm not entirely sure it's properly addressed at that time or it still remains.
js...@google.com <js...@google.com> #8
I remember there was/is an issue about binary resolution, in particular, when there are synthetic parameters generated by Compose compiler plugin.
I meant this one:
js...@google.com <js...@google.com> #9
As a note, reproduced (thanks!):
.../ComposeLint86/ComposeLint86/app/src/main/java/com/example/composelint86/MainActivity.kt:35: Error: produceState calls should assign value inside the producer lambda [ProduceStateDoesNotAssignValue from androidx.compose.runtime]
val state = produceState("No-one", key1 = Unit) {
~~~~~~~~~~~~
Explanation for issues of type "ProduceStateDoesNotAssignValue":
produceState returns an observable State using values assigned inside the
producer lambda. If the lambda never assigns (i.e value = foo), then the
State will never change. Make sure to assign a value when the source you
are producing values from changes / emits a new value. For sample usage see
the produceState documentation.
Vendor: Jetpack Compose
Identifier: androidx.compose.runtime
It's supposed to be:
@Composable
fun <T> produceState(
initialValue: T,
key1: Any?,
producer: suspend ProduceStateScope<T>.() -> Unit
): State<T> { ... }
but resolved to:
@Composable
fun <T> produceState(
initialValue: T,
producer: suspend ProduceStateScope<T>.() -> Unit
): State<T> { ... }
js...@google.com <js...@google.com> #10
FYI, another instance of wrong resolution:
Description
Jetpack Compose version: 2024.09.02
Upgrading from 2024.09.00 to 02 has triggered a false positive on the following snippet with
produceState