|
|
@ -39,8 +39,8 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear |
|
|
|
private static RecentSearchManager recentSearchManager = null; |
|
|
|
private static RecentSearchManager recentSearchManager = null; |
|
|
|
private static File recentFile = null; |
|
|
|
private static File recentFile = null; |
|
|
|
private SearchResult modelList; |
|
|
|
private SearchResult modelList; |
|
|
|
private List<AlphaCellModel> recentModelList = new ArrayList<>(); |
|
|
|
private SearchResult recentModelList; |
|
|
|
private Map<String, List<AlphaCellModel>> recentKVModelMap = new HashMap<>(); |
|
|
|
private Map<String, SearchResult> recentKVModelMap = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
public synchronized static RecentSearchManager getRecentSearchManger() { |
|
|
|
public synchronized static RecentSearchManager getRecentSearchManger() { |
|
|
|
if (recentSearchManager == null) { |
|
|
|
if (recentSearchManager == null) { |
|
|
@ -64,7 +64,7 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear |
|
|
|
String nodeName = reader.getTagName(); |
|
|
|
String nodeName = reader.getTagName(); |
|
|
|
if (nodeName.equals("RecentModelList")) { |
|
|
|
if (nodeName.equals("RecentModelList")) { |
|
|
|
String key = reader.getAttrAsString("searchKey", StringUtils.EMPTY); |
|
|
|
String key = reader.getAttrAsString("searchKey", StringUtils.EMPTY); |
|
|
|
final ArrayList<AlphaCellModel> list = new ArrayList<>(); |
|
|
|
final SearchResult list = new SearchResult(); |
|
|
|
reader.readXMLObject(new XMLReadable() { |
|
|
|
reader.readXMLObject(new XMLReadable() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void readXML(XMLableReader reader) { |
|
|
|
public void readXML(XMLableReader reader) { |
|
|
@ -206,23 +206,19 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear |
|
|
|
return recentModelList; |
|
|
|
return recentModelList; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void setRecentModelList(List<AlphaCellModel> recentModelList) { |
|
|
|
|
|
|
|
this.recentModelList = recentModelList; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 根据搜索字段获取对应的model列表 |
|
|
|
* 根据搜索字段获取对应的model列表 |
|
|
|
* |
|
|
|
* |
|
|
|
* @param searchText |
|
|
|
* @param searchText |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public synchronized List<AlphaCellModel> getRecentModelList(String searchText) { |
|
|
|
private synchronized SearchResult getRecentModelList(String searchText) { |
|
|
|
recentModelList = new ArrayList<>(); |
|
|
|
recentModelList = new SearchResult(); |
|
|
|
for (String key : recentKVModelMap.keySet()) { |
|
|
|
for (String key : recentKVModelMap.keySet()) { |
|
|
|
AlphaFineHelper.checkCancel(); |
|
|
|
AlphaFineHelper.checkCancel(); |
|
|
|
if (ComparatorUtils.equals(key, searchText)) { |
|
|
|
if (ComparatorUtils.equals(key, searchText)) { |
|
|
|
recentModelList = recentKVModelMap.get(searchText); |
|
|
|
recentModelList = recentKVModelMap.get(searchText); |
|
|
|
List<AlphaCellModel> resultModelList = new ArrayList<>(recentModelList); |
|
|
|
SearchResult resultModelList = recentModelList; |
|
|
|
Iterator<AlphaCellModel> modelIterator = resultModelList.iterator(); |
|
|
|
Iterator<AlphaCellModel> modelIterator = resultModelList.iterator(); |
|
|
|
while (modelIterator.hasNext()) { |
|
|
|
while (modelIterator.hasNext()) { |
|
|
|
AlphaCellModel model = modelIterator.next(); |
|
|
|
AlphaCellModel model = modelIterator.next(); |
|
|
@ -234,7 +230,7 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear |
|
|
|
Collections.sort(resultModelList); |
|
|
|
Collections.sort(resultModelList); |
|
|
|
int size = resultModelList.size(); |
|
|
|
int size = resultModelList.size(); |
|
|
|
if (size > MAX_SIZE) { |
|
|
|
if (size > MAX_SIZE) { |
|
|
|
return resultModelList.subList(0, MAX_SIZE); |
|
|
|
return (SearchResult) resultModelList.subList(0, MAX_SIZE); |
|
|
|
} |
|
|
|
} |
|
|
|
return resultModelList; |
|
|
|
return resultModelList; |
|
|
|
} |
|
|
|
} |
|
|
@ -259,7 +255,7 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear |
|
|
|
} |
|
|
|
} |
|
|
|
//trimToSize(cellModels);
|
|
|
|
//trimToSize(cellModels);
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
List<AlphaCellModel> list = new ArrayList<>(); |
|
|
|
SearchResult list = new SearchResult(); |
|
|
|
list.add(cellModel); |
|
|
|
list.add(cellModel); |
|
|
|
recentKVModelMap.put(searchKey, list); |
|
|
|
recentKVModelMap.put(searchKey, list); |
|
|
|
} |
|
|
|
} |
|
|
|