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:
Emily Chuang
2018-11-14 14:57:35 +08:00
committed by Yi-Ling Chuang
parent 4942fd2aff
commit 1e24cb02dc
8 changed files with 159 additions and 15 deletions

View File

@@ -209,16 +209,19 @@ public class CardDatabaseHelper extends SQLiteOpenHelper {
* Mark a specific ContextualCard with dismissal flag in the database to indicate that the
* card has been dismissed.
*
* @param cardName the card name of the ContextualCard which is dismissed by user.
* @return updated row number
* @param context Context
* @param cardName The card name of the ContextualCard which is dismissed by user.
* @return The number of rows updated
*/
public int markContextualCardAsDismissed(String cardName) {
final SQLiteDatabase database = this.getWritableDatabase();
public int markContextualCardAsDismissed(Context context, String cardName) {
final SQLiteDatabase database = getWritableDatabase();
final ContentValues values = new ContentValues();
values.put(CardColumns.CARD_DISMISSED, 1);
final String selection = CardColumns.NAME + "=?";
final String[] selectionArgs = {cardName};
final int rowsUpdated = database.update(CARD_TABLE, values, selection, selectionArgs);
database.close();
context.getContentResolver().notifyChange(CardContentProvider.URI, null);
return rowsUpdated;
}
}