use of cn.nicolite.palm300heroes.presenter.SearchPresenter in project Palm300Heroes by nicolite.
the class SearchActivity method doBusiness.
@Override
protected void doBusiness() {
recyclerView.setLayoutManager(new GridLayoutManager(context, 3, OrientationHelper.VERTICAL, false));
adapter = new SearchAdapter(context, searchHistoryList);
recyclerView.setAdapter(adapter);
adapter.setOnItemClickListener(new SearchAdapter.OnItemClickListener() {
@Override
public void onItemClick(View view, int position, long itemId) {
SearchHistory searchHistory = searchHistoryList.get(position);
toolbarSearchEdit.setText(searchHistory.getHistory());
startSearchResult();
}
});
searchPresenter = new SearchPresenter(this, this);
searchPresenter.showHistory(type);
adapter.setOnItemLongClickListener(new SearchAdapter.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(View view, final int position, long itemId) {
final CommonDialog commonDialog = new CommonDialog(context);
commonDialog.setMessage("确定删除该条记录?").setPositiveButton("确认", new View.OnClickListener() {
@Override
public void onClick(View view) {
searchPresenter.deleteHistoryItem(searchHistoryList.get(position));
searchHistoryList.remove(position);
adapter.notifyItemRemoved(position);
commonDialog.dismiss();
}
}).setNegativeButton("取消", null).show();
return true;
}
});
toolbarSearchEdit.setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View view, int i, KeyEvent keyEvent) {
if (i == KeyEvent.KEYCODE_ENTER && keyEvent.getAction() == KeyEvent.ACTION_UP) {
KeyBoardUtils.hideSoftInput(context, getWindow());
searchPresenter.addHistory(type, toolbarSearchEdit.getText().toString());
startSearchResult();
return true;
}
return false;
}
});
}
Aggregations