Assigned
Status Update
Comments
yb...@google.com <yb...@google.com> #2
We don't support cross-process invalidations yet.
de...@gmail.com <de...@gmail.com> #3
At least , add a "refresh all observables" function to alpha4 ? i am trying to implement it by myself with your InvalidationTracker class
de...@gmail.com <de...@gmail.com> #4
Okey, I made it and created a method to invalidate all observables below;
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
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
Description
Version used: 1.3.1
Devices/Android versions reproduced on: API 26
If this is a bug in the library, we would appreciate if you could attach:
There is a bug when using `ConcatAdapter` to merge 3 adapters where top and bottom adapter is using `ListAdapter` and one adapter in the middle being `RecyclerView.Adapter`.
```// Declaration
private lateinit var includedExchangeAdapter: ExchangeAdapter
private lateinit var excludedExchangeAdapter: ExchangeAdapter
private val middleAdapter = ExchangeMidAdapter {
alertDialog.show()
}```
```// OnCreate or OnViewCreated
includedExchangeAdapter = ExchangeAdapter(...
excludedExchangeAdapter = ExchangeAdapter(...
concatAdapter = ConcatAdapter(includedExchangeAdapter, excludedExchangeAdapter)
recyclerView.adapter = concatAdapter```
```// States
is ExchangeState.FetchLoading -> {
logTxtV.text = null
swipeRefreshLayout.isRefreshing = true
includedExchangeAdapter.submitList(state.includedList) // Cache (can be empty)
excludedExchangeAdapter.submitList(state.excludedList) // Cache (can be empty)
// ListAdapter can be slow when updating its `currentList` after calling `submitList`
// hence we used the actual data of state here for correct validation
addOrRemovedMiddleAdapter(state.includedList, state.excludedList)
}
is ExchangeState.FetchSuccess -> {
swipeRefreshLayout.isRefreshing = false
includedExchangeAdapter.submitList(state.includedList)
excludedExchangeAdapter.submitList(state.excludedList)
// ListAdapter can be slow when updating its `currentList` after calling `submitList`
// hence we used the actual data of state here for correct validation
addOrRemovedMiddleAdapter(state.includedList, state.excludedList)
// Since this is a free limited API, data can be empty
if (state.includedList.isEmpty() && state.excludedList.isEmpty())
logTxtV.setText(R.string.no_data)
}```
We only show the middle adapter if the bottom adapter (excludedExchangeAdapter) is not empty.
```// Adding or Removing of adapter in the middle
private fun addOrRemovedMiddleAdapter(
includedList: List<ExchangeDataDomain>?,
excludedList: List<ExchangeDataDomain>?
) {
if (includedList.isNullOrEmpty().not() && excludedList.isNullOrEmpty()) {
concatAdapter.removeAdapter(middleAdapter)
}
else {
concatAdapter.addAdapter(1, middleAdapter)
}```
}```
This only happens when the load states returns empty hence the `ConcatAdapter` will show empty specially if it is the very first time fetching the data so load state has no cache yet, then got populated later in the success state. The `RecyclerView` initial visible items are middle adapter and bottom (excluded) adapter and you need to scroll downwards first in order to saw top adapter (included).
- A screenrecord or screenshots showing the issue (if UI related).
Please see the attached file for screenshots.