OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.browser.download.ui; | 5 package org.chromium.chrome.browser.download.ui; |
6 | 6 |
7 import android.text.TextUtils; | 7 import android.text.TextUtils; |
8 | 8 |
| 9 import org.chromium.chrome.browser.widget.DateDividedAdapter.TimedItem; |
| 10 |
9 import java.util.ArrayList; | 11 import java.util.ArrayList; |
| 12 import java.util.List; |
10 import java.util.Locale; | 13 import java.util.Locale; |
11 | 14 |
12 /** | 15 /** |
13 * Stores a List of DownloadHistoryItemWrappers for a particular download backen
d. | 16 * Stores a List of DownloadHistoryItemWrappers for a particular download backen
d. |
14 */ | 17 */ |
15 public abstract class BackendItems extends ArrayList<DownloadHistoryItemWrapper>
{ | 18 public abstract class BackendItems extends ArrayList<DownloadHistoryItemWrapper>
{ |
16 /** See {@link #findItemIndex}. */ | 19 /** See {@link #findItemIndex}. */ |
17 public static final int INVALID_INDEX = -1; | 20 public static final int INVALID_INDEX = -1; |
18 | 21 |
19 /** Whether or not the list has been initialized. */ | 22 /** Whether or not the list has been initialized. */ |
(...skipping 10 matching lines...) Expand all Loading... |
30 } | 33 } |
31 return totalSize; | 34 return totalSize; |
32 } | 35 } |
33 | 36 |
34 /** | 37 /** |
35 * Filters out items that match the query and are displayed in this list for
the current filter. | 38 * Filters out items that match the query and are displayed in this list for
the current filter. |
36 * @param filterType Filter to use. | 39 * @param filterType Filter to use. |
37 * @param query The text to match. | 40 * @param query The text to match. |
38 * @param filteredItems List for appending items that match the filter. | 41 * @param filteredItems List for appending items that match the filter. |
39 */ | 42 */ |
40 public void filter(int filterType, String query, BackendItems filteredItems)
{ | 43 public void filter(int filterType, String query, List<TimedItem> filteredIte
ms) { |
41 if (TextUtils.isEmpty(query)) { | 44 if (TextUtils.isEmpty(query)) { |
42 filter(filterType, filteredItems); | 45 filter(filterType, filteredItems); |
43 return; | 46 return; |
44 } | 47 } |
45 | 48 |
46 for (DownloadHistoryItemWrapper item : this) { | 49 for (DownloadHistoryItemWrapper item : this) { |
47 query = query.toLowerCase(Locale.getDefault()); | 50 query = query.toLowerCase(Locale.getDefault()); |
48 Locale locale = Locale.getDefault(); | 51 Locale locale = Locale.getDefault(); |
49 if (item.isVisibleToUser(filterType) | 52 if (item.isVisibleToUser(filterType) |
50 && (item.getDisplayHostname().toLowerCase(locale).contains(q
uery) | 53 && (item.getDisplayHostname().toLowerCase(locale).contains(q
uery) |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 public void setIsInitialized() { | 87 public void setIsInitialized() { |
85 mIsInitialized = true; | 88 mIsInitialized = true; |
86 } | 89 } |
87 | 90 |
88 /** | 91 /** |
89 * Filters out items that are displayed in this list for the current filter. | 92 * Filters out items that are displayed in this list for the current filter. |
90 * | 93 * |
91 * @param filterType Filter to use. | 94 * @param filterType Filter to use. |
92 * @param filteredItems List for appending items that match the filter. | 95 * @param filteredItems List for appending items that match the filter. |
93 */ | 96 */ |
94 private void filter(int filterType, BackendItems filteredItems) { | 97 private void filter(int filterType, List<TimedItem> filteredItems) { |
95 for (DownloadHistoryItemWrapper item : this) { | 98 for (DownloadHistoryItemWrapper item : this) { |
96 if (item.isVisibleToUser(filterType)) filteredItems.add(item); | 99 if (item.isVisibleToUser(filterType)) filteredItems.add(item); |
97 } | 100 } |
98 } | 101 } |
99 } | 102 } |
OLD | NEW |