@Override public void clearSelection() { mSelectedBookmarks.clear(); for (EnhancedBookmarkUIObserver observer : mUIObservers) { observer.onSelectionStateChange(new ArrayList<BookmarkId>(mSelectedBookmarks)); } }
@Override public boolean toggleSelectionForBookmark(BookmarkId bookmark) { if (!mEnhancedBookmarksModel.getBookmarkById(bookmark).isEditable()) return false; if (mSelectedBookmarks.contains(bookmark)) mSelectedBookmarks.remove(bookmark); else mSelectedBookmarks.add(bookmark); for (EnhancedBookmarkUIObserver observer : mUIObservers) { observer.onSelectionStateChange(new ArrayList<BookmarkId>(mSelectedBookmarks)); } return isBookmarkSelected(bookmark); }
/** Destroys and cleans up itself. This must be called after done using this class. */ public void destroy() { for (EnhancedBookmarkUIObserver observer : mUIObservers) { observer.onDestroy(); } assert mUIObservers.size() == 0; if (mUndoController != null) { mUndoController.destroy(); mUndoController = null; } mEnhancedBookmarksModel.removeObserver(mBookmarkModelObserver); mEnhancedBookmarksModel.destroy(); mEnhancedBookmarksModel = null; mLargeIconBridge.destroy(); mLargeIconBridge = null; }
@Override public void notifyStateChange(EnhancedBookmarkUIObserver observer) { int state = getCurrentState(); switch (state) { case UIState.STATE_ALL_BOOKMARKS: observer.onAllBookmarksStateSet(); break; case UIState.STATE_FOLDER: observer.onFolderStateSet(mStateStack.peek().mFolder); break; case UIState.STATE_LOADING: // In loading state, onEnhancedBookmarkDelegateInitialized() is not called for all // UIObservers, which means that there will be no observers at the time. Do nothing. assert mUIObservers.isEmpty(); break; case UIState.STATE_FILTER: observer.onFilterStateSet(mStateStack.peek().mFilter); break; default: assert false : "State not valid"; break; } }