From d75fa4f4ee37487e77a3c4142f2ba3881c04d72c Mon Sep 17 00:00:00 2001 From: Manuel Martin Date: Tue, 5 Nov 2019 00:41:14 +0100 Subject: [PATCH] Remove the ignore flag that prevented the update after deleting an item (#2145) --- .../vrbrowser/ui/views/BookmarksView.java | 16 ++-------------- .../mozilla/vrbrowser/ui/views/HistoryView.java | 12 ++---------- 2 files changed, 4 insertions(+), 24 deletions(-) diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/BookmarksView.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/BookmarksView.java index c1ae0c65c..e35e9d268 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/BookmarksView.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/BookmarksView.java @@ -55,7 +55,6 @@ public class BookmarksView extends FrameLayout implements BookmarksStore.Bookmar private BookmarksBinding mBinding; private Accounts mAccounts; private BookmarkAdapter mBookmarkAdapter; - private boolean mIgnoreNextListener; private ArrayList mBookmarksViewListeners; private CustomLinearLayoutManager mLayoutManager; @@ -113,9 +112,6 @@ private void initialize(Context aContext) { mBinding.setIsSignedIn(mAccounts.isSignedIn()); mBinding.setIsSyncEnabled(mAccounts.isEngineEnabled(SyncEngine.Bookmarks.INSTANCE)); - updateBookmarks(); - SessionStore.get().getBookmarkStore().addListener(this); - setVisibility(GONE); setOnTouchListener((v, event) -> { @@ -147,14 +143,14 @@ public void onClick(@NonNull View view, @NonNull Bookmark item) { public void onDelete(@NonNull View view, @NonNull Bookmark item) { mBinding.bookmarksList.requestFocusFromTouch(); - mIgnoreNextListener = true; - SessionStore.get().getBookmarkStore().deleteBookmarkById(item.getGuid()); mBookmarkAdapter.removeItem(item); if (mBookmarkAdapter.itemCount() == 0) { mBinding.setIsEmpty(true); mBinding.setIsLoading(false); mBinding.executePendingBindings(); } + + SessionStore.get().getBookmarkStore().deleteBookmarkById(item.getGuid()); } @Override @@ -322,19 +318,11 @@ private void updateLayout() { @Override public void onBookmarksUpdated() { - if (mIgnoreNextListener) { - mIgnoreNextListener = false; - return; - } updateBookmarks(); } @Override public void onBookmarkAdded() { - if (mIgnoreNextListener) { - mIgnoreNextListener = false; - return; - } updateBookmarks(); } } diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/HistoryView.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/HistoryView.java index deb6a95dd..e94e1c784 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/views/HistoryView.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/views/HistoryView.java @@ -61,7 +61,6 @@ public class HistoryView extends FrameLayout implements HistoryStore.HistoryList private HistoryBinding mBinding; private Accounts mAccounts; private HistoryAdapter mHistoryAdapter; - private boolean mIgnoreNextListener; private ArrayList mHistoryViewListeners; public HistoryView(Context aContext) { @@ -116,9 +115,6 @@ private void initialize(Context aContext) { mBinding.setIsSignedIn(mAccounts.isSignedIn()); mBinding.setIsSyncEnabled(mAccounts.isEngineEnabled(SyncEngine.History.INSTANCE)); - updateHistory(); - SessionStore.get().getHistoryStore().addListener(this); - setVisibility(GONE); setOnTouchListener((v, event) -> { @@ -150,14 +146,14 @@ public void onClick(View view, VisitInfo item) { public void onDelete(View view, VisitInfo item) { mBinding.historyList.requestFocusFromTouch(); - mIgnoreNextListener = true; - SessionStore.get().getHistoryStore().deleteHistory(item.getUrl(), item.getVisitTime()); mHistoryAdapter.removeItem(item); if (mHistoryAdapter.itemCount() == 0) { mBinding.setIsEmpty(true); mBinding.setIsLoading(false); mBinding.executePendingBindings(); } + + SessionStore.get().getHistoryStore().deleteHistory(item.getUrl(), item.getVisitTime()); } @Override @@ -365,10 +361,6 @@ private void updateLayout() { @Override public void onHistoryUpdated() { - if (mIgnoreNextListener) { - mIgnoreNextListener = false; - return; - } updateHistory(); } }