Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/history/HistoryManager.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/history/HistoryManager.java b/chrome/android/java/src/org/chromium/chrome/browser/history/HistoryManager.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9430530364909b89af9dba204285dd6abd643a22 |
| --- /dev/null |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/history/HistoryManager.java |
| @@ -0,0 +1,79 @@ |
| +// Copyright 2016 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.history; |
| + |
| +import android.app.Activity; |
| +import android.support.v7.widget.Toolbar.OnMenuItemClickListener; |
| +import android.view.LayoutInflater; |
| +import android.view.MenuItem; |
| +import android.view.ViewGroup; |
| + |
| +import org.chromium.chrome.R; |
| +import org.chromium.chrome.browser.widget.TintedDrawable; |
| +import org.chromium.chrome.browser.widget.selection.SelectableListLayout; |
| +import org.chromium.chrome.browser.widget.selection.SelectionDelegate; |
| +import org.chromium.ui.base.DeviceFormFactor; |
| + |
| +/** |
| + * Displays and manages the UI for browsing history. |
| + */ |
| +public class HistoryManager implements OnMenuItemClickListener { |
| + private Activity mActivity; |
| + private SelectableListLayout mSelectableListLayout; |
| + private HistoryAdapter mHistoryAdapter; |
| + private SelectionDelegate<HistoryItem> mSelectionDelegate; |
|
gone
2016/12/02 19:34:37
finals?
Theresa
2016/12/02 20:49:32
Done.
|
| + |
| + /** |
| + * Creates a new HistoryManager. |
| + * @param activity The Activity associated with the HistoryManager. |
| + */ |
| + public HistoryManager(Activity activity) { |
| + mActivity = activity; |
| + |
| + mSelectionDelegate = new SelectionDelegate<HistoryItem>(); |
|
gone
2016/12/02 19:34:37
new SelectionDelegate<>();
Theresa
2016/12/02 20:49:32
Done.
|
| + mHistoryAdapter = new HistoryAdapter(mSelectionDelegate); |
| + |
| + mSelectableListLayout = |
| + (SelectableListLayout) LayoutInflater.from(activity).inflate( |
| + R.layout.history_main, null); |
| + mSelectableListLayout.initializeRecyclerView(mHistoryAdapter); |
| + mSelectableListLayout.initializeToolbar(R.layout.history_toolbar, mSelectionDelegate, |
| + R.string.menu_history, null, R.id.normal_menu_group, |
| + R.id.selection_mode_menu_group, this); |
| + mSelectableListLayout.initializeEmptyView( |
| + TintedDrawable.constructTintedDrawable(mActivity.getResources(), |
| + R.drawable.history_large), |
| + R.string.history_manager_empty); |
| + |
| + mHistoryAdapter.initialize(); |
| + |
| + // TODO(twellington): add a scroll listener to the RecyclerView that loads more items when |
| + // the scroll position is near the end. |
| + } |
| + |
| + @Override |
| + public boolean onMenuItemClick(MenuItem item) { |
| + if (item.getItemId() == R.id.close_menu_id && !DeviceFormFactor.isTablet(mActivity)) { |
| + mActivity.finish(); |
| + return true; |
| + } |
| + return false; |
| + } |
| + |
| + /** |
| + * @return The view that shows the main browsing history UI. |
| + */ |
| + public ViewGroup getView() { |
| + return mSelectableListLayout; |
| + } |
| + |
| + /** |
| + * Called when the activity/native page is destroyed. |
| + */ |
| + public void onDestroyed() { |
| + mSelectableListLayout.onDestroyed(); |
| + mHistoryAdapter.onDestroyed(); |
| + } |
| +} |