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:
Peter Serwylo 2016-12-19 12:56:07 +11:00
parent f4c03c6baa
commit bdde162f56
2 changed files with 5 additions and 2 deletions

View File

@ -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);
}

View File

@ -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.