From 8a26c51274d400920e0c4b5748ef93ab094f381c Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Tue, 25 Apr 2017 10:18:24 +0200 Subject: [PATCH] Fix potential crash search history --- OsmAnd/src/net/osmand/plus/helpers/SearchHistoryHelper.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/helpers/SearchHistoryHelper.java b/OsmAnd/src/net/osmand/plus/helpers/SearchHistoryHelper.java index d78df6e49d..aefeabf041 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/SearchHistoryHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/SearchHistoryHelper.java @@ -39,7 +39,7 @@ public class SearchHistoryHelper { 5, 60, 60 * 24, 5 * 60 * 24, 10 * 60 * 24, 30 * 60 * 24 }; - private static Comparator historyEntryComparator = new Comparator() { + private static class HistoryEntryComparator implements Comparator { 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);