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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/widget/DateDividedAdapter.java

Issue 2555273002: [Android History] Add support for removing items (Closed)
Patch Set: Changes from dfalcantara@ review Created 4 years 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/widget/DateDividedAdapter.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/widget/DateDividedAdapter.java b/chrome/android/java/src/org/chromium/chrome/browser/widget/DateDividedAdapter.java
index eb37562a1c446300257ba9fc258bf7beafff9ce2..003498dfac2ddc17d37384982a0356d1681fc094 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/widget/DateDividedAdapter.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/widget/DateDividedAdapter.java
@@ -108,7 +108,7 @@ public abstract class DateDividedAdapter extends Adapter<RecyclerView.ViewHolder
/**
* A bucket of items with the same date.
*/
- private static class ItemGroup {
+ protected static class ItemGroup {
private final Date mDate;
private final List<TimedItem> mItems = new ArrayList<>();
@@ -128,6 +128,10 @@ public abstract class DateDividedAdapter extends Adapter<RecyclerView.ViewHolder
mIsSorted = false;
}
+ public void removeItem(TimedItem item) {
+ mItems.remove(item);
+ }
+
/** Records the position of all the TimedItems in this group, relative to the full list. */
public void setPosition(int index) {
assert mIndex == 0;
@@ -329,7 +333,7 @@ public abstract class DateDividedAdapter extends Adapter<RecyclerView.ViewHolder
/**
* Utility method to traverse all groups and find the {@link ItemGroup} for the given position.
*/
- private Pair<ItemGroup, Integer> getGroupAt(int position) {
+ protected Pair<ItemGroup, Integer> getGroupAt(int position) {
// TODO(ianwen): Optimize the performance if the number of groups becomes too large.
int i = position;
for (ItemGroup group : mGroups) {
@@ -344,6 +348,13 @@ public abstract class DateDividedAdapter extends Adapter<RecyclerView.ViewHolder
}
/**
+ * @param group The group to remove from the adapter.
+ */
+ protected void removeGroup(ItemGroup group) {
+ mGroups.remove(group);
+ }
+
+ /**
* Creates a long ID that identifies a particular day in history.
* @param date Date to process.
* @return Long that has the day of the year (1-365) in the lowest 16 bits and the year in the

Powered by Google App Engine
This is Rietveld 408576698