Commit 2c3613a0 authored by zhang_z's avatar zhang_z

搜索栏替换;

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