From 15ff313e56d6687cb8f6f04c1f4525f2b6e7e299 Mon Sep 17 00:00:00 2001 From: "diana.iacos" Date: Mon, 27 May 2019 07:43:43 +0000 Subject: [PATCH] Bug 1553474 - "Remove bookmark" option is displayed for pages that were not bookmarked; r=petru Differential Revision: https://phabricator.services.mozilla.com/D32664 --HG-- extra : moz-landing-system : lando --- .../activitystream/homepanel/stream/TopPanelRow.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/stream/TopPanelRow.java b/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/stream/TopPanelRow.java index 6bdbd1e29675..8146ce78a4fd 100644 --- a/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/stream/TopPanelRow.java +++ b/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/stream/TopPanelRow.java @@ -126,7 +126,7 @@ public class TopPanelRow extends StreamViewHolder { if (isPinned || !urls.contains(baseUrl)) { final Object[] originalColumns = new Object[] { cursor.getLong(cursor.getColumnIndex(BrowserContract.Combined._ID)), - cursor.getLong(cursor.getColumnIndex(BrowserContract.Combined.BOOKMARK_ID)), + getBookmarkId(cursor), cursor.getLong(cursor.getColumnIndex(BrowserContract.Combined.HISTORY_ID)), cursor.getString(cursor.getColumnIndex(BrowserContract.Combined.URL)), cursor.getString(cursor.getColumnIndex(BrowserContract.Combined.TITLE)), @@ -143,6 +143,12 @@ public class TopPanelRow extends StreamViewHolder { return filteredCursor; } + private Long getBookmarkId(Cursor cursor) { + // If the value of BOOKMARK_ID column it's null that means the url is not bookmarked + final int columnIndex = cursor.getColumnIndex(BrowserContract.Combined.BOOKMARK_ID); + return cursor.isNull(columnIndex) ? null : cursor.getLong(columnIndex); + } + private boolean isTopSitePinned(final int topSiteType) { return topSiteType == BrowserContract.TopSites.TYPE_PINNED; }