Commit 2c3613a0 authored by zhang_z's avatar zhang_z

搜索栏替换;

parent 63ba06a2
......@@ -3,8 +3,6 @@
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/TangKuPos.iml" filepath="$PROJECT_DIR$/TangKuPos.iml" />
<module fileurl="file://C:\Users\JM_DEV\AndroidStudioProjects\TangKuPos2\TangKuPos.iml" filepath="C:\Users\JM_DEV\AndroidStudioProjects\TangKuPos2\TangKuPos.iml" />
<module fileurl="file://D:\Work\Android\AndroidProject\XingData\TangKuPos\TangKuPos2.iml" filepath="D:\Work\Android\AndroidProject\XingData\TangKuPos\TangKuPos2.iml" />
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
</modules>
</component>
......
package com.xingdata.zzdpos.ui.manage.sssku;
import android.view.MotionEvent;
import android.view.inputmethod.EditorInfo;
import com.blankj.utilcode.util.ActivityUtils;
import com.blankj.utilcode.util.KeyboardUtils;
import com.blankj.utilcode.util.StringUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.xingdata.zzdpos.C;
import com.xingdata.zzdpos.R;
......@@ -54,17 +51,10 @@ public class SsskuActivity extends BaseActivity<SsskuPresenter, ActivitySsskuBin
public void initView() {
this.showTitleBarByTitleMode(C.TITLE_MODE.SKU_MANAGER);
this.loadRootFragment(R.id.f_sssku, mManagerFragment);
mViewBinding.btnBack.setOnClickListener(view -> getTopFragment().onBackPressedSupport());
mViewBinding.etSearch.setOnEditorActionListener((textView, i, keyEvent) -> {
if (i == EditorInfo.IME_ACTION_SEARCH && !StringUtils.isEmpty(textView.getText())) {
KeyboardUtils.hideSoftInput(textView);
mPresenter.searchSku(textView.getText().toString());
}
return false;
});
mViewBinding.btnScan.setOnClickListener(view -> mPresenter.clickScan(mViewBinding.getTitleMode()));
mViewBinding.btnMenu.setOnClickListener(view -> mPresenter.clickSkuMenu());
mViewBinding.vSearch.setOnSearchListener(keyword -> mPresenter.searchSku(keyword));
}
@Override
......@@ -128,18 +118,17 @@ public class SsskuActivity extends BaseActivity<SsskuPresenter, ActivitySsskuBin
@Override
public void showSearchFragment(int searchType) {
if (mSearchFragment.isAdded()) return;
mViewBinding.etSearch.requestFocus();
KeyboardUtils.showSoftInput(mViewBinding.etSearch);
this.showTitleBarByTitleMode(searchType);
mViewBinding.vSearch.clear();
mViewBinding.vSearch.showSoftInput();
this.start(mSearchFragment.setKeyword("").setSearchType(searchType));
}
@Override
public void showSearchFragment(String keyword, int searchType) {
if (mSearchFragment.isAdded()) return;
mViewBinding.etSearch.requestFocus();
KeyboardUtils.showSoftInput(mViewBinding.etSearch);
this.showTitleBarByTitleMode(searchType);
mViewBinding.vSearch.setText(keyword);
this.start(mSearchFragment.setKeyword(keyword).setSearchType(searchType));
}
......@@ -162,7 +151,7 @@ public class SsskuActivity extends BaseActivity<SsskuPresenter, ActivitySsskuBin
mScanFragment.setOnBackPressedListener(this::backToAddFragment);
break;
}
KeyboardUtils.hideSoftInput(mViewBinding.etSearch);
mViewBinding.vSearch.hideSoftInput();
this.start(mScanFragment);
}
......@@ -306,13 +295,13 @@ public class SsskuActivity extends BaseActivity<SsskuPresenter, ActivitySsskuBin
private void showTitleBarByTitleMode(int titleMode) {
if (mViewBinding.getTitleMode() == titleMode) return;
mViewBinding.setTitleMode(titleMode);
mViewBinding.etSearch.setText("");
mViewBinding.vSearch.clear();
switch (titleMode) {
case C.TITLE_MODE.SKU:
mViewBinding.etSearch.setHint(R.string.sssku_search_hint);
mViewBinding.vSearch.setHint(getString(R.string.sssku_search_hint));
break;
case C.TITLE_MODE.PKG:
mViewBinding.etSearch.setHint(R.string.sssku_search_hint);
mViewBinding.vSearch.setHint(getString(R.string.sssku_search_hint));
break;
case C.TITLE_MODE.SKU_DETAIL:
break;
......@@ -323,7 +312,7 @@ public class SsskuActivity extends BaseActivity<SsskuPresenter, ActivitySsskuBin
* 重置搜索栏
*/
private void resetSearchBar() {
mViewBinding.etSearch.setText("");
mViewBinding.vSearch.clear();
mViewBinding.clTitle.requestFocus();
}
......
......@@ -2,9 +2,7 @@ package com.xingdata.zzdpos.ui.marketing.ms;
import android.view.MotionEvent;
import android.view.inputmethod.EditorInfo;
import com.blankj.utilcode.util.KeyboardUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.xingdata.zzdpos.C;
import com.xingdata.zzdpos.R;
......@@ -47,13 +45,7 @@ public class MsActivity<Sku extends BaseSku> extends BaseActivity<MsPresenter, A
this.loadRootFragment(R.id.f_ms, mManagerFragment);
mViewBinding.setTitleMode(C.TITLE_MODE.TEXT);
mViewBinding.btnBack.setOnClickListener(view -> getTopFragment().onBackPressedSupport());
mViewBinding.etSearch.setOnEditorActionListener((textView, i, keyEvent) -> {
if (i == EditorInfo.IME_ACTION_SEARCH) {
KeyboardUtils.hideSoftInput(textView);
mPresenter.clickSearchButton(textView.getText().toString());
}
return false;
});
mViewBinding.vSearch.setOnSearchListener(keyword -> mPresenter.clickSearchButton(keyword));
}
@Override
......@@ -92,12 +84,15 @@ public class MsActivity<Sku extends BaseSku> extends BaseActivity<MsPresenter, A
@Override
public void showSearchFragment(int searchType) {
this.showTitleBarByTitleMode(searchType);
mViewBinding.vSearch.clear();
mViewBinding.vSearch.showSoftInput();
this.start(mSearchFragment.setKeyword("").setSearchType(searchType));
}
@Override
public void showSearchFragment(String keyword, int searchType) {
this.showTitleBarByTitleMode(searchType);
mViewBinding.vSearch.setText(keyword);
this.start(mSearchFragment.setKeyword(keyword).setSearchType(searchType));
}
......@@ -196,13 +191,13 @@ public class MsActivity<Sku extends BaseSku> extends BaseActivity<MsPresenter, A
private void showTitleBarByTitleMode(int titleMode) {
if (mViewBinding.getTitleMode() == titleMode) return;
mViewBinding.setTitleMode(titleMode);
mViewBinding.etSearch.setText("");
mViewBinding.vSearch.clear();
switch (titleMode) {
case C.TITLE_MODE.SKU:
mViewBinding.etSearch.setHint(R.string.ms_editor_type_gift_search_hint);
mViewBinding.vSearch.setHint(getString(R.string.ms_editor_type_gift_search_hint));
break;
case C.TITLE_MODE.GIFT:
mViewBinding.etSearch.setHint(R.string.ms_editor_type_gift_search_hint);
mViewBinding.vSearch.setHint(getString(R.string.ms_editor_type_gift_search_hint));
break;
}
}
......
......@@ -63,6 +63,13 @@ public class SearchBar extends ConstraintLayout {
KeyboardUtils.showSoftInput(mViewBinding.etSearch);
}
/**
* 隐藏软键盘
*/
public void hideSoftInput() {
KeyboardUtils.hideSoftInput(mViewBinding.etSearch);
}
public SearchBar(Context context, AttributeSet attrs) {
super(context, attrs);
mViewBinding = DataBindingUtil.inflate(LayoutInflater.from(context), R.layout.view_search_bar, this, true);
......
......@@ -33,25 +33,16 @@
android:src="@mipmap/back_black"
app:layout_constraintLeft_toLeftOf="parent" />
<LinearLayout
<com.xingdata.zzdpos.view.SearchBar
android:id="@+id/v_search"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginEnd="@dimen/all_margin"
android:visibility="@{titleMode>1?0:8}"
app:layout_constraintBottom_toTopOf="parent"
android:layout_height="0dp"
android:visibility="@{titleMode>1?View.VISIBLE:View.INVISIBLE}"
app:inputType="text"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="@id/btn_back"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="parent">
<EditText
android:id="@+id/et_search"
style="@style/searchBarEditor"
android:layout_width="0dp"
android:layout_weight="1"
android:inputType="text"
android:labelFor="@+id/et_search" />
</LinearLayout>
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_title"
......
......@@ -37,25 +37,16 @@
android:src="@mipmap/back_black"
app:layout_constraintLeft_toLeftOf="parent" />
<LinearLayout
<com.xingdata.zzdpos.view.SearchBar
android:id="@+id/v_search"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginEnd="@dimen/all_margin"
android:visibility="@{titleMode==1||titleMode==6||titleMode==8||titleMode==9||titleMode==10?8:0}"
app:layout_constraintBottom_toTopOf="parent"
android:layout_height="0dp"
android:visibility="@{titleMode==1||titleMode==6||titleMode==8||titleMode==9||titleMode==10?View.VISIBLE:View.INVISIBLE}"
app:inputType="text"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="@id/btn_back"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="parent">
<EditText
android:id="@+id/et_search"
style="@style/searchBarEditor"
android:layout_width="0dp"
android:layout_weight="1"
android:inputType="text"
android:labelFor="@+id/et_search" />
</LinearLayout>
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_title"
......
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