Commit 9f5d3859 authored by zhang_z's avatar zhang_z

修改搜索框;

parent e33d96e3
......@@ -22,6 +22,12 @@ import com.xingdata.zzdpos.util.Global;
public class SearchBar extends ConstraintLayout {
private ViewSearchBarBinding mViewBinding;
private boolean isEmptyEnabled;
public void setEmptyEnabled(boolean emptyEnabled) {
isEmptyEnabled = emptyEnabled;
}
public interface OnSearchListener {
void onSearch(String keyword);
}
......@@ -61,7 +67,7 @@ public class SearchBar extends ConstraintLayout {
* 显示软键盘
*/
public void showSoftInput() {
Global.setFocus(mViewBinding.etSearch,getContext());
Global.setFocus(mViewBinding.etSearch, getContext());
// KeyboardUtils.showSoftInput(mViewBinding.etSearch);
}
......@@ -79,20 +85,20 @@ public class SearchBar extends ConstraintLayout {
mViewBinding.etSearch.setOnEditorActionListener((textView, i, keyEvent) -> {
if (i == EditorInfo.IME_ACTION_SEARCH) {
String str = mViewBinding.etSearch.getText().toString();
if (StringUtils.isEmpty(str)) {
if (StringUtils.isEmpty(str) && !isEmptyEnabled) {
ToastUtils.showShort("请输入搜索内容");
return false;
return true;
}
KeyboardUtils.hideSoftInput(mViewBinding.etSearch);
mOnSearchListener.onSearch(str);
}
return false;
return true;
});
mViewBinding.tvSearch.setOnClickListener(view -> {
String str = mViewBinding.etSearch.getText().toString();
if (StringUtils.isEmpty(str)) {
if (StringUtils.isEmpty(str) && !isEmptyEnabled) {
ToastUtils.showShort("请输入搜索内容");
this.showSoftInput();
return;
}
KeyboardUtils.hideSoftInput(mViewBinding.etSearch);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment