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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryAdapter.java

Issue 2251343002: [Downloads] Animate the DateDividedAdapter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@DOWNLOADS_tests
Patch Set: Rebasing 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/download/ui/DownloadHistoryItemWrapper.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/download/ui/DownloadHistoryAdapter.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryAdapter.java b/chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryAdapter.java
index 5a99e44f3387b8a15b40da38fc78cab5a86bae88..a0300ac5fbdd2eb4bbf910fdb3d1c050d321124b 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryAdapter.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryAdapter.java
@@ -78,6 +78,7 @@ public class DownloadHistoryAdapter extends DateDividedAdapter implements Downlo
DownloadHistoryAdapter(boolean showOffTheRecord, ComponentName parentComponent) {
mShowOffTheRecord = showOffTheRecord;
mParentComponent = parentComponent;
+ setHasStableIds(true);
}
@Override
@@ -209,16 +210,7 @@ public class DownloadHistoryAdapter extends DateDividedAdapter implements Downlo
*/
public void onDownloadItemRemoved(String guid, boolean isOffTheRecord) {
if (isOffTheRecord && !mShowOffTheRecord) return;
-
- List<DownloadItemWrapper> list = getDownloadItemList(isOffTheRecord);
- int index = findItemIndex(list, guid);
- if (index != INVALID_INDEX) {
- DownloadItemWrapper wrapper = list.remove(index);
- if (mSelectionDelegate != null && mSelectionDelegate.isItemSelected(wrapper)) {
- mSelectionDelegate.toggleSelectionForItem(wrapper);
- }
- filter(mFilter);
- }
+ if (removeItemFromList(getDownloadItemList(isOffTheRecord), guid)) filter(mFilter);
}
@Override
@@ -293,14 +285,7 @@ public class DownloadHistoryAdapter extends DateDividedAdapter implements Downlo
@Override
public void onItemDeleted(String guid) {
- int index = findItemIndex(mOfflinePageItems, guid);
- if (index != INVALID_INDEX) {
- DownloadHistoryItemWrapper wrapper = mOfflinePageItems.remove(index);
- if (mSelectionDelegate.isItemSelected(wrapper)) {
- mSelectionDelegate.toggleSelectionForItem(wrapper);
- }
- updateFilter();
- }
+ if (removeItemFromList(mOfflinePageItems, guid)) updateFilter();
}
@Override
@@ -369,6 +354,25 @@ public class DownloadHistoryAdapter extends DateDividedAdapter implements Downlo
}
}
+ /**
+ * Removes the item matching the given |guid|.
+ * @param list List of the users downloads of a specific type.
+ * @param guid GUID of the download to remove.
+ * @return True if something was removed, false otherwise.
+ */
+ private <T extends DownloadHistoryItemWrapper> boolean removeItemFromList(
+ List<T> list, String guid) {
+ int index = findItemIndex(list, guid);
+ if (index != INVALID_INDEX) {
+ T wrapper = list.remove(index);
+ if (mSelectionDelegate != null && mSelectionDelegate.isItemSelected(wrapper)) {
+ mSelectionDelegate.toggleSelectionForItem(wrapper);
+ }
+ return true;
+ }
+ return false;
+ }
+
private static DownloadManagerService getDownloadManagerService() {
return DownloadManagerService.getDownloadManagerService(
ContextUtils.getApplicationContext());
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryItemWrapper.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698