Commit 83b8b62e by 张建升

多個頁面彈出輸入法 清除數據

parent 2d520f03
......@@ -4,6 +4,7 @@ import android.app.Application;
import android.content.Context;
import android.text.InputFilter;
import android.text.InputType;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import com.gingersoft.gsa.cloud.common.bean.BaseResult;
......@@ -63,6 +64,7 @@ import static com.gingersoft.supply_chain.mvp.ui.fragment.supplier.SupplierListF
/**
* ================================================
* Description:
* mod by zjs 单价获取焦点时清空内容
* <p>
* Created by MVPArmsTemplate on 11/24/2020 16:13
* <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
......@@ -198,7 +200,7 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient
}
public List<InfoMultiBean> getFragmentInfo(Context context) {
public List<InfoMultiBean> getFragmentInfo(Context context ,View.OnFocusChangeListener onFocusChangeListener) {
List<InfoMultiBean> infoMultiBeans = new ArrayList<>();
infoMultiBeans.add(new InfoMultiBean(InfoMultiBean.ITEM_TYPE_LINE));
infoMultiBeans.add(new InfoMultiBean(InfoMultiBean.ITEM_TYPE_TITLE, "商品圖片"));
......@@ -209,10 +211,20 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient
infoMultiBeans.add(new MultiInputBean(InfoMultiBean.ITEM_TYPE_INPUT, "食材名稱", true, "請輸入名稱", new InputFilter[]{InputFilterUtils.getLengthFilter(context, 200), InputFilterUtils.getChAndEnAndNumAndPtInputFilter(context)}, InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES));
infoMultiBeans.add(new MultiSelectBean(InfoMultiBean.EDIT_FOOD_ITEM_SELECT, "食材類別", true, "請選擇食材類別", SELECT_FOOD_CATEGORY_REQUEST_CODE, CategorySelectFragment.class));
infoMultiBeans.add(new MultiSelectBean(InfoMultiBean.EDIT_FOOD_ITEM_SELECT, "基本單位", true, "請選擇食材單位", SELECT_PACKAGE_SPECIFICATION_REQUEST_CODE, FoodUnitPageFragment.class));
infoMultiBeans.add(new MultiInputBean(InfoMultiBean.ITEM_TYPE_INPUT, "包裝說明", false, "請輸入包裝說明", new InputFilter[]{InputFilterUtils.getLengthFilter(context, 10), InputFilterUtils.getTypeFilter(context, InputFilterUtils.chAndEnAndNumAndSlash)}));
infoMultiBeans.add(new MultiInputBean(InfoMultiBean.ITEM_TYPE_INPUT, "包裝說明", false, "請輸入包裝說明", new InputFilter[]{InputFilterUtils.getLengthFilter(context, 25), InputFilterUtils.getTypeFilter(context, InputFilterUtils.chAndEnAndNumAndSlash)}));
infoMultiBeans.add(new MultiInputBean(InfoMultiBean.ITEM_TYPE_INPUT, "食材編號", false, "請輸入食材編號", new InputFilter[]{InputFilterUtils.getLengthFilter(context, 32), InputFilterUtils.getEnAndNumInputFilter(context)}));
infoMultiBeans.add(new InfoMultiBean(InfoMultiBean.ITEM_MULTIPLE_BOOLEAN, "是否有SN碼", false, false));
infoMultiBeans.add(new MultiInputBean(InfoMultiBean.ITEM_TYPE_INPUT, "單價($)", false, "請輸入單價,保留2位小數", new InputFilter[]{InputFilterUtils.getLengthFilter(context, 9), new DecimalDigitsInputFilter(context, 2)}, InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL));
// infoMultiBeans.add(new MultiInputBean(InfoMultiBean.ITEM_TYPE_INPUT, "單價($)", false, "請輸入單價,保留2位小數", new InputFilter[]{InputFilterUtils.getLengthFilter(context, 9), new DecimalDigitsInputFilter(context, 2)}, InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL));
MultiInputBean price= new MultiInputBean(InfoMultiBean.ITEM_TYPE_INPUT, "單價($)", false, "請輸入單價,保留2位小數", new InputFilter[]{InputFilterUtils.getLengthFilter(context, 9), new DecimalDigitsInputFilter(context, 2)}, InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
price.setOnFocusChangeListener(onFocusChangeListener);
// price.setOnFocusChangeListener((v, hasFocus) -> {
// LogUtil.e("zjs","price "+v.isPressed()+" hasFocus=="+hasFocus);
// if (hasFocus && purchaseFoodBean != null) {
// infoMultiBeans.get(foodIngredientPriceIndex).setShowValue("");
// purchaseFoodBean.setUnitPrice(0d);
// }
// });
infoMultiBeans.add(price);
infoMultiBeans.add(new InfoMultiBean(InfoMultiBean.ITEM_TYPE_LINE));
infoMultiBeans.add(new InfoMultiBean(InfoMultiBean.ITEM_TYPE_TITLE, "庫存預警"));
infoMultiBeans.add(new InfoMultiBean(InfoMultiBean.ITEM_MULTIPLE_BOOLEAN, "是否審核", false, ""));
......
......@@ -133,8 +133,27 @@ public class NewSupplierPresenter extends BasePresenter<NewSupplierContract.Mode
infoMultiBeans.add(multiInputSupplierName);
infoMultiBeans.add(new MultiInputBean(InfoMultiBean.ITEM_TYPE_INPUT, "聯繫人", true, "請輸入聯繫人", new InputFilter[]{InputFilterUtils.getLengthFilter(mContext, 20), InputFilterUtils.getChAndEnAndNumInputFilter(mContext)}, InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_WORDS));
infoMultiBeans.add(new MultiInputBean(InfoMultiBean.ITEM_TYPE_INPUT, "詳細地址", true, "請輸入詳細地址", new InputFilter[]{InputFilterUtils.getLengthFilter(mContext, 200), InputFilterUtils.getChAndEnAndNumAndPtInputFilter(mContext)}, InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES));
infoMultiBeans.add(new MultiInputBean(InfoMultiBean.ITEM_TYPE_INPUT, "聯繫人電話", true, "請輸入聯繫人電話", new InputFilter[]{InputFilterUtils.getLengthFilter(mContext, 11)}, EditorInfo.TYPE_CLASS_PHONE));
infoMultiBeans.add(new MultiInputBean(InfoMultiBean.ITEM_TYPE_INPUT, "最低採購金額", false, "請輸入最低金額", new InputFilter[]{InputFilterUtils.getLengthFilter(mContext, 9)}, EditorInfo.TYPE_CLASS_NUMBER | EditorInfo.TYPE_NUMBER_FLAG_DECIMAL));
MultiInputBean con=new MultiInputBean(InfoMultiBean.ITEM_TYPE_INPUT, "聯繫人電話", true, "請輸入聯繫人電話", new InputFilter[]{InputFilterUtils.getLengthFilter(mContext, 11)}, EditorInfo.TYPE_CLASS_PHONE);
MultiInputBean price= new MultiInputBean(InfoMultiBean.ITEM_TYPE_INPUT, "最低採購金額", false, "請輸入最低金額", new InputFilter[]{InputFilterUtils.getLengthFilter(mContext, 9)}, EditorInfo.TYPE_CLASS_NUMBER | EditorInfo.TYPE_NUMBER_FLAG_DECIMAL);
con.setOnFocusChangeListener((v, hasFocus) -> {
if (hasFocus && TextUtil.isNotEmptyOrNullOrUndefined(supplierBean.getContactInformation())) {
supplierBean.setContactInformation("");
infoMultiBeans.get(telephoneIndex).setShowValue("");
infoMultiAdapter.notifyItemChanged(telephoneIndex);
}
});
price.setOnFocusChangeListener((v, hasFocus) -> {
String minimumAmount = infoMultiBeans.get(lowPurchaseAmount).getShowValue();
if (hasFocus && TextUtil.isNotEmptyOrNullOrUndefined(minimumAmount)) {
supplierBean.setMinimumAmount(0d);
infoMultiBeans.get(lowPurchaseAmount).setShowValue("");
infoMultiAdapter.notifyItemChanged(lowPurchaseAmount);
}
});
infoMultiBeans.add(con);
infoMultiBeans.add(price);
infoMultiBeans.add(new MultiInputBean(InfoMultiBean.ITEM_TYPE_INPUT, "運費", false, "請輸入運費", new InputFilter[]{InputFilterUtils.getLengthFilter(mContext, 9)}, EditorInfo.TYPE_CLASS_NUMBER | EditorInfo.TYPE_NUMBER_FLAG_DECIMAL));
infoMultiBeans.add(new InfoMultiBean(InfoMultiBean.ITEM_TYPE_LINE));
......
......@@ -441,8 +441,6 @@ public class OtherFunctionPresenter extends BasePresenter<OtherFunctionContract.
Map<String, Object> map = new HashMap<>(5);
map.put("pageSize", 1000);
map.put("pageIndex", 0);
LogUtil.e(" zjs getFoodsBySupplier foodCategoryTrees.getId()= "+foodCategoryTrees.getId() +
" name="+name +" position="+position);
final boolean hasName=!TextUtils.isEmpty(name);
if (hasName) {
map.put("name", name);
......
......@@ -4,6 +4,7 @@ import android.content.Context;
import android.text.Editable;
import android.text.InputFilter;
import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.View;
import android.widget.CheckBox;
import android.widget.EditText;
......@@ -21,6 +22,7 @@ import com.gingersoft.gsa.cloud.common.utils.MoneyUtil;
import com.gingersoft.gsa.cloud.common.utils.inputFilter.DecimalDigitsInputFilter;
import com.gingersoft.gsa.cloud.common.utils.inputFilter.InputFilterUtils;
import com.gingersoft.gsa.cloud.common.utils.inputFilter.MoneyInputFilter;
import com.gingersoft.gsa.cloud.common.utils.log.LogUtil;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.mvp.bean.DeputyUnitBean;
......@@ -120,6 +122,7 @@ public class OrderDetailsFoodAdapter extends BaseQuickAdapter<PurchaseOrderDetai
edFoodNum.setTextColor(ContextCompat.getColor(getContext(), R.color.color_aaa));
edUnitPrice.setTextColor(ContextCompat.getColor(getContext(), R.color.color_3c));
edUnitPrice.setEnabled(true);
handlerInput(edUnitPrice);
} else {
if (item.getStatus() == PurchaseOrderDetailsBean.COMPLETE_RECEIVED) {
//全部收貨的不可編輯數量和金額
......@@ -132,6 +135,8 @@ public class OrderDetailsFoodAdapter extends BaseQuickAdapter<PurchaseOrderDetai
edUnitPrice.setEnabled(true);
edFoodNum.setTextColor(ContextCompat.getColor(getContext(), R.color.color_3c));
edUnitPrice.setTextColor(ContextCompat.getColor(getContext(), R.color.color_3c));
handlerInput(edFoodNum);
handlerInput(edUnitPrice);
}
}
edFoodNum.setFilters(inputFilters);
......@@ -180,7 +185,7 @@ public class OrderDetailsFoodAdapter extends BaseQuickAdapter<PurchaseOrderDetai
edFoodNum.setOnFocusChangeListener((v, hasFocus) -> {
if (hasFocus) {
edFoodNum.addTextChangedListener(watcher);
if ("0".equals(edFoodNum.getText().toString())) {
if (TextUtil.isNotEmptyOrNullOrUndefined(edUnitPrice)) {
edFoodNum.setText("");
}
} else {
......@@ -228,10 +233,12 @@ public class OrderDetailsFoodAdapter extends BaseQuickAdapter<PurchaseOrderDetai
edUnitPrice.setOnFocusChangeListener((v, hasFocus) -> {
if (hasFocus) {
if (TextUtil.isNotEmptyOrNullOrUndefined(edUnitPrice)) {
double price = Double.parseDouble(edUnitPrice.getText().toString());
if (price == 0) {
// LogUtil.e("zjs",""+v.isPressed()+" hasFocus=="+hasFocus);
// double price = Double.parseDouble(edUnitPrice.getText().toString());
// if (price == 0) {
// edUnitPrice.setText("");
// }
edUnitPrice.setText("");
}
}
edUnitPrice.addTextChangedListener(unitPriceWatcher);
} else {
......@@ -245,6 +252,18 @@ public class OrderDetailsFoodAdapter extends BaseQuickAdapter<PurchaseOrderDetai
});
}
private void handlerInput(EditText editText){
editText.setOnFocusChangeListener((v, hasFocus) -> {
if (hasFocus) {
String txt=editText.getText().toString();
if (!TextUtil.isEmptyOrNullOrUndefined(txt)) {
editText.setText("");
}
}
});
}
/**
* 修改實付金額
*/
......
......@@ -290,7 +290,6 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien
*/
private void jumpToSearch() {
int position = firstLevelCategoryAdapter.getSelectedIndex() ;
LogUtil.e("zjs jumpToSearch 跳轉到搜索頁面 position"+position);
mPresenter.getFoodsBySupplier(edFoodIngredientsSearch.getText().toString(),position, firstLevelCategoryAdapter.getItem(position), false, true);
}
......@@ -464,7 +463,6 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien
firstLevelCategoryAdapter = new FirstLevelCategoryAdapter(foodCategoryTrees, requireContext());
rvFirstCategory.setAdapter(firstLevelCategoryAdapter);
firstLevelCategoryAdapter.setOnItemClickListener((adapter, view, position) -> {
LogUtil.e("zjs initCategoryInfo ItemClick position "+position);
firstCategoryClick(position);
});
} else {
......
......@@ -14,6 +14,7 @@ import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import com.gingersoft.gsa.cloud.common.utils.FileUtils;
import com.gingersoft.gsa.cloud.common.utils.log.LogUtil;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.common.utils.toast.ToastUtils;
import com.gingersoft.gsa.cloud.ui.adapter.bean.InfoMultiBean;
......@@ -90,7 +91,7 @@ public class NewFoodIngredientsFragment extends BaseSupplyChainFragment<NewFoodI
* false:新增
*/
public boolean isUpdate = false;
private PurchaseFoodBean purchaseFoodBean;
public static NewFoodIngredientsFragment newInstance(PurchaseFoodBean purchaseFoodBean) {
NewFoodIngredientsFragment fragment = new NewFoodIngredientsFragment();
Bundle bundle = new Bundle();
......@@ -136,7 +137,7 @@ public class NewFoodIngredientsFragment extends BaseSupplyChainFragment<NewFoodI
}
});
Bundle arguments = getArguments();
PurchaseFoodBean purchaseFoodBean;
if (arguments != null) {
purchaseFoodBean = (PurchaseFoodBean) arguments.getSerializable(FOOD_INFO_KEY);
......@@ -169,7 +170,15 @@ public class NewFoodIngredientsFragment extends BaseSupplyChainFragment<NewFoodI
@Override
public void initAdapter() {
infoMultiAdapter = new InfoMultiAdapter(mContext, mPresenter.getFragmentInfo(mContext));
infoMultiAdapter = new InfoMultiAdapter(mContext, mPresenter.getFragmentInfo(mContext, (v, hasFocus) -> {
LogUtil.e("zjs"," initAdapter currentThread "+v.isPressed()+" hasFocus__"+v.hasFocus()+" hasFocus=="+hasFocus);
if (hasFocus && purchaseFoodBean.getUnitPrice()>0) {
InfoMultiBean infoMultiBean = infoMultiAdapter.getItem(12);
infoMultiBean.setShowValue("");
purchaseFoodBean.setUnitPrice(0d);
rvNewFoodIngredients.postDelayed(() -> infoMultiAdapter.notifyItemChanged(12),10);
}
}));
rvNewFoodIngredients.addItemDecoration(new DividerItemDecoration(mContext, VERTICAL_LIST));
infoMultiAdapter.setOnItemClickListener((adapter, view, position) -> {
List<InfoMultiBean> data = infoMultiAdapter.getData();
......
......@@ -294,7 +294,6 @@ public class OtherFunctionFragment extends BaseSupplyChainFragment<OtherFunction
*/
private void jumpToSearch() {
int position = firstLevelCategoryAdapter.getSelectedIndex() ;
LogUtil.e("zjs jumpToSearch 跳轉到搜索頁面 position"+position);
mPresenter.getFoodsBySupplier(edFoodIngredientsSearch.getText().toString(),position, firstLevelCategoryAdapter.getItem(position), false, true);
}
......@@ -468,7 +467,6 @@ public class OtherFunctionFragment extends BaseSupplyChainFragment<OtherFunction
firstLevelCategoryAdapter = new FirstLevelCategoryAdapter(foodCategoryTrees, requireContext());
rvFirstCategory.setAdapter(firstLevelCategoryAdapter);
firstLevelCategoryAdapter.setOnItemClickListener((adapter, view, position) -> {
LogUtil.e("zjs initCategoryInfo ItemClick position "+position);
firstCategoryClick(position);
});
} else {
......
......@@ -9,6 +9,8 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import com.gingersoft.gsa.cloud.common.utils.log.LogUtil;
import com.gingersoft.gsa.cloud.ui.adapter.bean.InfoMultiBean;
import com.gingersoft.gsa.cloud.ui.recylcler.decorator.DividerItemDecoration;
import com.gingersoft.gsa.cloud.ui.utils.AppDialog;
import com.gingersoft.supply_chain.R;
......
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