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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadItemGroup.java

Issue 2670083002: [Download Home] Displaying offline page bundle per day (Closed)
Patch Set: Filter out pages before adding to DateDividedAdapter Created 3 years, 10 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.chromium.chrome.browser.download.ui;
6
7 import org.chromium.chrome.browser.download.ui.DownloadHistoryAdapter.Subsection Header;
8 import org.chromium.chrome.browser.download.ui.DownloadHistoryItemWrapper.Offlin ePageItemWrapper;
9 import org.chromium.chrome.browser.widget.DateDividedAdapter;
10 import org.chromium.chrome.browser.widget.DateDividedAdapter.TimedItem;
11
12 /**
13 * A bucket of downloaded items with the same date. It also holds the suggested offline items which
14 * are shown at the end of the list for that date.
15 */
16 public class DownloadItemGroup extends DateDividedAdapter.ItemGroup {
17 public DownloadItemGroup(long timestamp) {
18 super(timestamp);
19 }
20
21 @Override
22 public int compareItem(TimedItem lhs, TimedItem rhs) {
23 int lhsOrder = order(lhs);
24 int rhsOrder = order(rhs);
25
26 if (lhsOrder != rhsOrder) {
27 return lhsOrder < rhsOrder ? -1 : 1;
28 }
29
30 return super.compareItem(lhs, rhs);
31 }
32
33 private boolean isSuggestedOfflinePage(TimedItem timedItem) {
34 if (timedItem instanceof OfflinePageItemWrapper) {
35 return ((OfflinePageItemWrapper) timedItem).isSuggested();
36 }
37
38 return false;
39 }
40
41 private int order(TimedItem timedItem) {
gone 2017/02/15 23:58:09 1) This really needs some documentation about what
shaktisahu 2017/02/16 06:07:06 Done.
42 if (isSuggestedOfflinePage(timedItem)) return 2;
43 if (timedItem instanceof SubsectionHeader) return 1;
44 return 0;
45 }
46 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698