|
@@ -83,7 +83,10 @@ public class ActSearchApp extends BaseActivity {
|
|
|
item_search_record_x.setOnClickListener(new View.OnClickListener() {
|
|
item_search_record_x.setOnClickListener(new View.OnClickListener() {
|
|
|
@Override
|
|
@Override
|
|
|
public void onClick(View view) {
|
|
public void onClick(View view) {
|
|
|
- searchRecordList.remove(item);
|
|
|
|
|
|
|
+ searchRecordMap.remove(item.getInput());
|
|
|
|
|
+ allSearchRecordList.remove(item);
|
|
|
|
|
+ searchRecordList.clear();
|
|
|
|
|
+ ListUtil.addAll(searchRecordList, allSearchRecordList, 10);
|
|
|
inputAdapter.notifyDataSetChanged();
|
|
inputAdapter.notifyDataSetChanged();
|
|
|
MyDbManager.getInstance().hideSearchApp(item);
|
|
MyDbManager.getInstance().hideSearchApp(item);
|
|
|
}
|
|
}
|
|
@@ -92,7 +95,6 @@ public class ActSearchApp extends BaseActivity {
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
search_app_list.setAdapter(inputAdapter);
|
|
search_app_list.setAdapter(inputAdapter);
|
|
|
- frame_container.setVisibility(View.INVISIBLE);
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private ArrayAdapter<SearchAppRecord> inputAdapter;
|
|
private ArrayAdapter<SearchAppRecord> inputAdapter;
|
|
@@ -142,22 +144,30 @@ public class ActSearchApp extends BaseActivity {
|
|
|
title_search_commit.performClick();
|
|
title_search_commit.performClick();
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
-
|
|
|
|
|
|
|
+ private Comparator<SearchAppRecord> comparator = new Comparator<SearchAppRecord>() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public int compare(SearchAppRecord item1, SearchAppRecord item2) {
|
|
|
|
|
+ return item2.getCount() - item1.getCount();
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
@Override
|
|
@Override
|
|
|
public void initData() {
|
|
public void initData() {
|
|
|
//初始化搜索历史
|
|
//初始化搜索历史
|
|
|
List<SearchAppRecord> newSgrList = MyDbManager.getInstance().getAllSearchAppRecord();
|
|
List<SearchAppRecord> newSgrList = MyDbManager.getInstance().getAllSearchAppRecord();
|
|
|
- ListUtil.addAll(searchRecordList, newSgrList);
|
|
|
|
|
- Collections.sort(searchRecordList, new Comparator<SearchAppRecord>() {
|
|
|
|
|
- @Override
|
|
|
|
|
- public int compare(SearchAppRecord item1, SearchAppRecord item2) {
|
|
|
|
|
- return item2.getCount() - item1.getCount();
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- for (SearchAppRecord item : searchRecordList) {
|
|
|
|
|
|
|
+ ListUtil.addAll(allSearchRecordList, newSgrList);
|
|
|
|
|
+ Collections.sort(allSearchRecordList, comparator);
|
|
|
|
|
+ ListUtil.addAll(searchRecordList, allSearchRecordList, 10);
|
|
|
|
|
+ for (SearchAppRecord item : allSearchRecordList) {
|
|
|
searchRecordMap.put(item.getInput(), item);
|
|
searchRecordMap.put(item.getInput(), item);
|
|
|
}
|
|
}
|
|
|
inputAdapter.notifyDataSetChanged();
|
|
inputAdapter.notifyDataSetChanged();
|
|
|
|
|
+ if(searchRecordList.isEmpty()) {
|
|
|
|
|
+ frame_container.setVisibility(View.VISIBLE);
|
|
|
|
|
+ search_app_list.setVisibility(View.INVISIBLE);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ frame_container.setVisibility(View.INVISIBLE);
|
|
|
|
|
+ search_app_list.setVisibility(View.VISIBLE);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@OnClick({R.id.title_search_commit, R.id.title_img_back})
|
|
@OnClick({R.id.title_search_commit, R.id.title_img_back})
|
|
@@ -173,6 +183,7 @@ public class ActSearchApp extends BaseActivity {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
List<SearchAppRecord> searchRecordList = new ArrayList<>();
|
|
List<SearchAppRecord> searchRecordList = new ArrayList<>();
|
|
|
|
|
+ List<SearchAppRecord> allSearchRecordList = new ArrayList<>();
|
|
|
Map<String, SearchAppRecord> searchRecordMap = new HashMap<>();
|
|
Map<String, SearchAppRecord> searchRecordMap = new HashMap<>();
|
|
|
|
|
|
|
|
//尝试搜索游戏
|
|
//尝试搜索游戏
|
|
@@ -193,6 +204,7 @@ public class ActSearchApp extends BaseActivity {
|
|
|
searchRecord = new SearchAppRecord();
|
|
searchRecord = new SearchAppRecord();
|
|
|
searchRecord.setInput(inputText);
|
|
searchRecord.setInput(inputText);
|
|
|
searchRecordList.add(searchRecord);
|
|
searchRecordList.add(searchRecord);
|
|
|
|
|
+ allSearchRecordList.add(searchRecord);
|
|
|
searchRecordMap.put(inputText, searchRecord);
|
|
searchRecordMap.put(inputText, searchRecord);
|
|
|
}
|
|
}
|
|
|
searchRecord.setTime(System.currentTimeMillis());
|
|
searchRecord.setTime(System.currentTimeMillis());
|