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

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

Issue 2459033002: 📰 Add a context menu to remove status items (Closed)
Patch Set: close the menu when the view is detached Created 4 years, 1 month 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
Index: chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/NewTabPageRecyclerView.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/NewTabPageRecyclerView.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/NewTabPageRecyclerView.java
index ef1261d99e1c438c3fe73ab98dff582d0cb0daf7..d3e4d3c97bafa3b93e38facc331a057f60f99c05 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/NewTabPageRecyclerView.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/NewTabPageRecyclerView.java
@@ -33,7 +33,9 @@
import org.chromium.chrome.browser.preferences.ChromePreferenceManager;
import org.chromium.chrome.browser.util.ViewUtils;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
/**
@@ -485,33 +487,35 @@ public boolean gatherTransparentRegion(Region region) {
* the animation here should be reflected also in
* {@link #updateViewStateForDismiss(float, ViewHolder)} and reset in
* {@link CardViewHolder#onBindViewHolder()}.
- * @param suggestion The item to be dismissed.
+ * @param item The item to be dismissed.
*/
- public void dismissItemWithAnimation(SnippetArticle suggestion) {
- // We need to recompute the position, as it might have changed.
- final int position = getNewTabPageAdapter().getSuggestionPosition(suggestion);
dgn 2016/11/10 19:44:02 problem1: this does not support things that are no
+ public void dismissItemWithAnimation(final ViewHolder viewHolder) {
+ // We need to recompute the position, as it might have changed. ???
+ final int position = viewHolder.getAdapterPosition();
if (position == RecyclerView.NO_POSITION) {
// The item does not exist anymore, so ignore.
return;
}
- final View itemView = mLayoutManager.findViewByPosition(position);
- if (itemView == null) {
- // The view is not visible anymore, skip the animation.
- getNewTabPageAdapter().dismissItem(position);
- return;
- }
-
- final ViewHolder viewHolder = getChildViewHolder(itemView);
if (!((NewTabPageViewHolder) viewHolder).isDismissable()) {
// The item is not dismissable (anymore), so ignore.
return;
}
- AnimatorSet animation = new AnimatorSet();
- animation.playTogether(ObjectAnimator.ofFloat(itemView, View.ALPHA, 0f),
+ List<Animator> animations = new ArrayList<>();
+ animations.add(ObjectAnimator.ofFloat(itemView, View.ALPHA, 0f));
+ animations.add(
ObjectAnimator.ofFloat(itemView, View.TRANSLATION_X, (float) itemView.getWidth()));
+ final ViewHolder dismissSibling = getNewTabPageAdapter().getDismissSibling(viewHolder);
+ if (dismissSibling != null) {
+ animations.add(ObjectAnimator.ofFloat(dismissSibling.itemView, View.ALPHA, 0f));
+ animations.add(ObjectAnimator.ofFloat(
+ dismissSibling.itemView, View.TRANSLATION_X, (float) itemView.getWidth()));
+ }
+
+ AnimatorSet animation = new AnimatorSet();
+ animation.playTogether(animations.toArray(new Animator[animations.size()]));
animation.setDuration(DISMISS_ANIMATION_TIME_MS);
animation.setInterpolator(DISMISS_INTERPOLATOR);
animation.addListener(new AnimatorListenerAdapter() {

Powered by Google App Engine
This is Rietveld 408576698