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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/history/HistoryManager.java

Issue 2542203002: [Android History] Add Android history manager UI and bridge (Closed)
Patch Set: Add OWNERS files Created 4 years 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.chromium.chrome.browser.history;
6
7 import android.app.Activity;
8 import android.support.v7.widget.Toolbar.OnMenuItemClickListener;
9 import android.view.LayoutInflater;
10 import android.view.MenuItem;
11 import android.view.ViewGroup;
12
13 import org.chromium.chrome.R;
14 import org.chromium.chrome.browser.widget.TintedDrawable;
15 import org.chromium.chrome.browser.widget.selection.SelectableListLayout;
16 import org.chromium.chrome.browser.widget.selection.SelectionDelegate;
17 import org.chromium.ui.base.DeviceFormFactor;
18
19 /**
20 * Displays and manages the UI for browsing history.
21 */
22 public class HistoryManager implements OnMenuItemClickListener {
23 private Activity mActivity;
24 private SelectableListLayout mSelectableListLayout;
25 private HistoryAdapter mHistoryAdapter;
26 private SelectionDelegate<HistoryItem> mSelectionDelegate;
gone 2016/12/02 19:34:37 finals?
Theresa 2016/12/02 20:49:32 Done.
27
28 /**
29 * Creates a new HistoryManager.
30 * @param activity The Activity associated with the HistoryManager.
31 */
32 public HistoryManager(Activity activity) {
33 mActivity = activity;
34
35 mSelectionDelegate = new SelectionDelegate<HistoryItem>();
gone 2016/12/02 19:34:37 new SelectionDelegate<>();
Theresa 2016/12/02 20:49:32 Done.
36 mHistoryAdapter = new HistoryAdapter(mSelectionDelegate);
37
38 mSelectableListLayout =
39 (SelectableListLayout) LayoutInflater.from(activity).inflate(
40 R.layout.history_main, null);
41 mSelectableListLayout.initializeRecyclerView(mHistoryAdapter);
42 mSelectableListLayout.initializeToolbar(R.layout.history_toolbar, mSelec tionDelegate,
43 R.string.menu_history, null, R.id.normal_menu_group,
44 R.id.selection_mode_menu_group, this);
45 mSelectableListLayout.initializeEmptyView(
46 TintedDrawable.constructTintedDrawable(mActivity.getResources(),
47 R.drawable.history_large),
48 R.string.history_manager_empty);
49
50 mHistoryAdapter.initialize();
51
52 // TODO(twellington): add a scroll listener to the RecyclerView that loa ds more items when
53 // the scroll position is near the end.
54 }
55
56 @Override
57 public boolean onMenuItemClick(MenuItem item) {
58 if (item.getItemId() == R.id.close_menu_id && !DeviceFormFactor.isTablet (mActivity)) {
59 mActivity.finish();
60 return true;
61 }
62 return false;
63 }
64
65 /**
66 * @return The view that shows the main browsing history UI.
67 */
68 public ViewGroup getView() {
69 return mSelectableListLayout;
70 }
71
72 /**
73 * Called when the activity/native page is destroyed.
74 */
75 public void onDestroyed() {
76 mSelectableListLayout.onDestroyed();
77 mHistoryAdapter.onDestroyed();
78 }
79 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698