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

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: rebase 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 156bb65ee6dcc678dc30af589299af3b27a91409..15299e11e0f845d12fd94151717a4782d1483f00 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
@@ -255,6 +255,28 @@ public void onItemRangeRemoved(TreeNode child, int index, int count) {
}
@Override
+ protected void notifyItemRangeInserted(int index, int count) {
+ super.notifyItemRangeInserted(index, count);
+ notifyNeighbourModified(index, count);
+ }
+
+ @Override
+ protected void notifyItemRangeRemoved(int index, int count) {
+ super.notifyItemRangeRemoved(index, count);
+ notifyNeighbourModified(index, count);
+ }
+
+ private void notifyNeighbourModified(int index, int modifiedRange) {
+ int aboveNeighbour = index - 1;
+ int belowNeighbour = index + modifiedRange;
+
+ 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