OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.browser.ntp; | 5 package org.chromium.chrome.browser.ntp; |
6 | 6 |
7 import android.annotation.SuppressLint; | 7 import android.annotation.SuppressLint; |
8 import android.content.Context; | 8 import android.content.Context; |
9 import android.content.res.Configuration; | 9 import android.content.res.Configuration; |
10 import android.content.res.Resources; | 10 import android.content.res.Resources; |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 } | 354 } |
355 }); | 355 }); |
356 } else { | 356 } else { |
357 stub.setLayoutResource(R.layout.new_tab_page_scroll_view); | 357 stub.setLayoutResource(R.layout.new_tab_page_scroll_view); |
358 mScrollView = (NewTabPageScrollView) stub.inflate(); | 358 mScrollView = (NewTabPageScrollView) stub.inflate(); |
359 mScrollView.setBackgroundColor( | 359 mScrollView.setBackgroundColor( |
360 ApiCompatibilityUtils.getColor(getResources(), R.color.ntp_b
g)); | 360 ApiCompatibilityUtils.getColor(getResources(), R.color.ntp_b
g)); |
361 mScrollView.enableBottomShadow(SHADOW_COLOR); | 361 mScrollView.enableBottomShadow(SHADOW_COLOR); |
362 mNewTabPageLayout = (NewTabPageLayout) findViewById(R.id.ntp_content
); | 362 mNewTabPageLayout = (NewTabPageLayout) findViewById(R.id.ntp_content
); |
363 } | 363 } |
364 mContextMenuManager = new ContextMenuManager(mActivity, mManager, | 364 mContextMenuManager = |
365 mUseCardsUi ? mRecyclerView : mScrollView); | 365 new ContextMenuManager(mManager, tab, mUseCardsUi ? mRecyclerVie
w : mScrollView); |
366 mActivity.getWindowAndroid().addContextMenuCloseListener(mContextMenuMan
ager); | |
367 manager.addDestructionObserver(new DestructionObserver() { | |
368 @Override | |
369 public void onDestroy() { | |
370 mActivity.getWindowAndroid().removeContextMenuCloseListener(mCon
textMenuManager); | |
371 } | |
372 }); | |
373 | 366 |
374 mMostVisitedDesign = new MostVisitedDesign(getContext()); | 367 mMostVisitedDesign = new MostVisitedDesign(getContext()); |
375 mMostVisitedLayout = | 368 mMostVisitedLayout = |
376 (MostVisitedLayout) mNewTabPageLayout.findViewById(R.id.most_vis
ited_layout); | 369 (MostVisitedLayout) mNewTabPageLayout.findViewById(R.id.most_vis
ited_layout); |
377 mMostVisitedDesign.initMostVisitedLayout(searchProviderHasLogo); | 370 mMostVisitedDesign.initMostVisitedLayout(searchProviderHasLogo); |
378 | 371 |
379 mSearchProviderLogoView = | 372 mSearchProviderLogoView = |
380 (LogoView) mNewTabPageLayout.findViewById(R.id.search_provider_l
ogo); | 373 (LogoView) mNewTabPageLayout.findViewById(R.id.search_provider_l
ogo); |
381 mSearchBoxView = mNewTabPageLayout.findViewById(R.id.search_box); | 374 mSearchBoxView = mNewTabPageLayout.findViewById(R.id.search_box); |
382 mNoSearchLogoSpacer = mNewTabPageLayout.findViewById(R.id.no_search_logo
_spacer); | 375 mNoSearchLogoSpacer = mNewTabPageLayout.findViewById(R.id.no_search_logo
_spacer); |
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1242 public int getScrollPosition() { | 1235 public int getScrollPosition() { |
1243 if (mUseCardsUi) return mRecyclerView.getScrollPosition(); | 1236 if (mUseCardsUi) return mRecyclerView.getScrollPosition(); |
1244 return RecyclerView.NO_POSITION; | 1237 return RecyclerView.NO_POSITION; |
1245 } | 1238 } |
1246 | 1239 |
1247 /** @return the context menu manager. */ | 1240 /** @return the context menu manager. */ |
1248 public ContextMenuManager getContextMenuManager() { | 1241 public ContextMenuManager getContextMenuManager() { |
1249 return mContextMenuManager; | 1242 return mContextMenuManager; |
1250 } | 1243 } |
1251 } | 1244 } |
OLD | NEW |