| Index: chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/ActionListItem.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/ActionListItem.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/ActionListItem.java
|
| index 9d93dab4d19143fbeb01667f0140eea3f0bddec2..f144d83b1d5384c12de78dcf24d9d5b7b75a9794 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/ActionListItem.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/ActionListItem.java
|
| @@ -6,30 +6,58 @@ package org.chromium.chrome.browser.ntp.cards;
|
|
|
| import android.view.View;
|
|
|
| +import org.chromium.base.Log;
|
| import org.chromium.chrome.R;
|
| import org.chromium.chrome.browser.ntp.NewTabPageView.NewTabPageManager;
|
| import org.chromium.chrome.browser.ntp.UiConfig;
|
| +import org.chromium.chrome.browser.ntp.snippets.KnownCategories;
|
|
|
| /**
|
| * Item that allows the user to perform an action on the NTP.
|
| */
|
| class ActionListItem implements NewTabPageListItem {
|
| + private static final String TAG = "NtpCards";
|
| +
|
| + private final int mCategory;
|
| +
|
| + public ActionListItem(int category) {
|
| + mCategory = category;
|
| + }
|
| +
|
| @Override
|
| public int getType() {
|
| return NewTabPageListItem.VIEW_TYPE_ACTION;
|
| }
|
|
|
| public static class ViewHolder extends CardViewHolder {
|
| + private ActionListItem mActionListItem;
|
| +
|
| public ViewHolder(NewTabPageRecyclerView recyclerView, final NewTabPageManager manager,
|
| UiConfig uiConfig) {
|
| super(R.layout.new_tab_page_action_card, recyclerView, uiConfig);
|
| itemView.setOnClickListener(new View.OnClickListener() {
|
| @Override
|
| public void onClick(View v) {
|
| - // TODO(dgn): Implement other behaviours.
|
| - manager.navigateToBookmarks();
|
| + int category = mActionListItem.mCategory;
|
| + if (category == KnownCategories.BOOKMARKS) {
|
| + manager.navigateToBookmarks();
|
| + } else if (category == KnownCategories.OFFLINE_PAGES) {
|
| + // TODO(pke): Implement.
|
| + // org.chromium.chrome.browser.download.DownloadUtils.showDownloadManager
|
| + } else {
|
| + // TODO(pke): This should redirect to the C++ backend. Once it does,
|
| + // change the condition in the SuggestionsSection constructor.
|
| + Log.wtf(TAG, "More action called on a dynamically added section: %d",
|
| + category);
|
| + }
|
| }
|
| });
|
| }
|
| +
|
| + @Override
|
| + public void onBindViewHolder(NewTabPageListItem item) {
|
| + super.onBindViewHolder(item);
|
| + mActionListItem = (ActionListItem) item;
|
| + }
|
| }
|
| }
|
|
|