Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2475)

Unified Diff: chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkDrawerListView.java

Issue 1141283003: Upstream oodles of Chrome for Android code into Chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: final patch? Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkDrawerListView.java
diff --git a/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkDrawerListView.java b/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkDrawerListView.java
new file mode 100644
index 0000000000000000000000000000000000000000..b3f432175b19c379355c96d635b95c5f0c98a16a
--- /dev/null
+++ b/chrome/android/java_staging/src/org/chromium/chrome/browser/enhancedbookmarks/EnhancedBookmarkDrawerListView.java
@@ -0,0 +1,125 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser.enhancedbookmarks;
+
+import android.annotation.SuppressLint;
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.ListView;
+
+import org.chromium.chrome.browser.BookmarksBridge.BookmarkModelObserver;
+import org.chromium.chrome.browser.enhanced_bookmarks.EnhancedBookmarksBridge.FiltersObserver;
+import org.chromium.components.bookmarks.BookmarkId;
+
+import java.util.List;
+
+/**
+ * Main drawer list view of Enhanced Bookmark UI. It is responsible for presenting different viewing
+ * modes and let users to choose.
+ */
+@SuppressLint("Instantiatable")
+class EnhancedBookmarkDrawerListView extends ListView implements EnhancedBookmarkUIObserver {
+ private EnhancedBookmarkDelegate mDelegate;
+
+ private BookmarkModelObserver mBookmarkModelObserver = new BookmarkModelObserver() {
+ @Override
+ public void bookmarkModelChanged() {
+ mDelegate.notifyStateChange(EnhancedBookmarkDrawerListView.this);
+ }
+ };
+
+ private FiltersObserver mFiltersObserver = new FiltersObserver() {
+ @Override
+ public void onFiltersChanged() {
+ mDelegate.notifyStateChange(EnhancedBookmarkDrawerListView.this);
+ }
+ };
+
+ private final EnhancedBookmarkDrawerListViewAdapter mAdapter =
+ new EnhancedBookmarkDrawerListViewAdapter();
+
+ public EnhancedBookmarkDrawerListView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+
+ setAdapter(mAdapter);
+ setOnItemClickListener(new OnItemClickListener() {
+ @Override
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+ mDelegate.closeDrawer();
+
+ EnhancedBookmarkDrawerListViewAdapter.Item item =
+ (EnhancedBookmarkDrawerListViewAdapter.Item) mAdapter.getItem(position);
+
+ switch (item.mType) {
+ case EnhancedBookmarkDrawerListViewAdapter.TYPE_FOLDER:
+ mDelegate.openFolder(item.mFolderId);
+ break;
+ case EnhancedBookmarkDrawerListViewAdapter.TYPE_ALL_ITEMS:
+ mDelegate.openAllBookmarks();
+ break;
+ case EnhancedBookmarkDrawerListViewAdapter.TYPE_FILTER:
+ mDelegate.openFilter(item.mFilter);
+ break;
+ default:
+ assert false;
+ }
+ }
+ });
+ }
+
+ void showLoadingUi() {
+ mAdapter.clear();
+ mAdapter.notifyDataSetChanged();
+ clearChoices();
+ }
+
+ // EnhancedBookmarkUIObserver implementations.
+
+ @Override
+ public void onEnhancedBookmarkDelegateInitialized(EnhancedBookmarkDelegate delegate) {
+ mDelegate = delegate;
+ delegate.getModel().addModelObserver(mBookmarkModelObserver);
+ delegate.getModel().addFiltersObserver(mFiltersObserver);
+ mAdapter.setEnhancedBookmarkUIDelegate(delegate);
+ delegate.addUIObserver(this);
+ }
+
+ @Override
+ public void onDestroy() {
+ mDelegate.getModel().removeModelObserver(mBookmarkModelObserver);
+ mDelegate.getModel().removeFiltersObserver(mFiltersObserver);
+ mDelegate.removeUIObserver(this);
+ }
+
+ @Override
+ public void onAllBookmarksStateSet() {
+ mAdapter.updateList();
+ setItemChecked(mAdapter.getItemPosition(EnhancedBookmarkDelegate.STATE_ALL_BOOKMARKS, null),
+ true);
+ }
+
+ @Override
+ public void onFolderStateSet(BookmarkId folder) {
+ mAdapter.updateList();
+ setItemChecked(mAdapter.getItemPosition(EnhancedBookmarkDelegate.STATE_FOLDER, folder),
+ true);
+ }
+
+ @Override
+ public void onFilterStateSet(String filter) {
+ mAdapter.updateList();
+ setItemChecked(mAdapter.getItemPosition(EnhancedBookmarkDelegate.STATE_FILTER, filter),
+ true);
+ }
+
+ @Override
+ public void onSelectionStateChange(List<BookmarkId> selectedBookmarks) {
+ }
+
+ @Override
+ public void onListModeChange(boolean isListModeEnabled) {}
+}

Powered by Google App Engine
This is Rietveld 408576698