| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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.widget.selection; | 5 package org.chromium.chrome.browser.widget.selection; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.content.res.Configuration; | 8 import android.content.res.Configuration; |
| 9 import android.content.res.Resources; | 9 import android.content.res.Resources; |
| 10 import android.graphics.Rect; | 10 import android.graphics.Rect; |
| 11 import android.graphics.drawable.Drawable; | 11 import android.graphics.drawable.Drawable; |
| 12 import android.support.annotation.VisibleForTesting; | 12 import android.support.annotation.VisibleForTesting; |
| 13 import android.support.v4.widget.DrawerLayout; | 13 import android.support.v4.widget.DrawerLayout; |
| 14 import android.support.v7.widget.LinearLayoutManager; | 14 import android.support.v7.widget.LinearLayoutManager; |
| 15 import android.support.v7.widget.RecyclerView; | 15 import android.support.v7.widget.RecyclerView; |
| 16 import android.support.v7.widget.RecyclerView.Adapter; | 16 import android.support.v7.widget.RecyclerView.Adapter; |
| 17 import android.support.v7.widget.RecyclerView.AdapterDataObserver; | 17 import android.support.v7.widget.RecyclerView.AdapterDataObserver; |
| 18 import android.support.v7.widget.RecyclerView.ItemAnimator; | 18 import android.support.v7.widget.RecyclerView.ItemAnimator; |
| 19 import android.support.v7.widget.RecyclerView.OnScrollListener; | 19 import android.support.v7.widget.RecyclerView.OnScrollListener; |
| 20 import android.support.v7.widget.Toolbar; |
| 20 import android.support.v7.widget.Toolbar.OnMenuItemClickListener; | 21 import android.support.v7.widget.Toolbar.OnMenuItemClickListener; |
| 21 import android.util.AttributeSet; | 22 import android.util.AttributeSet; |
| 22 import android.view.LayoutInflater; | 23 import android.view.LayoutInflater; |
| 23 import android.view.View; | 24 import android.view.View; |
| 24 import android.view.ViewStub; | 25 import android.view.ViewStub; |
| 25 import android.widget.RelativeLayout; | 26 import android.widget.RelativeLayout; |
| 26 import android.widget.TextView; | 27 import android.widget.TextView; |
| 27 | 28 |
| 28 import org.chromium.base.ApiCompatibilityUtils; | 29 import org.chromium.base.ApiCompatibilityUtils; |
| 29 import org.chromium.chrome.R; | 30 import org.chromium.chrome.R; |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 padding, mRecyclerView.getPaddingTop(), | 292 padding, mRecyclerView.getPaddingTop(), |
| 292 padding, mRecyclerView.getPaddingBottom()); | 293 padding, mRecyclerView.getPaddingBottom()); |
| 293 } | 294 } |
| 294 | 295 |
| 295 @Override | 296 @Override |
| 296 public void onSelectionStateChange(List<E> selectedItems) { | 297 public void onSelectionStateChange(List<E> selectedItems) { |
| 297 setToolbarShadowVisibility(); | 298 setToolbarShadowVisibility(); |
| 298 } | 299 } |
| 299 | 300 |
| 300 /** | 301 /** |
| 301 * Removes the content view from this view and returns it so that it may be
re-attached | 302 * Removes the toolbar view from this view and returns it so that it may be
re-attached |
| 302 * elsewhere. | 303 * elsewhere. |
| 303 * @return The content view, which consists of the {@link RecyclerView} that
holds the list of | 304 * @return The toolbar view. |
| 304 * items, the empty view, and the loading view. | |
| 305 */ | 305 */ |
| 306 public View detachContentView() { | 306 public Toolbar detachToolbarView() { |
| 307 View contentView = findViewById(R.id.list_content); | 307 removeView(mToolbar); |
| 308 assert contentView != null; | 308 return mToolbar; |
| 309 removeView(contentView); | |
| 310 | |
| 311 // The background color is typically set on the SelectableListLayout rat
her than the content | |
| 312 // view. Set the background color for the content view so that it is not
transparent. | |
| 313 contentView.setBackground(getBackground()); | |
| 314 | |
| 315 return contentView; | |
| 316 } | 309 } |
| 317 | 310 |
| 318 /** | 311 /** |
| 319 * Called when a search is starting. | 312 * Called when a search is starting. |
| 320 */ | 313 */ |
| 321 public void onStartSearch() { | 314 public void onStartSearch() { |
| 322 mRecyclerView.setItemAnimator(null); | 315 mRecyclerView.setItemAnimator(null); |
| 323 mToolbarShadow.setVisibility(View.VISIBLE); | 316 mToolbarShadow.setVisibility(View.VISIBLE); |
| 324 mEmptyView.setText(mSearchEmptyStringResId); | 317 mEmptyView.setText(mSearchEmptyStringResId); |
| 325 } | 318 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 */ | 357 */ |
| 365 private void updateEmptyViewVisibility() { | 358 private void updateEmptyViewVisibility() { |
| 366 mEmptyView.setVisibility(mAdapter.getItemCount() == 0 ? View.VISIBLE : V
iew.GONE); | 359 mEmptyView.setVisibility(mAdapter.getItemCount() == 0 ? View.VISIBLE : V
iew.GONE); |
| 367 } | 360 } |
| 368 | 361 |
| 369 @VisibleForTesting | 362 @VisibleForTesting |
| 370 public View getToolbarShadowForTests() { | 363 public View getToolbarShadowForTests() { |
| 371 return mToolbarShadow; | 364 return mToolbarShadow; |
| 372 } | 365 } |
| 373 } | 366 } |
| OLD | NEW |