refresh on any key change by default

This commit is contained in:
Vincent Breitmoser
2018-07-02 13:25:18 +02:00
parent f3c4b15b17
commit a31c35a4ad
2 changed files with 7 additions and 1 deletions

View File

@@ -43,6 +43,10 @@ public class DatabaseNotifyManager {
contentResolver.notifyChange(uri, null);
}
public static Uri getNotifyUriAllKeys() {
return BASE_URI;
}
public static Uri getNotifyUriMasterKeyId(long masterKeyId) {
return BASE_URI.buildUpon().appendPath(Long.toString(masterKeyId)).build();
}

View File

@@ -4,9 +4,11 @@ package org.sufficientlysecure.keychain.ui.keyview;
import android.arch.lifecycle.LiveData;
import android.arch.lifecycle.ViewModel;
import android.content.Context;
import android.net.Uri;
import org.sufficientlysecure.keychain.livedata.GenericLiveData;
import org.sufficientlysecure.keychain.livedata.GenericLiveData.GenericDataLoader;
import org.sufficientlysecure.keychain.provider.DatabaseNotifyManager;
/** A simple generic ViewModel that can be used if exactly one field of data needs to be stored. */
@@ -15,7 +17,7 @@ public class GenericViewModel extends ViewModel {
public <T> LiveData<T> getGenericLiveData(Context context, GenericDataLoader<T> func) {
if (genericLiveData == null) {
genericLiveData = new GenericLiveData<>(context, null, func);
genericLiveData = new GenericLiveData<>(context, DatabaseNotifyManager.getNotifyUriAllKeys(), func);
}
// noinspection unchecked
return genericLiveData;