|
|
@@ -19,6 +19,7 @@ import android.widget.TextView;
|
|
|
import com.sheep.gamegroup.absBase.BaseActivity;
|
|
|
import com.sheep.gamegroup.model.entity.SearchAppRecord;
|
|
|
import com.sheep.gamegroup.util.ListUtil;
|
|
|
+import com.sheep.gamegroup.util.LogUtil;
|
|
|
import com.sheep.gamegroup.util.MyDbManager;
|
|
|
import com.sheep.gamegroup.util.ViewUtil;
|
|
|
import com.sheep.gamegroup.view.adapter.ArrayAdapter;
|
|
|
@@ -89,6 +90,10 @@ public class ActSearchApp extends BaseActivity {
|
|
|
ListUtil.addAll(searchRecordList, allSearchRecordList, 10);
|
|
|
inputAdapter.notifyDataSetChanged();
|
|
|
MyDbManager.getInstance().hideSearchApp(item);
|
|
|
+ if(searchRecordList.isEmpty()){
|
|
|
+ frame_container.setVisibility(View.VISIBLE);
|
|
|
+ search_app_list.setVisibility(View.INVISIBLE);
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
return true;
|
|
|
@@ -133,7 +138,12 @@ public class ActSearchApp extends BaseActivity {
|
|
|
@Override
|
|
|
public void afterTextChanged(Editable editable) {
|
|
|
title_search_input.removeCallbacks(autoSearchRunnable);
|
|
|
- title_search_input.postDelayed(autoSearchRunnable, 1000L);//1秒后自动搜索
|
|
|
+ if(editable.toString().isEmpty() && !searchRecordList.isEmpty()){//输入框内容为空且有搜索记录时显示搜索记录
|
|
|
+ search_app_list.setVisibility(View.VISIBLE);
|
|
|
+ frame_container.setVisibility(View.INVISIBLE);
|
|
|
+ } else {
|
|
|
+ title_search_input.postDelayed(autoSearchRunnable, 1000L);//1秒后自动搜索
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
@@ -188,29 +198,24 @@ public class ActSearchApp extends BaseActivity {
|
|
|
|
|
|
//尝试搜索游戏
|
|
|
private void toSearchApp() {
|
|
|
- String inputText = title_search_input.getText().toString();
|
|
|
- if (TextUtils.isEmpty(inputText)) {
|
|
|
- fgtSearchApp.clear();
|
|
|
- fgtSearchApp.notifyDataSetChanged();
|
|
|
- search_app_list.setVisibility(View.VISIBLE);
|
|
|
- frame_container.setVisibility(View.INVISIBLE);
|
|
|
- return;
|
|
|
- }
|
|
|
search_app_list.setVisibility(View.INVISIBLE);
|
|
|
frame_container.setVisibility(View.VISIBLE);
|
|
|
- //保存搜索到数据库
|
|
|
- SearchAppRecord searchRecord = searchRecordMap.get(inputText);
|
|
|
- if(searchRecord == null) {
|
|
|
- searchRecord = new SearchAppRecord();
|
|
|
- searchRecord.setInput(inputText);
|
|
|
- searchRecordList.add(searchRecord);
|
|
|
- allSearchRecordList.add(searchRecord);
|
|
|
- searchRecordMap.put(inputText, searchRecord);
|
|
|
+ String inputText = title_search_input.getText().toString();
|
|
|
+ if (!TextUtils.isEmpty(inputText)) {
|
|
|
+ //保存搜索到数据库
|
|
|
+ SearchAppRecord searchRecord = searchRecordMap.get(inputText);
|
|
|
+ if(searchRecord == null) {
|
|
|
+ searchRecord = new SearchAppRecord();
|
|
|
+ searchRecord.setInput(inputText);
|
|
|
+ searchRecordList.add(searchRecord);
|
|
|
+ allSearchRecordList.add(searchRecord);
|
|
|
+ searchRecordMap.put(inputText, searchRecord);
|
|
|
+ }
|
|
|
+ searchRecord.setTime(System.currentTimeMillis());
|
|
|
+ searchRecord.addCount();
|
|
|
+ MyDbManager.getInstance().saveOrUpdate(searchRecord);
|
|
|
+ inputAdapter.notifyDataSetChanged();
|
|
|
}
|
|
|
- searchRecord.setTime(System.currentTimeMillis());
|
|
|
- searchRecord.addCount();
|
|
|
- MyDbManager.getInstance().saveOrUpdate(searchRecord);
|
|
|
- inputAdapter.notifyDataSetChanged();
|
|
|
fgtSearchApp.toSearch(inputText);
|
|
|
}
|
|
|
}
|