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.suggestions; | 5 package org.chromium.chrome.browser.suggestions; |
6 | 6 |
7 import android.animation.Animator; | 7 import android.animation.Animator; |
8 import android.animation.AnimatorListenerAdapter; | 8 import android.animation.AnimatorListenerAdapter; |
9 import android.animation.AnimatorSet; | 9 import android.animation.AnimatorSet; |
10 import android.animation.ObjectAnimator; | 10 import android.animation.ObjectAnimator; |
11 import android.content.Context; | 11 import android.content.Context; |
12 import android.content.res.Resources; | 12 import android.content.res.Resources; |
13 import android.graphics.Canvas; | 13 import android.graphics.Canvas; |
14 import android.support.v4.view.ViewCompat; | 14 import android.support.v4.view.ViewCompat; |
15 import android.support.v4.view.animation.FastOutLinearInInterpolator; | 15 import android.support.v4.view.animation.FastOutLinearInInterpolator; |
16 import android.support.v7.view.ContextThemeWrapper; | 16 import android.support.v7.view.ContextThemeWrapper; |
17 import android.support.v7.widget.LinearLayoutManager; | 17 import android.support.v7.widget.LinearLayoutManager; |
18 import android.support.v7.widget.RecyclerView; | 18 import android.support.v7.widget.RecyclerView; |
19 import android.support.v7.widget.helper.ItemTouchHelper; | 19 import android.support.v7.widget.helper.ItemTouchHelper; |
| 20 import android.util.AttributeSet; |
20 import android.view.GestureDetector; | 21 import android.view.GestureDetector; |
21 import android.view.MotionEvent; | 22 import android.view.MotionEvent; |
22 import android.view.View; | 23 import android.view.View; |
23 import android.view.ViewGroup; | 24 import android.view.ViewGroup; |
24 import android.view.animation.Interpolator; | 25 import android.view.animation.Interpolator; |
25 import android.view.inputmethod.EditorInfo; | 26 import android.view.inputmethod.EditorInfo; |
26 import android.view.inputmethod.InputConnection; | 27 import android.view.inputmethod.InputConnection; |
27 | 28 |
28 import org.chromium.base.ApiCompatibilityUtils; | 29 import org.chromium.base.ApiCompatibilityUtils; |
29 import org.chromium.base.Callback; | 30 import org.chromium.base.Callback; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 * Height compensation value for each item being dismissed. Since dismissals
sometimes include | 68 * Height compensation value for each item being dismissed. Since dismissals
sometimes include |
68 * sibling elements, and these don't get the standard treatment, we track th
e total height | 69 * sibling elements, and these don't get the standard treatment, we track th
e total height |
69 * associated with the element the user interacted with. | 70 * associated with the element the user interacted with. |
70 */ | 71 */ |
71 private final Map<ViewHolder, Integer> mCompensationHeightMap = new HashMap<
>(); | 72 private final Map<ViewHolder, Integer> mCompensationHeightMap = new HashMap<
>(); |
72 | 73 |
73 /** Whether the RecyclerView and its children should react to touch events.
*/ | 74 /** Whether the RecyclerView and its children should react to touch events.
*/ |
74 private boolean mTouchEnabled = true; | 75 private boolean mTouchEnabled = true; |
75 | 76 |
76 public SuggestionsRecyclerView(Context context) { | 77 public SuggestionsRecyclerView(Context context) { |
77 super(new ContextThemeWrapper(context, R.style.NewTabPageRecyclerView)); | 78 this(context, null); |
| 79 } |
| 80 |
| 81 public SuggestionsRecyclerView(Context context, AttributeSet attrs) { |
| 82 super(new ContextThemeWrapper(context, R.style.NewTabPageRecyclerView),
attrs); |
78 | 83 |
79 Resources res = getContext().getResources(); | 84 Resources res = getContext().getResources(); |
80 setBackgroundColor(ApiCompatibilityUtils.getColor(res, R.color.ntp_bg)); | 85 setBackgroundColor(ApiCompatibilityUtils.getColor(res, R.color.ntp_bg)); |
81 setLayoutParams(new LayoutParams( | 86 setLayoutParams(new LayoutParams( |
82 ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATC
H_PARENT)); | 87 ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATC
H_PARENT)); |
83 setFocusable(true); | 88 setFocusable(true); |
84 setFocusableInTouchMode(true); | 89 setFocusableInTouchMode(true); |
85 setContentDescription(res.getString(R.string.accessibility_new_tab_page)
); | 90 setContentDescription(res.getString(R.string.accessibility_new_tab_page)
); |
86 | 91 |
87 mGestureDetector = | 92 mGestureDetector = |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 * Callback to reset a card's properties affected by swipe to dismiss. | 361 * Callback to reset a card's properties affected by swipe to dismiss. |
357 */ | 362 */ |
358 private static class ResetForDismissCallback extends NewTabPageViewHolder.Pa
rtialBindCallback { | 363 private static class ResetForDismissCallback extends NewTabPageViewHolder.Pa
rtialBindCallback { |
359 @Override | 364 @Override |
360 public void onResult(NewTabPageViewHolder holder) { | 365 public void onResult(NewTabPageViewHolder holder) { |
361 assert holder instanceof CardViewHolder; | 366 assert holder instanceof CardViewHolder; |
362 ((CardViewHolder) holder).getRecyclerView().updateViewStateForDismis
s(0, holder); | 367 ((CardViewHolder) holder).getRecyclerView().updateViewStateForDismis
s(0, holder); |
363 } | 368 } |
364 } | 369 } |
365 } | 370 } |
OLD | NEW |