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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/CardViewHolder.java

Issue 2285833002: Fix suggestion dismissing when underlying data changes (Closed)
Patch Set: Import SuppressFBWarnings from the right namespace Created 4 years, 4 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/NewTabPageAdapter.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/CardViewHolder.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/CardViewHolder.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/CardViewHolder.java
index ad835a05999e9fb4218062b86ae71a21131b74d8..5dc61ec4dc16a4208dc37b3e080221a2517a5cea 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/CardViewHolder.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/CardViewHolder.java
@@ -4,12 +4,7 @@
package org.chromium.chrome.browser.ntp.cards;
-import android.animation.Animator;
-import android.animation.AnimatorListenerAdapter;
-import android.animation.AnimatorSet;
-import android.animation.ObjectAnimator;
import android.support.annotation.DrawableRes;
-import android.support.v4.view.animation.FastOutLinearInInterpolator;
import android.support.v4.view.animation.FastOutSlowInInterpolator;
import android.support.v7.widget.RecyclerView;
import android.view.ContextMenu;
@@ -44,9 +39,7 @@ import org.chromium.chrome.browser.util.ViewUtils;
* parent implementation to reset the private state when a card is recycled.
*/
public class CardViewHolder extends NewTabPageViewHolder {
- private static final Interpolator FADE_INTERPOLATOR = new FastOutLinearInInterpolator();
private static final Interpolator TRANSITION_INTERPOLATOR = new FastOutSlowInInterpolator();
- private static final int DISMISS_ANIMATION_TIME_MS = 300;
/** Value used for max peeking card height and padding. */
private final int mMaxPeekPadding;
@@ -192,15 +185,6 @@ public class CardViewHolder extends NewTabPageViewHolder {
return mPeekingPercentage > 0f;
}
- @Override
- public void updateViewStateForDismiss(float dX) {
- // Any changes in the animation here should be reflected also in |dismiss|
- // and reset in onBindViewHolder.
- float input = Math.abs(dX) / itemView.getMeasuredWidth();
- float alpha = 1 - FADE_INTERPOLATOR.getInterpolation(input);
- itemView.setAlpha(alpha);
- }
-
/**
* Override this to react when the card is tapped. This method will not be called if the card is
* currently peeking.
@@ -248,40 +232,6 @@ public class CardViewHolder extends NewTabPageViewHolder {
return LayoutInflater.from(parent.getContext()).inflate(resourceId, parent, false);
}
- /**
- * Animates the card being swiped to the right as if the user had dismissed it. You must check
- * {@link #isDismissable()} before calling.
- */
- protected void dismiss() {
- assert isDismissable();
-
- // In case the user pressed dismiss on the context menu after swiping to dismiss.
- if (getAdapterPosition() == RecyclerView.NO_POSITION) return;
-
- // Any changes in the animation here should be reflected also in |updateViewStateForDismiss|
- // and reset in onBindViewHolder.
- AnimatorSet animation = new AnimatorSet();
- animation.playTogether(
- ObjectAnimator.ofFloat(itemView, View.ALPHA, 0f),
- ObjectAnimator.ofFloat(itemView, View.TRANSLATION_X, (float) itemView.getWidth()));
-
- animation.setDuration(DISMISS_ANIMATION_TIME_MS);
- animation.setInterpolator(FADE_INTERPOLATOR);
- animation.addListener(new AnimatorListenerAdapter() {
- @Override
- public void onAnimationStart(Animator animation) {
- mRecyclerView.onItemDismissStarted(itemView);
- }
-
- @Override
- public void onAnimationEnd(Animator animation) {
- ((NewTabPageAdapter) mRecyclerView.getAdapter()).dismissItem(CardViewHolder.this);
- mRecyclerView.onItemDismissFinished(itemView);
- }
- });
- animation.start();
- }
-
private static boolean isCard(@NewTabPageItem.ViewType int type) {
switch (type) {
case NewTabPageItem.VIEW_TYPE_SNIPPET:
@@ -307,4 +257,8 @@ public class CardViewHolder extends NewTabPageViewHolder {
if (hasCardAbove && !hasCardBelow) return R.drawable.ntp_card_bottom;
return R.drawable.ntp_card_single;
}
+
+ protected NewTabPageRecyclerView getRecyclerView() {
+ return mRecyclerView;
+ }
}
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/NewTabPageAdapter.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698