Add contextual card dismissal implementation
When users clcik on the remove button in dismissal view, the card should be marked as dismissed in the database, and the UI should be refreshed. Bug: 113783548, 119594116 Test: robotests Change-Id: I980600c4c0753ad5abc52ae63bac7196a4b818f1
This commit is contained in:
committed by
Yi-Ling Chuang
parent
4942fd2aff
commit
1e24cb02dc
@@ -24,8 +24,11 @@ import android.content.ContentProviderClient;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.database.ContentObserver;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -60,6 +63,19 @@ public class ContextualCardLoader extends AsyncLoaderCompat<List<ContextualCard>
|
||||
mContext = context.getApplicationContext();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStartLoading() {
|
||||
super.onStartLoading();
|
||||
mContext.getContentResolver().registerContentObserver(CardContentProvider.URI,
|
||||
false /*notifyForDescendants*/, mObserver);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStopLoading() {
|
||||
super.onStopLoading();
|
||||
mContext.getContentResolver().unregisterContentObserver(mObserver);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDiscardResult(List<ContextualCard> result) {
|
||||
|
||||
@@ -184,4 +200,14 @@ public class ContextualCardLoader extends AsyncLoaderCompat<List<ContextualCard>
|
||||
}
|
||||
return -1L;
|
||||
}
|
||||
|
||||
private final ContentObserver mObserver = new ContentObserver(
|
||||
new Handler(Looper.getMainLooper())) {
|
||||
@Override
|
||||
public void onChange(boolean selfChange) {
|
||||
if (isStarted()) {
|
||||
forceLoad();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user