Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Remove the ignore flag that prevented the update after deleting an it…
Browse files Browse the repository at this point in the history
…em (#2145)
  • Loading branch information
keianhzo authored and bluemarvin committed Nov 4, 2019
1 parent 69f6a94 commit d75fa4f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<BookmarksCallback> mBookmarksViewListeners;
private CustomLinearLayoutManager mLayoutManager;

Expand Down Expand Up @@ -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) -> {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<HistoryCallback> mHistoryViewListeners;

public HistoryView(Context aContext) {
Expand Down Expand Up @@ -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) -> {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -365,10 +361,6 @@ private void updateLayout() {

@Override
public void onHistoryUpdated() {
if (mIgnoreNextListener) {
mIgnoreNextListener = false;
return;
}
updateHistory();
}
}

0 comments on commit d75fa4f

Please sign in to comment.