Fix potential crash search history
This commit is contained in:
parent
8919740cf9
commit
6667051460
1 changed files with 3 additions and 3 deletions
|
@ -39,7 +39,7 @@ public class SearchHistoryHelper {
|
|||
5, 60, 60 * 24, 5 * 60 * 24, 10 * 60 * 24, 30 * 60 * 24
|
||||
};
|
||||
|
||||
private static Comparator<HistoryEntry> historyEntryComparator = new Comparator<HistoryEntry>() {
|
||||
private static class HistoryEntryComparator implements Comparator<HistoryEntry> {
|
||||
long time = System.currentTimeMillis();
|
||||
|
||||
@Override
|
||||
|
@ -200,7 +200,7 @@ public class SearchHistoryHelper {
|
|||
HistoryItemDBHelper helper = new HistoryItemDBHelper();
|
||||
if (loadedEntries == null) {
|
||||
loadedEntries = helper.getEntries();
|
||||
Collections.sort(loadedEntries, historyEntryComparator);
|
||||
Collections.sort(loadedEntries, new HistoryEntryComparator());
|
||||
for(HistoryEntry he : loadedEntries) {
|
||||
mp.put(he.getName(), he);
|
||||
}
|
||||
|
@ -236,7 +236,7 @@ public class SearchHistoryHelper {
|
|||
model.markAsAccessed(System.currentTimeMillis());
|
||||
helper.add(model);
|
||||
}
|
||||
Collections.sort(loadedEntries, historyEntryComparator);
|
||||
Collections.sort(loadedEntries, new HistoryEntryComparator());
|
||||
if(loadedEntries.size() > HISTORY_LIMIT){
|
||||
if(helper.remove(loadedEntries.get(loadedEntries.size() - 1))){
|
||||
loadedEntries.remove(loadedEntries.size() - 1);
|
||||
|
|
Loading…
Reference in a new issue