Notify when new categories are available, old ones are no longer available.
Whether a category is "available" or not is not a function of whether it is in the category table or not. Rather, it is a function of whether there are any active apps/apks which are in that category. Thus, don't notify after inserting a category (the notification was wrong anyway as it was trying to notify the AppProvider Uri instead of the ContentProvider one). Instead, do it after a repo update is complete.
This commit is contained in:
parent
f4c03c6baa
commit
bdde162f56
@ -134,7 +134,7 @@ public class CategoryProvider extends FDroidProvider {
|
||||
MATCHER.addURI(getAuthority(), PATH_ALL_CATEGORIES, CODE_LIST);
|
||||
}
|
||||
|
||||
private static Uri getContentUri() {
|
||||
static Uri getContentUri() {
|
||||
return Uri.parse("content://" + getAuthority());
|
||||
}
|
||||
|
||||
@ -239,7 +239,9 @@ public class CategoryProvider extends FDroidProvider {
|
||||
@Override
|
||||
public Uri insert(@NonNull Uri uri, ContentValues values) {
|
||||
long rowId = db().insertOrThrow(getTableName(), null, values);
|
||||
getContext().getContentResolver().notifyChange(AppProvider.getCanUpdateUri(), null);
|
||||
// Don't try and notify listeners here, because it will instead happen when the TempAppProvider
|
||||
// is committed (when the AppProvider and ApkProviders notify their listeners). There is no
|
||||
// other time where categories get added (at time of writing) so this should be okay.
|
||||
return getCategoryIdUri(rowId);
|
||||
}
|
||||
|
||||
|
@ -253,6 +253,7 @@ public class TempAppProvider extends AppProvider {
|
||||
|
||||
getContext().getContentResolver().notifyChange(AppProvider.getContentUri(), null);
|
||||
getContext().getContentResolver().notifyChange(ApkProvider.getContentUri(), null);
|
||||
getContext().getContentResolver().notifyChange(CategoryProvider.getContentUri(), null);
|
||||
} finally {
|
||||
db.endTransaction();
|
||||
db.execSQL("DETACH DATABASE " + DB); // Can't be done in a transaction.
|
||||
|
Loading…
x
Reference in New Issue
Block a user