Commit 34daf316 authored by 陈前's avatar 陈前

扫码

parent b4c13a57
......@@ -20,6 +20,7 @@ import com.xingdata.zzdpos.model.Pager;
import com.xingdata.zzdpos.ui.dialog.LoadingDialog;
import com.xingdata.zzdpos.ui.manage.otherselect.fragment.OtherDetailFragment;
import com.xingdata.zzdpos.ui.manage.otherselect.fragment.OtherListFragment;
import com.xingdata.zzdpos.ui.scan.ScanFragment;
import com.xingdata.zzdpos.util.Global;
import com.xingdata.zzdpos.util.OnClickListener;
......@@ -29,6 +30,7 @@ public class OtherSelectActivity extends BaseActivity<OtherSelectPresenter,
private OtherListFragment mOtherListFragment = new OtherListFragment();
private OtherDetailFragment mOtherDetailFragment = new OtherDetailFragment();
LoadingDialog mLoadingDialog = new LoadingDialog();
private ScanFragment mScanFragment;
@Override
public int getLayoutId() {
......@@ -37,20 +39,32 @@ public class OtherSelectActivity extends BaseActivity<OtherSelectPresenter,
@Override
public void initView() {
mViewBinding.lyTitle.ivRight.setVisibility(View.GONE);
mViewBinding.lyTitle.ivRight.setVisibility(View.VISIBLE);
mViewBinding.lyTitle.edTitle.setVisibility(View.GONE);
mViewBinding.lyTitle.tvTitle.setText("邻库查询");
mViewBinding.lyTitle.tvTitle.setVisibility(View.VISIBLE);
FragmentUtils.add(getSupportFragmentManager(), mOtherListFragment, mViewBinding
.fragmentContainer.getId(), false, true);
mViewBinding.edTitle.setOnEditorActionListener(new TextView.OnEditorActionListener() {
mViewBinding.lyTitle.ivRight.setImageResource(R.mipmap.but_sweep_yard);
mViewBinding.lyTitle.ivRight.setOnClickListener(new OnClickListener() {
@Override
public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
if (i == EditorInfo.IME_ACTION_SEARCH) {
search(mViewBinding.edTitle.getText().toString().trim());
protected void myOnClickListener(View v) {
if (mScanFragment == null) {
mScanFragment = new ScanFragment();
mScanFragment.setOnScanCompletedListener(new ScanFragment.OnScanCompletedListener() {
@Override
public void OnScanCompleted(String barcode) {
mOtherListFragment.search(barcode);
}
});
}
if (!mScanFragment.isAdded()) {
FragmentUtils.add(getSupportFragmentManager(), mScanFragment, mViewBinding
.fragmentContainer.getId(), false, true);
}
return true;
}
});
mViewBinding.lyTitle.setOnClickListener(new OnClickListener() {
......@@ -60,8 +74,8 @@ public class OtherSelectActivity extends BaseActivity<OtherSelectPresenter,
mViewBinding.lyTitle.edTitle.clearFocus();
}
if (mOtherDetailFragment.isAdded()) {
mOtherDetailFragment.pop();
if (mScanFragment.isAdded()) {
mScanFragment.pop();
return;
}
finish();
......@@ -84,11 +98,12 @@ public class OtherSelectActivity extends BaseActivity<OtherSelectPresenter,
@Override
public void loadOssku(Pager<Ossku> osskuList, boolean isRefresh) {
if (mOtherDetailFragment.isAdded()) {
mOtherDetailFragment.pop();
public void loadOssku(Pager<Ossku> osskuList, boolean isRefresh, String keyWord) {
if (mScanFragment.isAdded()) {
mScanFragment.pop();
}
mOtherListFragment.setData(osskuList, isRefresh);
mOtherListFragment.setKeyword(keyWord);
}
@Override
......@@ -104,17 +119,6 @@ public class OtherSelectActivity extends BaseActivity<OtherSelectPresenter,
super.onPause();
}
private void search(String string) {
KeyboardUtils.hideSoftInput(this);
if (string.length() == 0) {
ToastUtils.showShort("请输入搜索内容");
return;
}
mPresenter.searchGoodsFirst(string);
}
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
......
......@@ -20,7 +20,7 @@ public interface OtherSelectContract {
/**
* 加载列表
*/
void loadOssku(Pager<Ossku> osskuList, boolean isRefresh);
void loadOssku(Pager<Ossku> osskuList, boolean isRefresh,String wd);
void showOsskuDetail(Ossku ossku);
}
......
......@@ -40,9 +40,11 @@ public class OtherSelectPresenter extends OtherSelectContract.Presenter {
.subscribe(osskus -> {
if (osskus.getTotalRow() == 0) {
ToastUtils.showShort("没有搜到当前商品,请重新输入");
}else {
mView.loadOssku(osskus, nowPageNumber == 1,keyword);
}
//判断是否能加载更多
mView.loadOssku(osskus, nowPageNumber == 1);
}, throwable -> {
ToastUtils.showShort(throwable.getMessage());
});
......
......@@ -7,6 +7,7 @@ import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.KeyEvent;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.TextView;
......@@ -51,7 +52,15 @@ public class OtherListFragment extends BaseFragment<OtherSelectPresenter, Fragme
mViewBinding.recyclerOtherSelcet.setLayoutManager(new LinearLayoutManager(getActivity()));
mViewBinding.recyclerOtherSelcet.setAdapter(mOtherSelectAdapter);
mViewBinding.edTitle.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
if (i == EditorInfo.IME_ACTION_SEARCH) {
search(mViewBinding.edTitle.getText().toString().trim());
}
return true;
}
});
// mOtherSelectAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
// @Override
// public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
......@@ -102,11 +111,25 @@ public class OtherListFragment extends BaseFragment<OtherSelectPresenter, Fragme
}
public void setKeyword(String s){
mViewBinding.edTitle.setText(s);
}
private View getEmptyView(int resHint) {
View view = getLayoutInflater().inflate(R.layout.view_empty, null);
((TextView) view.findViewById(R.id.tv_empty)).setText(resHint);
return view;
}
public void search(String string) {
KeyboardUtils.hideSoftInput(getActivity());
if (string.length() == 0) {
ToastUtils.showShort("请输入搜索内容");
return;
}
mPresenter.searchGoodsFirst(string);
}
}
......@@ -2,7 +2,9 @@ package com.xingdata.zzdpos.ui.manage.replenishment;
import android.view.MotionEvent;
import android.view.View;
import com.blankj.utilcode.util.FragmentUtils;
import com.blankj.utilcode.util.KeyboardUtils;
import com.xingdata.zzdpos.R;
import com.xingdata.zzdpos.base.BaseActivity;
......@@ -12,7 +14,9 @@ import com.xingdata.zzdpos.model.Sssku;
import com.xingdata.zzdpos.ui.dialog.LoadingDialog;
import com.xingdata.zzdpos.ui.manage.replenishment.fragment.ReplenishmentDetailFragment;
import com.xingdata.zzdpos.ui.manage.replenishment.fragment.ReplenishmentFragment;
import com.xingdata.zzdpos.ui.scan.ScanFragment;
import com.xingdata.zzdpos.util.Global;
import com.xingdata.zzdpos.util.OnClickListener;
import java.util.List;
......@@ -22,6 +26,7 @@ public class ReplenishmentActivity extends BaseActivity<ReplenishmentPresenter,
private ReplenishmentDetailFragment mReplenishmentDetailFragment = new
ReplenishmentDetailFragment();
private boolean isAllowFragment = true;
private ScanFragment mScanFragment;
LoadingDialog mLoadingDialog = new LoadingDialog();
@Override
......@@ -32,7 +37,46 @@ public class ReplenishmentActivity extends BaseActivity<ReplenishmentPresenter,
@Override
public void initView() {
mPresenter.queryPsbList();
mViewBinding.icTitle.edTitle.setVisibility(View.GONE);
mViewBinding.icTitle.tvTitle.setText(R.string.replenishment_meun);
mViewBinding.icTitle.tvTitle.setVisibility(View.VISIBLE);
mViewBinding.icTitle.ivRight.setImageResource(R.mipmap.but_sweep_yard);
mViewBinding.icTitle.ivRight.setOnClickListener(new OnClickListener() {
@Override
protected void myOnClickListener(View v) {
if (mScanFragment == null) {
mScanFragment = new ScanFragment();
mScanFragment.setOnScanCompletedListener(new ScanFragment.OnScanCompletedListener() {
@Override
public void OnScanCompleted(String barcode) {
mReplenishmentDetailFragment.scrollToItem(barcode);
}
});
}
if (!mScanFragment.isAdded()) {
start(mScanFragment);
}
}
});
mViewBinding.icTitle.setOnClickListener(new OnClickListener() {
@Override
protected void myOnClickListener(View v) {
if (mReplenishmentDetailFragment.isAdded()) {
mReplenishmentDetailFragment.pop();
mViewBinding.icTitle.tvTitle.setText(R.string.replenishment_meun);
return;
}
if (mScanFragment.isAdded()) {
mScanFragment.pop();
return;
}
finish();
}
});
mViewBinding.icTitle.ivRight.setVisibility(View.GONE);
}
@Override
......@@ -58,6 +102,7 @@ public class ReplenishmentActivity extends BaseActivity<ReplenishmentPresenter,
if (isAllowFragment) {
isAllowFragment = false;
mReplenishmentDetailFragment.setSsskuList(ssskuList);
changeTitle("一键补货", true);
start(mReplenishmentDetailFragment);
}
......@@ -68,6 +113,7 @@ public class ReplenishmentActivity extends BaseActivity<ReplenishmentPresenter,
if (isAllowFragment) {
isAllowFragment = false;
mReplenishmentDetailFragment.setPsb(psb);
changeTitle("定货详情", true);
start(mReplenishmentDetailFragment);
}
......@@ -95,6 +141,17 @@ public class ReplenishmentActivity extends BaseActivity<ReplenishmentPresenter,
isAllowFragment = is;
}
@Override
public void changeTitle(String s, boolean b) {
mViewBinding.icTitle.tvTitle.setText(s);
if (b) {
mViewBinding.icTitle.ivRight.setVisibility(View.VISIBLE);
} else {
mViewBinding.icTitle.ivRight.setVisibility(View.GONE);
}
}
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
Global.clickHideKeyboard(ev, this);
......
......@@ -22,6 +22,7 @@ public interface ReplenishmentContract {
void isAllowFragment(Boolean is);
void changeTitle(String s,boolean b);
/**
......@@ -55,6 +56,11 @@ public interface ReplenishmentContract {
*/
public abstract void clickAdd();
/**
* 补货订货页面 - 改标题
*/
public abstract void changeTitle(String s,boolean b);
/**
* 补货订货页面 - 查询门店订货订单
*/
......
......@@ -43,6 +43,11 @@ public class ReplenishmentPresenter extends ReplenishmentContract.Presenter {
}
@Override
public void changeTitle(String s, boolean b) {
mView.changeTitle(s,b);
}
@Override
public void queryPsbList() {
mView.isShowLoading(true);
......
......@@ -54,9 +54,7 @@ public class ReplenishmentDetailFragment extends BaseFragment<ReplenishmentPrese
@Override
public void initView() {
mViewBinding.lyTitle.edTitle.setVisibility(View.GONE);
mViewBinding.lyTitle.tvTitle.setVisibility(View.VISIBLE);
mViewBinding.lyTitle.tvTitle.setText("定货详情");
mViewBinding.edTitle.setHint(R.string.inventory_add_et_hint);
mViewBinding.edTitle.setText("");
Drawable drawableTop = getResources().getDrawable(R.mipmap.but_unfurled);
......@@ -66,12 +64,7 @@ public class ReplenishmentDetailFragment extends BaseFragment<ReplenishmentPrese
mViewBinding.tvShopTitle.setCompoundDrawables(null, null, drawableTop, null);
mViewBinding.tvSupplierTitle.setCompoundDrawables(null, null, drawableTop, null);
initRecycycler();
mViewBinding.lyTitle.setOnClickListener(new OnClickListener() {
@Override
protected void myOnClickListener(View v) {
pop();
}
});
mViewBinding.tvShopTitle.setOnClickListener(new OnClickListener() {
@Override
protected void myOnClickListener(View v) {
......@@ -96,7 +89,7 @@ public class ReplenishmentDetailFragment extends BaseFragment<ReplenishmentPrese
}
}
});
mViewBinding.lyTitle.ivRight.setVisibility(View.GONE);
mViewBinding.edTitle.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
......@@ -107,9 +100,7 @@ public class ReplenishmentDetailFragment extends BaseFragment<ReplenishmentPrese
return true;
}
});
mViewBinding.lyTitle.ivBack.setOnClickListener(view -> {
this.pop();
});
mViewBinding.btnOk.setOnClickListener(view -> {
if (mPsb == null || mPsb.getPsbStatus() == null) {
......@@ -269,12 +260,13 @@ public class ReplenishmentDetailFragment extends BaseFragment<ReplenishmentPrese
return view;
}
private void scrollToItem(String string) {
public void scrollToItem(String string) {
if (string.length() == 0) {
ToastUtils.showShort("请输入搜索内容");
return;
}
Pattern pattern = Pattern.compile(string, Pattern.CASE_INSENSITIVE);
for (int i = 0; i < mReplenishmentDetailAdapter.getData().size(); i++) {
......@@ -304,4 +296,10 @@ public class ReplenishmentDetailFragment extends BaseFragment<ReplenishmentPrese
ToastUtils.showShort("没有找到相关货品");
}
@Override
public boolean onBackPressedSupport() {
mPresenter.changeTitle(getResources().getString(R.string.replenishment_meun), false);
return super.onBackPressedSupport();
}
}
......@@ -65,16 +65,7 @@ public class ReplenishmentFragment extends BaseFragment<ReplenishmentPresenter,
mViewBinding.btnAdd.setOnClickListener(view -> {
mPresenter.clickAdd();
});
mViewBinding.icTitle.edTitle.setVisibility(View.GONE);
mViewBinding.icTitle.tvTitle.setText("补货订货");
mViewBinding.icTitle.tvTitle.setVisibility(View.VISIBLE);
mViewBinding.icTitle.setOnClickListener(new OnClickListener() {
@Override
protected void myOnClickListener(View v) {
getActivity().finish();
}
});
mViewBinding.icTitle.ivRight.setVisibility(View.GONE);
mViewBinding.edTitle.setHint("请输入供货商名称");
mViewBinding.edTitle.setInputType(InputType.TYPE_CLASS_TEXT);
......
......@@ -12,31 +12,15 @@
android:id="@+id/ly_title"
layout="@layout/title_order" />
<EditText
android:id="@+id/ed_title"
style="@style/searchBarEditor"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_below="@id/ly_title"
android:layout_marginBottom="@dimen/padding_small"
android:layout_marginEnd="@dimen/all_bounced_padding"
android:layout_marginStart="@dimen/all_bounced_padding"
android:layout_marginTop="@dimen/padding_small"
android:drawablePadding="@dimen/all_padding"
android:hint="@string/other_select_edit_hint"
android:textColor="@color/black_likui"
android:inputType="text"
android:imeOptions="actionSearch"
android:textSize="@dimen/all_text_size_low"
/>
<FrameLayout
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/ed_title"
android:background="@color/gray_zhouyu"></FrameLayout>
android:layout_below="@id/ly_title"
android:background="@color/gray_zhouyu">
</FrameLayout>
<View
android:layout_width="match_parent"
......@@ -44,11 +28,7 @@
android:layout_below="@id/ly_title"
android:background="@color/gray_huanggai" />
<View
android:layout_width="match_parent"
android:layout_height="@dimen/view_line_L050"
android:layout_below="@id/ed_title"
android:background="@color/gray_huanggai" />
</RelativeLayout>
</layout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:orientation="vertical">
<include
android:id="@+id/ic_title"
layout="@layout/title_order"
app:layout_constraintTop_toTopOf="parent" />
<View
android:layout_width="match_parent"
android:layout_height="@dimen/view_line_L050"
android:background="@color/gray_huanggai" />
<FrameLayout
android:id="@+id/f_bottom"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
......@@ -20,6 +29,6 @@
</FrameLayout>
</android.support.constraint.ConstraintLayout>
</LinearLayout>
</layout>
\ No newline at end of file
......@@ -10,7 +10,29 @@
android:background="@color/gray_zhouyu"
android:orientation="vertical">
<EditText
android:id="@+id/ed_title"
style="@style/searchBarEditor"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_below="@id/ly_title"
android:layout_marginBottom="@dimen/padding_small"
android:layout_marginEnd="@dimen/all_bounced_padding"
android:layout_marginStart="@dimen/all_bounced_padding"
android:layout_marginTop="@dimen/padding_small"
android:drawablePadding="@dimen/all_padding"
android:hint="@string/other_select_edit_hint"
android:textColor="@color/black_likui"
android:inputType="text"
android:imeOptions="actionSearch"
android:textSize="@dimen/all_text_size_low"
/>
<View
android:layout_width="match_parent"
android:layout_height="@dimen/view_line_L050"
android:layout_below="@id/ed_title"
android:background="@color/gray_huanggai" />
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/srl_product"
android:layout_width="match_parent"
......
......@@ -13,15 +13,6 @@
android:orientation="vertical"
android:splitMotionEvents="false">
<include
android:id="@+id/ic_title"
layout="@layout/title_order"
app:layout_constraintTop_toTopOf="parent" />
<View
android:layout_width="match_parent"
android:layout_height="@dimen/view_line_L050"
android:background="@color/gray_huanggai" />
<EditText
android:id="@+id/ed_title"
style="@style/searchBarEditor"
......
......@@ -63,11 +63,6 @@
android:background="@color/white_caocao"
android:splitMotionEvents="false">
<include
android:id="@+id/ly_title"
layout="@layout/title_order"
app:layout_constraintTop_toTopOf="parent" />
<android.support.constraint.ConstraintLayout
android:id="@+id/cl_default"
......@@ -109,7 +104,6 @@
app:layout_constraintTop_toTopOf="@id/tv_supplier_title" />
<View
android:id="@+id/view_line_left_1"
android:layout_width="match_parent"
......@@ -502,7 +496,7 @@
style="@style/searchBarEditor"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_below="@id/ly_title"
android:layout_alignParentTop="true"
android:layout_marginBottom="@dimen/padding_small"
android:layout_marginEnd="@dimen/all_bounced_padding"
android:layout_marginStart="@dimen/all_bounced_padding"
......
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