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

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

Issue 2651743002: 📰 Fix card style when a neighbour is added or removed (Closed)
Patch Set: Revert to previous implementation Created 3 years, 11 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
Index: chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/SuggestionsSection.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/SuggestionsSection.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/SuggestionsSection.java
index c9a636a0372293e4644312c450931a05182a2974..b34a0e46d6034ad54343341762467f1b2a94d8de 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/SuggestionsSection.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/SuggestionsSection.java
@@ -267,6 +267,27 @@ public void onItemRangeRemoved(TreeNode child, int index, int count) {
}
@Override
+ protected void notifyItemRangeInserted(int index, int count) {
+ super.notifyItemRangeInserted(index, count);
+ notifyNeighboursModified(index - 1, index + count);
+ }
+
+ @Override
+ protected void notifyItemRangeRemoved(int index, int count) {
+ super.notifyItemRangeRemoved(index, count);
+ notifyNeighboursModified(index - 1, index);
+ }
+
+ /** Sends a notification to the items at the provided indices to refresh their background. */
+ private void notifyNeighboursModified(int aboveNeighbour, int belowNeighbour) {
+ assert aboveNeighbour < belowNeighbour;
+ if (aboveNeighbour >= 0) notifyItemChanged(aboveNeighbour, PartialUpdateId.CARD_BACKGROUND);
+ if (belowNeighbour < getItemCount()) {
+ notifyItemChanged(belowNeighbour, PartialUpdateId.CARD_BACKGROUND);
+ }
+ }
+
+ @Override
public void onBindViewHolder(NewTabPageViewHolder holder, int position) {
super.onBindViewHolder(holder, position);
childSeen(position);

Powered by Google App Engine
This is Rietveld 408576698