Commit 41a1858b by Wyh

1、供應鏈收貨sn碼數據修改 2、編輯商品提示保存 3、軟鍵盤遮擋問題 4、單位頁面點擊其他地方隱藏軟鍵盤 5、單位換算倍數輸入小數限制

6、採購單詳情顯示商品名稱 7、庫存消耗頁面不顯示商品圖片問題 8、收貨彈窗不消失問題 9、心跳預警修改
parent 84221077
......@@ -397,7 +397,6 @@ class DeliveryOrderMainActivity : BaseActivity<IPresenter>(), View.OnClickListen
if (!notification.areNotificationsEnabled()) {
//未開啟通知權限
AppDialog().showTipDialog(this, "檢測到通知權限未打開,建議打開,否則會影響正常使用!") { _, d ->
d.dismiss()
val intent = Intent()
when {
SDK_INT >= Build.VERSION_CODES.O -> {
......
......@@ -12,7 +12,8 @@
<uses-permission android:name="android.permission.FLASHLIGHT" />
<application android:networkSecurityConfig="@xml/network_android">
<activity android:name=".mvp.ui.activity.SupplyChainMainActivity" />
<activity android:name=".mvp.ui.activity.SupplyChainMainActivity"
android:windowSoftInputMode="adjustResize|stateVisible"/>
<meta-data
android:name="com.gingersoft.gsa.cloud.common.config.globalconfig.GlobalConfiguration"
......
......@@ -15,9 +15,12 @@ import lombok.Data;
public class OrderWareHouseBean {
private int status;
private int orderId;
private List<String> encodeFoodNos;
// private List<String> encodeFoodNos;
private List<PurchaseConsumeVerifyEncodeSn> purchaseConsumeVerifyEncodeSn;
private PurchaseWarehousingOrder purchaseWarehousingOrder;
private List<PurchaseWarehousingOrderDetail> purchaseWarehousingOrderDetailsTOS;
@Data
public static class PurchaseWarehousingOrder {
/**
......@@ -55,4 +58,16 @@ public class OrderWareHouseBean {
*/
private List<PurchaseFoodEncodeSn> purchaseFoodEncodeSn;
}
@Data
public static class PurchaseConsumeVerifyEncodeSn {
public PurchaseConsumeVerifyEncodeSn(String encodeFoodNo, List<String> encodeSnNos) {
this.encodeFoodNo = encodeFoodNo;
this.encodeSnNos = encodeSnNos;
}
private String encodeFoodNo;
private List<String> encodeSnNos;
}
}
......@@ -213,7 +213,7 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient
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, 11), InputFilterUtils.getEnAndNumInputFilter(context)}));
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 InfoMultiBean(InfoMultiBean.ITEM_TYPE_LINE));
......@@ -251,8 +251,14 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient
foodNoInputBean.setEdit(false);
foodNoInputBean.setShowValue(purchaseFoodBean.getFoodNo());
}
//sn食材
infoMultiBeans.get(foodSnIndex).setChecked(purchaseFoodBean.getFoodMarkSn() == PurchaseFoodBean.HAS_SN);
//sn食材,新增食材,是否是sn為-1,如果不是-1,則不是新增。就不能修改
if (purchaseFoodBean.getFoodMarkSn() != -1) {
infoMultiBeans.set(foodSnIndex, new MultiInputBean(InfoMultiBean.ITEM_TYPE_INPUT, "是否有SN碼", false, purchaseFoodBean.getFoodMarkSn() == PurchaseFoodBean.HAS_SN ? "是" : "否").setEdit(false));
} else {
//默認不是SN食材
purchaseFoodBean.setFoodMarkSn(0);
}
// infoMultiBeans.get(foodSnIndex).setChecked(purchaseFoodBean.getFoodMarkSn() == PurchaseFoodBean.HAS_SN);
//單價
if (purchaseFoodBean.getUnitPrice() != null) {
infoMultiBeans.get(foodIngredientPriceIndex).setShowValue(purchaseFoodBean.getUnitPrice() + "");
......
......@@ -154,7 +154,7 @@ public class NewSupplierPresenter extends BasePresenter<NewSupplierContract.Mode
// childInfoMulti.add(new MultiInputBean(InfoMultiBean.ITEM_TYPE_INPUT, "Kakao Talk", false, "請輸入Kakao Talk"));
// receivingMode.setInfoMultiBeans(childInfoMulti);
// infoMultiBeans.add(receivingMode);
MultiCheckInputBean emailInputBean = new MultiCheckInputBean(InfoMultiBean.ITEM_MULTIPLE_CHECKBOX, "Email", false, "請輸入Email", new InputFilter[]{InputFilterUtils.getLengthFilter(mContext, 20)}, R.drawable.ic_email, false);
MultiCheckInputBean emailInputBean = new MultiCheckInputBean(InfoMultiBean.ITEM_MULTIPLE_CHECKBOX, "Email", false, "請輸入Email", new InputFilter[]{InputFilterUtils.getLengthFilter(mContext, 40)}, R.drawable.ic_email, false);
emailInputBean.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
contactInfo.add(emailInputBean);
contactInfo.add(new MultiCheckInputBean(InfoMultiBean.ITEM_MULTIPLE_CHECKBOX, "WhatsApp", false, "請輸入WhatsApp", new InputFilter[]{InputFilterUtils.getLengthFilter(mContext, 20), InputFilterUtils.getChAndEnAndNumInputFilter(mContext)}, R.drawable.ic_whatsapp, false).setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES));
......
......@@ -372,7 +372,8 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
mRootView.showMessage(NULL_INFO_ERROR);
return null;
}
List<OrderWareHouseBean.PurchaseWarehousingOrderDetail> purchaseWarehousingOrderDetails = new ArrayList<>();
List<OrderWareHouseBean.PurchaseWarehousingOrderDetail> purchaseWarehousingOrderDetails = new ArrayList<>(purchaseOrderDetailsInfoVosBeans.size());
List<OrderWareHouseBean.PurchaseConsumeVerifyEncodeSn> purchaseConsumeVerifyEncodeSns = new ArrayList<>(purchaseOrderDetailsInfoVosBeans.size());
for (PurchaseOrderDetailsBean.PurchaseOrderDetailsInfoVosBean purchaseOrderDetailsInfoVosBean : purchaseOrderDetailsInfoVosBeans) {
if (purchaseOrderDetailsInfoVosBean.getStatus() != PurchaseOrderDetailsBean.COMPLETE_RECEIVED && purchaseOrderDetailsInfoVosBean.isChecked()) {
//新的入庫類
......@@ -397,10 +398,10 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
purchaseWarehousingOrderDetail.setPurchaseWarehousingUnit(wareHousingUnitBean);
//sn碼
List<PurchaseFoodEncodeSn> snList = null;
List<String> snCodes = null;
List<String> snCodes;
if (purchaseOrderDetailsInfoVosBean.getPurchaseFoodEncodeSns() != null) {
snList = new ArrayList<>();
snCodes = new ArrayList<>();
snList = new ArrayList<>(purchaseOrderDetailsInfoVosBean.getPurchaseFoodEncodeSns().size());
snCodes = new ArrayList<>(purchaseOrderDetailsInfoVosBean.getPurchaseFoodEncodeSns().size());
//只遍歷出新增的
for (PurchaseFoodEncodeSn purchaseFoodEncodeSn : purchaseOrderDetailsInfoVosBean.getPurchaseFoodEncodeSns()) {
if (purchaseFoodEncodeSn.newAdd) {
......@@ -408,12 +409,13 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
snCodes.add(purchaseFoodEncodeSn.getEncodeSnNo());
}
}
purchaseConsumeVerifyEncodeSns.add(new OrderWareHouseBean.PurchaseConsumeVerifyEncodeSn(purchaseOrderDetailsInfoVosBean.getFoodNo(), snCodes));
}
wareHouseBean.setEncodeFoodNos(snCodes);
purchaseWarehousingOrderDetail.setPurchaseFoodEncodeSn(snList);
purchaseWarehousingOrderDetails.add(purchaseWarehousingOrderDetail);
}
}
wareHouseBean.setPurchaseConsumeVerifyEncodeSn(purchaseConsumeVerifyEncodeSns);
return purchaseWarehousingOrderDetails;
}
......
......@@ -11,7 +11,6 @@ import android.widget.EditText;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.app.ActivityCompat;
import com.gingersoft.gsa.cloud.ui.widget.dialog.LoadingDialog;
import com.gingersoft.supply_chain.R;
......@@ -20,11 +19,11 @@ import com.gingersoft.supply_chain.mvp.content.SupplyShoppingCart;
import com.gingersoft.supply_chain.mvp.contract.SupplyChainMainContract;
import com.gingersoft.supply_chain.mvp.presenter.SupplyChainMainPresenter;
import com.gingersoft.supply_chain.mvp.ui.fragment.FunctionListFragment;
import com.gingersoft.supply_chain.mvp.utils.HideUtil;
import com.gingersoft.supply_chain.mvp.utils.NotDispatchListener;
import com.jess.arms.base.BaseFragmentActivity;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;
import com.jess.arms.utils.SoftHideKeyBoardUtil;
import static com.jess.arms.utils.Preconditions.checkNotNull;
......@@ -45,13 +44,19 @@ public class SupplyChainMainActivity extends BaseFragmentActivity<SupplyChainMai
}
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SoftHideKeyBoardUtil.assistActivity(this);
}
@Override
public int initView(@Nullable Bundle savedInstanceState) {
return R.layout.activity_supply_chain_main;
}
@Override
public void initData(@Nullable Bundle savedInstanceState) {
// HideUtil.init(this);
loadRootFragment(R.id.layout_supply_chain_content, FunctionListFragment.newInstance());
}
......@@ -75,6 +80,28 @@ public class SupplyChainMainActivity extends BaseFragmentActivity<SupplyChainMai
return super.dispatchTouchEvent(event);
}
// @Override
// public boolean onTouchEvent(@NonNull MotionEvent event) {
// if (getCurrentFocus() != null) {
// //点击EditText以外区域隐藏软键盘
// InputMethodManager mInputMethodManager = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
// mInputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
// }
// //对dialog区域外进行监听,数值按照实际情况调整
// if (event.getAction() == MotionEvent.ACTION_DOWN) {
// if (!(event.getX() >= -10 && event.getY() >= -10)
// || event.getX() >= calendarLayout.getWidth() + 10
// || event.getY() >= calendarLayout.getHeight() + 20) {
// //若有软键盘则关闭,无则关闭dialog
// if (SoftKeyBoardListener.softKeyFlag) {
// SoftKeyBoardListener.hideSoftKeyboard(getContext(), getCurrentFocus());
// } else {
// dismiss();
// }
// }
// }
// return super.onTouchEvent(event);
// }
// @Override
// public boolean dispatchTouchEvent(MotionEvent ev) {
// if (getTopFragment() instanceof NotDispatchListener) {
// return super.dispatchTouchEvent(ev);
......@@ -182,4 +209,5 @@ public class SupplyChainMainActivity extends BaseFragmentActivity<SupplyChainMai
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
}
}
......@@ -74,7 +74,6 @@ public class BuyIngredientsAdapter extends GroupedRecyclerViewAdapter<BuyIngredi
return getLayoutId();
}
@Override
public void onBindHeaderViewHolder(BaseViewHolder holder, int groupPosition, BuyIngredientsBean data) {
holder.setText(R.id.tv_buy_food_header, data.categoryName + "");
......
package com.gingersoft.supply_chain.mvp.ui.adapter;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.widget.TextView;
import androidx.cardview.widget.CardView;
import androidx.core.content.ContextCompat;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.gingersoft.gsa.cloud.common.R;
import com.gingersoft.supply_chain.mvp.bean.OrderCategoryBean;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
/**
* @author 宇航.
* User: admin
* Date: 2020/11/28
* Time: 11:45
* Use: 編輯分類,一級分類適配器
*/
public class CategoryAdapter extends BaseQuickAdapter<OrderCategoryBean.FoodCategoryTrees, BaseViewHolder> {
private int selectedIndex = 0;
private Drawable selectedBg;
private Drawable unSelectedBg;
private int selectColor = -1;
private int unSelectColor = -1;
private boolean showDelete = false;
public CategoryAdapter(@Nullable List<OrderCategoryBean.FoodCategoryTrees> data, Context context) {
super(R.layout.item_base_category, data);
addChildClickViewIds(R.id.iv_category_delete);
selectedBg = ContextCompat.getDrawable(context, R.drawable.shape_left_radio_shadow);
unSelectedBg = ContextCompat.getDrawable(context, R.color.trans);
}
@Override
protected void convert(@NotNull BaseViewHolder viewHolder, OrderCategoryBean.FoodCategoryTrees categoryBean) {
TextView tvCategoryName = viewHolder.getView(R.id.tv_category_name);
tvCategoryName.setText(categoryBean.getName());
CardView view = viewHolder.getView(R.id.layout_category);
if (viewHolder.getAdapterPosition() == selectedIndex) {
if (selectedBg != null) {
view.setBackground(selectedBg);
}
if (selectColor != -1) {
tvCategoryName.setTextColor(selectColor);
}
tvCategoryName.setSelected(true);
} else {
tvCategoryName.setSelected(false);
if (unSelectedBg != null) {
view.setBackground(unSelectedBg);
}
if (unSelectColor != -1) {
tvCategoryName.setTextColor(unSelectColor);
}
}
viewHolder.setGone(R.id.iv_category_delete, !showDelete);
}
public void setShowDelete(boolean showDelete) {
this.showDelete = showDelete;
notifyDataSetChanged();
}
public CategoryAdapter setSelectedBg(Drawable selectedBg) {
this.selectedBg = selectedBg;
return this;
}
public CategoryAdapter setUnSelectedBg(Drawable unSelectedBg) {
this.unSelectedBg = unSelectedBg;
return this;
}
public CategoryAdapter setSelectColor(int selectColor) {
this.selectColor = selectColor;
return this;
}
public CategoryAdapter setUnSelectColor(int unSelectColor) {
this.unSelectColor = unSelectColor;
return this;
}
public void setSelectedIndex(int selectedIndex) {
this.selectedIndex = selectedIndex;
notifyDataSetChanged();
}
public int getSelectedIndex() {
return selectedIndex;
}
}
......@@ -3,15 +3,14 @@ package com.gingersoft.supply_chain.mvp.ui.adapter;
import android.text.Editable;
import android.text.InputFilter;
import android.text.TextWatcher;
import android.view.View;
import android.widget.EditText;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.gingersoft.gsa.cloud.common.utils.MoneyUtil;
import com.gingersoft.gsa.cloud.common.utils.inputFilter.InputFilterUtils;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.mvp.bean.BasicUnitBean;
import com.gingersoft.supply_chain.mvp.bean.DeputyUnitBean;
import org.jetbrains.annotations.NotNull;
......@@ -39,7 +38,7 @@ public class DeputyUnitAdapter extends BaseQuickAdapter<DeputyUnitBean, BaseView
EditText edConversionMultiple = viewHolder.getView(R.id.ed_deputy_unit_conversion_multiple);
viewHolder.setText(R.id.tv_deputy_unit_title, "副單位" + (viewHolder.getAdapterPosition() + 1));
viewHolder.setText(R.id.ed_deputy_unit_name, item.getDeputyUnit());
viewHolder.setText(R.id.ed_deputy_unit_conversion_multiple, item.getConversionMultiple() + "");
viewHolder.setText(R.id.ed_deputy_unit_conversion_multiple, MoneyUtil.formatDouble(item.getConversionMultiple()));
//副單位換算倍數
TextWatcher deputyUnitNameWatcher = new TextWatcher() {
@Override
......@@ -77,11 +76,14 @@ public class DeputyUnitAdapter extends BaseQuickAdapter<DeputyUnitBean, BaseView
DeputyUnitBean deputyUnitBean = getData().get(viewHolder.getAdapterPosition());
if (TextUtil.isNotEmptyOrNullOrUndefined(s + "")) {
deputyUnitBean.setConversionMultiple(Double.parseDouble(s + ""));
} else {
deputyUnitBean.setConversionMultiple(Double.parseDouble("0"));
edConversionMultiple.setText("0");
}
}
};
setFocusChangeListener(edConversionMultiple, conversionMultipleWatcher);
edConversionMultiple.setFilters(new InputFilter[]{InputFilterUtils.getNumberFilter(edDeputyUnitName.getContext())});
if (TextUtil.isEmptyOrNullOrUndefined(item.getDeputyUnit())) {
edDeputyUnitName.requestFocus();
}
......
package com.gingersoft.supply_chain.mvp.ui.adapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.gingersoft.gsa.cloud.ui.R;
import com.gingersoft.gsa.cloud.ui.adapter.BaseSelectorAdapter;
import com.gingersoft.gsa.cloud.ui.bean.view.CategoryBean;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
/**
* @author 宇航.
* User: admin
* Date: 2020/11/28
* Time: 11:45
* Use:
*/
public class LeftCategoryAdapter extends BaseSelectorAdapter<CategoryBean, BaseViewHolder> {
private boolean showDelete = false;
public LeftCategoryAdapter(@Nullable List<CategoryBean> data) {
super(R.layout.item_base_category, data);
addChildClickViewIds(R.id.iv_category_delete);
}
@Override
protected void convert(@NotNull BaseViewHolder viewHolder, CategoryBean categoryBean) {
viewHolder.setText(R.id.tv_base_item_title, categoryBean.getCategoryName());
notifyCheckState(viewHolder.getAdapterPosition(), viewHolder.getView(R.id.tv_base_item_title), viewHolder.getView(R.id.item_layout_root));
viewHolder.setGone(R.id.iv_category_delete, !showDelete);
}
@Override
public void onBindViewHolder(@NotNull BaseViewHolder holder, int position, @NotNull List<Object> payloads) {
super.onBindViewHolder(holder, position, payloads);
//list为空时,必须调用两个参数的onBindViewHolder(@NonNull LabelHolder holder, int position)
if (payloads.isEmpty()) {
onBindViewHolder(holder, position);
} else {
notifyCheckState(position, holder.getView(R.id.tv_base_item_title), holder.getView(R.id.item_layout_root));
}
}
public void setShowDelete(boolean showDelete) {
this.showDelete = showDelete;
notifyDataSetChanged();
}
}
package com.gingersoft.supply_chain.mvp.ui.adapter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.cardview.widget.CardView;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.gingersoft.gsa.cloud.common.utils.CollectionUtils;
import com.gingersoft.gsa.cloud.ui.adapter.BaseSelectorAdapter;
import com.gingersoft.gsa.cloud.ui.view.textview.SuperTextView;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.mvp.bean.PurchaseFoodBean;
import com.gingersoft.supply_chain.mvp.bean.PurchaseOrderDetailsBean;
import com.qmuiteam.qmui.alpha.QMUIAlphaTextView;
import com.qmuiteam.qmui.util.QMUIDisplayHelper;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
/**
* @author 宇航.
* User: admin
* Date: 2021/4/20
* Time: 12:16
* Use:
*/
public class SnNameAdapter extends BaseSelectorAdapter<PurchaseOrderDetailsBean.PurchaseOrderDetailsInfoVosBean, BaseViewHolder> {
public SnNameAdapter(@Nullable List<PurchaseOrderDetailsBean.PurchaseOrderDetailsInfoVosBean> data) {
super(R.layout.item_base_selector, data);
if (CollectionUtils.isNotNullOrEmpty(data)) {
setSelectedIndex(0);
}
}
@Override
protected void convert(@NotNull BaseViewHolder viewHolder, PurchaseOrderDetailsBean.PurchaseOrderDetailsInfoVosBean purchaseOrderDetailsInfoVosBean) {
AppCompatTextView superTextView = viewHolder.getView(R.id.tv_base_select_title);
AppCompatTextView tvSn = viewHolder.getView(R.id.tv_sn);
CardView cardView = viewHolder.getView(R.id.card_base_select_layout);
if (purchaseOrderDetailsInfoVosBean.getFoodMarkSn() == PurchaseFoodBean.HAS_SN) {
//SN食材
tvSn.setVisibility(View.VISIBLE);
} else {
tvSn.setVisibility(View.GONE);
}
superTextView.setText(purchaseOrderDetailsInfoVosBean.getName());
switch (purchaseOrderDetailsInfoVosBean.getStatus()) {
case PurchaseOrderDetailsBean.PART_RECEIVED:
//部分收貨
cardView.setBackground(ContextCompat.getDrawable(getContext(), R.drawable.shape_orange_twelve_radius));
tvSn.setTextColor(ContextCompat.getColor(getContext(), R.color.white));
superTextView.setTextColor(ContextCompat.getColor(getContext(), R.color.white));
break;
case PurchaseOrderDetailsBean.COMPLETE_RECEIVED:
//全部
cardView.setBackground(ContextCompat.getDrawable(getContext(), R.drawable.shape_red_twelve_radius));
tvSn.setTextColor(ContextCompat.getColor(getContext(), R.color.white));
superTextView.setTextColor(ContextCompat.getColor(getContext(), R.color.white));
break;
default:
//默認
cardView.setBackground(ContextCompat.getDrawable(getContext(), R.drawable.shape_them_border_twelve_white_bg));
tvSn.setTextColor(ContextCompat.getColor(getContext(), R.color.required_color));
superTextView.setTextColor(ContextCompat.getColor(getContext(), R.color.color_3c));
break;
}
RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) cardView.getLayoutParams();
//bottom留3dp。陰影好看些
if (viewHolder.getAdapterPosition() == 0) {
//第一個
//左間距為15
layoutParams.setMargins(QMUIDisplayHelper.dp2px(getContext(), 15), 0, 0, QMUIDisplayHelper.dp2px(getContext(), 3));
cardView.setLayoutParams(layoutParams);
} else if (viewHolder.getAdapterPosition() == getItemCount() - 1) {
//最後一個
//左間距為8,右間距為15
layoutParams.setMargins(QMUIDisplayHelper.dp2px(getContext(), 8), 0, QMUIDisplayHelper.dp2px(getContext(), 15), QMUIDisplayHelper.dp2px(getContext(), 3));
cardView.setLayoutParams(layoutParams);
} else {
//左間距為8,右間距為0
layoutParams.setMargins(QMUIDisplayHelper.dp2px(getContext(), 8), 0, 0, QMUIDisplayHelper.dp2px(getContext(), 3));
cardView.setLayoutParams(layoutParams);
}
}
}
......@@ -17,7 +17,6 @@ import androidx.recyclerview.widget.RecyclerView;
import com.gingersoft.gsa.cloud.common.loadsir.EmptyCallback;
import com.gingersoft.gsa.cloud.common.loadsir.ErrorCallback;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.ui.adapter.BaseCategoryAdapter;
import com.gingersoft.gsa.cloud.ui.bean.view.CategoryBean;
import com.gingersoft.gsa.cloud.ui.utils.AppDialog;
import com.gingersoft.supply_chain.R;
......@@ -29,6 +28,7 @@ import com.gingersoft.supply_chain.mvp.content.SupplyShoppingCart;
import com.gingersoft.supply_chain.mvp.contract.FoodIngredientsContract;
import com.gingersoft.supply_chain.mvp.presenter.FoodIngredientsPresenter;
import com.gingersoft.supply_chain.mvp.ui.adapter.FoodListAdapter;
import com.gingersoft.supply_chain.mvp.ui.adapter.LeftCategoryAdapter;
import com.gingersoft.supply_chain.mvp.ui.adapter.OrderCategoryAdapter;
import com.gingersoft.supply_chain.mvp.ui.fragment.BaseSupplyChainFragment;
import com.gingersoft.supply_chain.mvp.ui.fragment.order.ShoppingCatFragment;
......@@ -146,7 +146,7 @@ public class FoodIngredientsFragment extends BaseSupplyChainFragment<FoodIngredi
*/
private int currentLevelCategory = OrderCategoryAdapter.PRIMARY_CATEGORY;
private BaseCategoryAdapter listSelectAdapter;
private LeftCategoryAdapter listSelectAdapter;
public static FoodIngredientsFragment newInstance(int pageType) {
FoodIngredientsFragment fragment = new FoodIngredientsFragment();
......@@ -362,7 +362,7 @@ public class FoodIngredientsFragment extends BaseSupplyChainFragment<FoodIngredi
supplierId = categoryBeans.get(0).getId();
}
if (listSelectAdapter == null) {
listSelectAdapter = new BaseCategoryAdapter(R.layout.item_base_category, categoryBeans);
listSelectAdapter = new LeftCategoryAdapter(categoryBeans);
listSelectAdapter.setUnSelectColor(ContextCompat.getColor(mContext, R.color.color_3c))
.setSelectColor(ContextCompat.getColor(mContext, R.color.theme_color));
listSelectAdapter.setOnItemClickListener((adapter, view, position) -> {
......
package com.gingersoft.supply_chain.mvp.ui.fragment.food;
import android.graphics.Color;
import android.os.Bundle;
import android.text.InputFilter;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.EditText;
import android.widget.ImageView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
......@@ -28,12 +27,10 @@ import com.gingersoft.supply_chain.mvp.presenter.FoodUnitPagePresenter;
import com.gingersoft.supply_chain.mvp.ui.adapter.BasicUnitAdapter;
import com.gingersoft.supply_chain.mvp.ui.adapter.DeputyUnitAdapter;
import com.gingersoft.supply_chain.mvp.ui.fragment.BaseSupplyChainFragment;
import com.gingersoft.supply_chain.mvp.ui.fragment.order.OrderDetailsFragment;
import com.gingersoft.supply_chain.mvp.ui.widget.EditTextPopup;
import com.gingersoft.supply_chain.mvp.utils.NotDispatchListener;
import com.jess.arms.di.component.AppComponent;
import com.lxj.xpopup.XPopup;
import com.lxj.xpopup.interfaces.OnCancelListener;
import com.qmuiteam.qmui.alpha.QMUIAlphaTextView;
import com.qmuiteam.qmui.widget.QMUITopBar;
......@@ -116,11 +113,16 @@ public class FoodUnitPageFragment extends BaseSupplyChainFragment<FoodUnitPagePr
@Override
public void initData(@Nullable Bundle savedInstanceState) {
getView().setOnTouchListener((v, event) -> {
hideSoftInput();
return false;
});
mPresenter.initData(getArguments());
edBasicUnit.setFilters(new InputFilter[]{InputFilterUtils.getLengthFilter(requireContext(), 5), InputFilterUtils.getChAndEnAndNumInputFilter(requireContext())});
edBasicUnit.requestFocus();
}
@OnClick({R2.id.tv_add_deputy, R2.id.tv_food_unit_complete})
public void onClick(View view) {
int viewId = view.getId();
......@@ -134,6 +136,7 @@ public class FoodUnitPageFragment extends BaseSupplyChainFragment<FoodUnitPagePr
if (TextUtil.isEmptyOrNullOrUndefined(basicUnit)) {
showMessage("請輸入基本單位");
edBasicUnit.setError("請輸入基本單位");
edBasicUnit.requestFocus();
return;
}
if (deputyUnitAdapter != null && deputyUnitAdapter.getItemCount() > 0) {
......
......@@ -142,6 +142,7 @@ public class NewFoodIngredientsFragment extends BaseSupplyChainFragment<NewFoodI
isUpdate = false;
initTopBar(topbarNewFoodIngredients, "新增食材");
purchaseFoodBean = new PurchaseFoodBean();
purchaseFoodBean.setFoodMarkSn(-1);
//拿到分類集合
String categoryName = arguments.getString(CATEGORY_NAME_KEY);
if (TextUtil.isNotEmptyOrNullOrUndefined(categoryName)) {
......@@ -300,8 +301,7 @@ public class NewFoodIngredientsFragment extends BaseSupplyChainFragment<NewFoodI
public boolean onBackPressedSupport() {
if (mPresenter.isUpdate(infoMultiAdapter.getData()) && !isLeave) {
//用戶修改了數據,提示是否保存
AppDialog.getInstance().showTipDialog(requireContext(), getString(R.string.str_info_no_save_leave), getString(R.string.str_save), getString(R.string.str_leave), (view, dialog) -> {
dialog.dismiss();
AppDialog.getInstance().showTipDialog(requireContext(), getString(R.string.str_about_to_leave), getString(R.string.str_yes), getString(R.string.str_no), (view, dialog) -> {
saveGoodsInfo();
}, (view, dialog) -> {
isLeave = true;
......
package com.gingersoft.supply_chain.mvp.ui.fragment.order;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.text.InputFilter;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.LinearInterpolator;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
......@@ -20,18 +20,18 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.cardview.widget.CardView;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.target.Target;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemChildClickListener;
import com.gingersoft.gsa.cloud.common.utils.CollectionUtils;
import com.gingersoft.gsa.cloud.common.utils.FileUtils;
import com.gingersoft.gsa.cloud.common.utils.MoneyUtil;
import com.gingersoft.gsa.cloud.common.utils.glide.GlideUtils;
import com.gingersoft.gsa.cloud.common.utils.inputFilter.InputFilterUtils;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.common.utils.time.TimeUtils;
......@@ -45,30 +45,26 @@ import com.gingersoft.supply_chain.mvp.bean.DeputyUnitBean;
import com.gingersoft.supply_chain.mvp.bean.PurchaseFoodBean;
import com.gingersoft.supply_chain.mvp.bean.PurchaseFoodEncodeSn;
import com.gingersoft.supply_chain.mvp.bean.PurchaseOrderDetailsBean;
import com.gingersoft.supply_chain.mvp.bean.WareHousingUnitBean;
import com.gingersoft.supply_chain.mvp.contract.OrderDetailsContract;
import com.gingersoft.supply_chain.mvp.presenter.OrderDetailsPresenter;
import com.gingersoft.supply_chain.mvp.ui.adapter.ImageAdapter;
import com.gingersoft.supply_chain.mvp.ui.adapter.OrderDetailsFoodAdapter;
import com.gingersoft.supply_chain.mvp.ui.adapter.SnNameAdapter;
import com.gingersoft.supply_chain.mvp.ui.fragment.BaseSupplyChainFragment;
import com.gingersoft.supply_chain.mvp.ui.widget.CenterLayoutManager;
import com.gingersoft.supply_chain.mvp.ui.widget.ChooseUnitPopup;
import com.gingersoft.supply_chain.mvp.ui.widget.PurchaseListMorePopup;
import com.gingersoft.supply_chain.mvp.ui.widget.ScanSnPopup;
import com.gingersoft.supply_chain.mvp.ui.widget.ScanSnView;
import com.gingersoft.supply_chain.mvp.utils.SelectPicture;
import com.gingersoft.supply_chain.mvp.utils.ViewUtils;
import com.google.android.material.checkbox.MaterialCheckBox;
import com.google.android.material.textfield.TextInputLayout;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.http.imageloader.ImageLoader;
import com.lxj.xpopup.XPopup;
import com.lxj.xpopup.core.BasePopupView;
import com.lxj.xpopup.core.ImageViewerPopupView;
import com.lxj.xpopup.enums.PopupPosition;
import com.lxj.xpopup.interfaces.OnSelectListener;
import com.lxj.xpopup.interfaces.XPopupCallback;
import com.lxj.xpopup.interfaces.XPopupImageLoader;
import com.qmuiteam.qmui.alpha.QMUIAlphaTextView;
import com.qmuiteam.qmui.util.QMUIDisplayHelper;
import com.qmuiteam.qmui.widget.QMUITopBar;
import com.yalantis.ucrop.UCrop;
......@@ -76,7 +72,6 @@ import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
import butterknife.BindView;
import butterknife.OnClick;
......@@ -124,8 +119,8 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr
TextInputLayout layoutInputRemark;
@BindView(R2.id.ed_warehouse_order_remark)
EditText edRemark;
// @BindView(R2.id.layout_ed_remark)
// LinearLayout layoutEdRemark;
@BindView(R2.id.card_show_more_food_name)
CardView cardMoreFoodName;
private OrderDetailsFoodAdapter orderDetailsFoodAdapter;
......@@ -186,7 +181,7 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr
}
@OnClick({R2.id.tv_order_details_partial_receipt, R2.id.tv_order_details_receipt, R2.id.layout_remarks})
@OnClick({R2.id.tv_order_details_partial_receipt, R2.id.tv_order_details_receipt, R2.id.layout_remarks, R2.id.card_show_more_food_name})
@Override
public void onClick(View v) {
int viewId = v.getId();
......@@ -222,6 +217,9 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr
} else if (viewId == R.id.layout_remarks) {
//備註,顯示備註輸入框
layoutInputRemark.setVisibility(layoutInputRemark.getVisibility() == View.VISIBLE ? View.GONE : View.VISIBLE);
} else if (viewId == R.id.card_show_more_food_name) {
//展開食品名稱彈窗
}
}
......@@ -311,6 +309,7 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr
break;
}
setTypesOfFood();
initRecyclerView(orderDetailsBean);
//全選按鈕狀態切換
cbOrderDetailsAllSelected.setOnCheckedChangeListener((buttonView, isChecked) -> {
......@@ -450,8 +449,14 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr
}
private void initRecyclerView(PurchaseOrderDetailsBean orderDetailsBean) {
rvOrderDetailsFoodName.setLayoutManager(new CenterLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false));
SnNameAdapter snNameAdapter = new SnNameAdapter(orderDetailsBean.getPurchaseOrderDetailsInfoVOS());
rvOrderDetailsFoodName.setAdapter(snNameAdapter);
orderDetailsFoodAdapter = new OrderDetailsFoodAdapter(mContext, orderDetailsBean.getPurchaseOrderDetailsInfoVOS());
rvOrderDetailsFoodList.setAdapter(orderDetailsFoodAdapter);
rvOrderDetailsFoodList.setLayoutManager(new CenterLayoutManager(requireContext(), LinearLayoutManager.VERTICAL, false));
orderDetailsFoodAdapter.setOnAmountChangeListener((position, value) -> {
totalAmount = MoneyUtil.sum(totalAmount, value);
setTotalAmount();
......@@ -474,6 +479,7 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr
});
orderDetailsFoodAdapter.setOnItemChildClickListener((adapter, view, position) -> {
int id = view.getId();
//食材單位點擊事件
if (id == R.id.layout_order_details_unit) {
//切換單位
PurchaseOrderDetailsBean.PurchaseOrderDetailsInfoVosBean purchaseOrderDetailsInfoVosBean = orderDetailsFoodAdapter.getData().get(position);
......@@ -504,6 +510,37 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr
}
}
});
// setMoreNameCard();
snNameAdapter.setOnItemClickListener((adapter, view, position) -> {
//點擊滑動到對應的食品
rvOrderDetailsFoodList.smoothScrollToPosition(position);
ViewUtils.moveToCenterByHorizontal(rvOrderDetailsFoodName, position);
// ViewUtils.moveToCenterByVertical(rvOrderDetailsFoodList, position);
LinearLayoutManager layoutManager = (LinearLayoutManager) rvOrderDetailsFoodList.getLayoutManager();
layoutManager.scrollToPositionWithOffset(position, 0);
View childAt = layoutManager.findViewByPosition(position);
if (childAt != null) {
Animation alphaAnimation = new AlphaAnimation(1.0f, 0.2f);
alphaAnimation.setDuration(600);
alphaAnimation.setFillBefore(true);
alphaAnimation.setInterpolator(new LinearInterpolator());
alphaAnimation.setRepeatCount(2);
alphaAnimation.setRepeatMode(Animation.REVERSE);
childAt.startAnimation(alphaAnimation);
}
});
}
/**
* 設置展開更多名稱的view高度
*/
private void setMoreNameCard() {
cardMoreFoodName.post(() -> {
int measuredHeight = cardMoreFoodName.getMeasuredHeight();
ViewGroup.LayoutParams layoutParams = cardMoreFoodName.getLayoutParams();
layoutParams.width = measuredHeight;
cardMoreFoodName.setLayoutParams(layoutParams);
});
}
/**
......
......@@ -120,7 +120,6 @@ public class ShoppingCatFragment extends BaseSupplyChainFragment<ShoppingCatPres
if (mPresenter.filterData(shoppingCartAdapter.getData())) {
AppDialog.getInstance().showTipDialog(requireContext(), "確認創建訂單?", (view, dialog) -> {
mPresenter.createOrder(shoppingCartAdapter.getData());
dialog.dismiss();
});
}
} else if (viewId == R.id.btn_order_content_order_template) {
......
......@@ -2,10 +2,8 @@ package com.gingersoft.supply_chain.mvp.ui.fragment.supplier;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
......@@ -17,12 +15,10 @@ import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.R2;
import com.gingersoft.supply_chain.di.component.DaggerNewSupplierComponent;
import com.gingersoft.supply_chain.mvp.bean.SupplierInfoBean;
import com.gingersoft.supply_chain.mvp.content.Constant;
import com.gingersoft.supply_chain.mvp.contract.NewSupplierContract;
import com.gingersoft.supply_chain.mvp.presenter.NewSupplierPresenter;
import com.gingersoft.supply_chain.mvp.ui.fragment.BaseSupplyChainFragment;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.DeviceUtils;
import com.qmuiteam.qmui.alpha.QMUIAlphaButton;
import com.qmuiteam.qmui.widget.QMUITopBar;
......
......@@ -3,7 +3,6 @@ package com.gingersoft.supply_chain.mvp.ui.fragment.warehouse;
import android.animation.LayoutTransition;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
......@@ -142,6 +141,7 @@ public class WarehouseDetailsFragment extends BaseSupplyChainFragment<WarehouseD
public void initData(@Nullable Bundle savedInstanceState) {
Bundle arguments = getArguments();
smartRefreshLayout.setPrimaryColorsId(R.color.trans, R.color.black);
loadService = LoadSir.getDefault().register(smartRefreshLayout);
LayoutTransition layoutTransition = new LayoutTransition();
layoutTransition.enableTransitionType(LayoutTransition.CHANGING);
......@@ -156,7 +156,7 @@ public class WarehouseDetailsFragment extends BaseSupplyChainFragment<WarehouseD
initTopBar(supplyTopBar, purchaseWarehousingOrderDetailsVO.getName());
tvUnit.setText(purchaseWarehousingOrderDetailsVO.getUnitName());
String foodImageUrl = arguments.getString(purchaseWarehousingOrderDetailsVO.getImages());
String foodImageUrl = purchaseWarehousingOrderDetailsVO.getImages();
if (TextUtil.isNotEmptyOrNullOrUndefined(foodImageUrl)) {
GlideUtils.display(requireContext(), ivFoodImg, foodImageUrl);
} else {
......@@ -419,7 +419,7 @@ public class WarehouseDetailsFragment extends BaseSupplyChainFragment<WarehouseD
restaurantName.setText(String.format(getString(R.string.str_restaurant_outbound_order), RestaurantInfoManager.newInstance().getRestaurantName()));
tvDate.setText(TimeUtils.getCurrentDate(TimeUtils.DEFAULT_DATE_FORMAT_YMDHM));
tvFoodNo.setText(String.format(getString(R.string.str_no), purchaseWarehousingOrderDetailsVO.getFoodNo()));
tvFoodNo.setText(String.format(getString(R.string.str_goods_no), purchaseWarehousingOrderDetailsVO.getFoodNo()));
tvUserName.setText(String.format(getString(R.string.str_prepared), UserContext.newInstance().getMemberName()));
List<OutboundOrderBean> outboundOrderBeans = new ArrayList<>();
outboundOrderBeans.add(new OutboundOrderBean(getString(R.string.str_product_name), purchaseWarehousingOrderDetailsVO.getName()));
......@@ -530,4 +530,5 @@ public class WarehouseDetailsFragment extends BaseSupplyChainFragment<WarehouseD
}
}
}
}
......@@ -7,6 +7,7 @@ import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.core.content.ContextCompat;
......@@ -51,6 +52,7 @@ public class ScanSnView extends FrameLayout {
@BindView(R2.id.rv_sn_code)
RecyclerView rvSnCode;
int recyclerHeight = 0;
private SnCodeAdapter adapter;
@BindView(R2.id.btn_confirm_sn)
QMUIAlphaButton btnFoodIngredientsConfirm;
......@@ -181,6 +183,14 @@ public class ScanSnView extends FrameLayout {
btnScanSn.setVisibility(GONE);
tvScanSn.setText(R.string.str_enter_sn);
}
rvSnCode.post(() -> {
if (recyclerHeight == 0) {
recyclerHeight = rvSnCode.getMeasuredHeight();
}
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) rvSnCode.getLayoutParams();
layoutParams.height = recyclerHeight;
rvSnCode.setLayoutParams(layoutParams);
});
edInputSn.setOnEditorActionListener((v, actionId, event) -> {
if (actionId == EditorInfo.IME_ACTION_UNSPECIFIED) {
//響應回車按鈕
......
package com.gingersoft.supply_chain.mvp.ui.widget;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
import android.widget.FrameLayout;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.RecyclerView;
import com.billy.cc.core.component.CC;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.gingersoft.gsa.cloud.common.utils.XPermissionUtils;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.common.utils.toast.ToastUtils;
import com.gingersoft.gsa.cloud.component.ComponentName;
import com.gingersoft.gsa.cloud.ui.utils.AppDialog;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.R2;
import com.gingersoft.supply_chain.mvp.bean.PurchaseFoodEncodeSn;
import com.qmuiteam.qmui.alpha.QMUIAlphaButton;
import com.qmuiteam.qmui.alpha.QMUIAlphaImageButton;
import com.qmuiteam.qmui.alpha.QMUIAlphaTextView;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import cn.bingoogolapple.qrcode.core.BarcodeType;
import me.yokeyword.fragmentation.SupportHelper;
/**
* @author 宇航.
......@@ -50,6 +29,8 @@ public class ShowSnView extends FrameLayout {
@BindView(R2.id.rv_sn_code)
RecyclerView rvSnCode;
@BindView(R2.id.frame_sn_list)
FrameLayout snListLayout;
public ShowSnView(Context context, List<PurchaseFoodEncodeSn> snCodes) {
super(context);
......
......@@ -39,7 +39,8 @@ public class ViewUtils {
}
//取得中間位置的item
Log.e("eee", "需要選中:" + sectionPosition + "顯示的:" + layoutManager.findFirstVisibleItemPosition() + "子數量:" + recyclerView.getChildCount());
View childAt = recyclerView.getChildAt(sectionPosition - layoutManager.findFirstVisibleItemPosition());
// View childAt = recyclerView.getChildAt(sectionPosition - layoutManager.findFirstVisibleItemPosition());
View childAt = layoutManager.findViewByPosition(sectionPosition - layoutManager.findFirstVisibleItemPosition());
//拿到列表一半的寬度
int halfLeftRvWidth = recyclerView.getWidth() / 2;
Log.e("eee", childAt + "一半寬度:" + halfLeftRvWidth + "第一個:" + recyclerView.getChildAt(0));
......
......@@ -4,20 +4,31 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/color_f0"
android:orientation="vertical">
<include layout="@layout/supply_chain_top_bar" />
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/color_f0"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/dp_8"
android:background="@color/white"
android:orientation="vertical"
android:paddingLeft="@dimen/dp_18"
android:paddingRight="@dimen/dp_18"
android:paddingBottom="@dimen/dp_6"
app:layout_collapseMode="parallax">
app:layout_scrollFlags="scroll|enterAlways">
<LinearLayout
android:layout_width="match_parent"
......@@ -142,30 +153,55 @@
android:layout_marginTop="@dimen/dp_10" />
</LinearLayout>
<HorizontalScrollView
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:visibility="gone">
android:orientation="horizontal">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_order_details_food_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@color/white"
android:paddingTop="@dimen/dp_7"
android:paddingBottom="@dimen/dp_7" />
<androidx.cardview.widget.CardView
android:id="@+id/card_show_more_food_name"
android:layout_width="@dimen/dp_38"
android:layout_height="match_parent"
android:background="@color/white"
android:visibility="gone"
app:cardElevation="@dimen/dp_10">
<ImageView
android:id="@+id/iv_unfold_arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/ic_inverted_triangle_66" />
</androidx.cardview.widget.CardView>
</LinearLayout>
</com.google.android.material.appbar.AppBarLayout>
</HorizontalScrollView>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_order_details_food_list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="@dimen/dp_10"
android:layout_weight="1"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
android:layout_height="match_parent"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="@color/white"
android:elevation="@dimen/dp_10"
android:orientation="vertical">
......@@ -225,14 +261,12 @@
tools:text="$300.00" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="horizontal">
<com.qmuiteam.qmui.alpha.QMUIAlphaTextView
android:id="@+id/tv_order_details_partial_receipt"
android:layout_width="0dp"
......
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/supply_chain_bg_color">
android:background="@color/supply_chain_bg_color"
android:orientation="vertical">
<include layout="@layout/supply_chain_top_bar" />
<com.google.android.material.appbar.AppBarLayout
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/trans">
android:layout_height="match_parent"
android:fillViewport="true">
<include
layout="@layout/supply_chain_top_bar"
app:layout_scrollFlags="scroll|enterAlways" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
......@@ -110,8 +114,7 @@
android:layout_marginLeft="@dimen/dp_10"
android:layout_marginTop="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_10"
android:orientation="horizontal"
app:layout_scrollFlags="scroll|enterAlwaysCollapsed">
android:orientation="horizontal">
<TextView
android:id="@+id/tv_warehousing_record"
......@@ -139,13 +142,11 @@
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_17" />
</LinearLayout>
</com.google.android.material.appbar.AppBarLayout>
<com.scwang.smartrefresh.layout.SmartRefreshLayout
android:id="@+id/srl_warehouse_details_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
app:srlAccentColor="@color/theme_333_color"
app:srlEnablePreviewInEditMode="true"
app:srlPrimaryColor="@color/trans">
......@@ -154,6 +155,7 @@
android:id="@+id/layout_warehousing_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:orientation="vertical">
<androidx.viewpager2.widget.ViewPager2
......@@ -163,4 +165,7 @@
android:layout_marginTop="@dimen/dp_10" />
</LinearLayout>
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
......@@ -9,8 +9,7 @@
android:layout_height="@dimen/dp_58"
android:layout_marginTop="@dimen/dp_8"
android:layout_marginRight="@dimen/dp_8"
android:scaleType="fitXY"
android:src="@drawable/awe" />
android:scaleType="fitXY" />
<ImageView
android:id="@+id/iv_img_delete"
......
......@@ -8,8 +8,10 @@
<include layout="@layout/item_show_sn_code" />
<FrameLayout
android:id="@+id/frame_sn_list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:minHeight="@dimen/dp_50"
android:layout_weight="1">
<androidx.recyclerview.widget.RecyclerView
......
......@@ -5,6 +5,7 @@
android:layout_width="match_parent"
android:layout_height="@dimen/head_height"
android:background="@color/theme_color"
app:layout_scrollFlags="scroll|enterAlways"
app:qmui_topbar_text_btn_color_state_list="@color/white"
app:qmui_topbar_title_color="@color/theme_white_color" />
......
......@@ -37,7 +37,7 @@
<string name="str_sn_code">SN碼</string>
<string name="str_restaurant_outbound_order">%1$s-出庫單</string>
<string name="str_no">NO:%1$s</string>
<string name="str_goods_no">NO:%1$s</string>
<string name="str_prepared">製單人:%1$s</string>
<string name="str_device_not_print">您的設備不支持打印</string>
<string name="str_sn_codes">SN碼:%1$s</string>
......@@ -51,5 +51,5 @@
<string name="str_number">數量</string>
<string name="str_amount">金額</string>
<string name="str_inventory_reason">消耗原因</string>
<string name="str_only_allowed_input_number">只允許輸入數字</string>
</resources>
\ No newline at end of file
......@@ -23,6 +23,7 @@ import android.os.Bundle;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
......@@ -36,6 +37,7 @@ import com.jess.arms.integration.lifecycle.ActivityLifecycleable;
import com.jess.arms.mvp.IPresenter;
import com.jess.arms.utils.ArmsUtils;
import com.jess.arms.utils.DeviceUtils;
import com.jess.arms.utils.SoftHideKeyBoardUtil;
import com.qmuiteam.qmui.arch.QMUIActivity;
import com.qmuiteam.qmui.arch.QMUIFragmentActivity;
import com.qmuiteam.qmui.util.QMUIDeviceHelper;
......
package com.jess.arms.utils;
import android.app.Activity;
import android.graphics.Rect;
import android.os.Build;
import android.util.Log;
import android.view.View;
import android.view.ViewTreeObserver;
import android.widget.FrameLayout;
/**
* @author 宇航.
* User: admin
* Date: 2021/4/20
* Time: 18:59
* Use:
*/
public class SoftHideKeyBoardUtil {
public static void assistActivity(Activity activity) {
new SoftHideKeyBoardUtil(activity);
}
private View mChildOfContent;
private int usableHeightPrevious;
private FrameLayout.LayoutParams frameLayoutParams;
//为适应华为小米等手机键盘上方出现黑条或不适配
private int contentHeight;//获取setContentView本来view的高度
private boolean isFirst = true;//只用获取一次
private int statusBarHeight;//状态栏高度
private SoftHideKeyBoardUtil(Activity activity) {
//1、找到Activity的最外层布局控件,它其实是一个DecorView,它所用的控件就是FrameLayout
FrameLayout content = (FrameLayout) activity.findViewById(android.R.id.content);
//2、获取到setContentView放进去的View
mChildOfContent = content.getChildAt(0);
//3、给Activity的xml布局设置View树监听,当布局有变化,如键盘弹出或收起时,都会回调此监听
//4、软键盘弹起会使GlobalLayout发生变化
mChildOfContent.getViewTreeObserver().addOnGlobalLayoutListener(() -> {
if (isFirst) {
contentHeight = mChildOfContent.getHeight();//兼容华为等机型
isFirst = false;
}
//5、当前布局发生变化时,对Activity的xml布局进行重绘
possiblyResizeChildOfContent();
});
//6、获取到Activity的xml布局的放置参数
frameLayoutParams = (FrameLayout.LayoutParams) mChildOfContent.getLayoutParams();
}
/**
* 获取界面可用高度,如果软键盘弹起后,Activity的xml布局可用高度需要减去键盘高度
*/
private void possiblyResizeChildOfContent() {
//1、获取当前界面可用高度,键盘弹起后,当前界面可用布局会减少键盘的高度
int usableHeightNow = computeUsableHeight();
//2、如果当前可用高度和原始值不一样
if (usableHeightNow != usableHeightPrevious) {
//3、获取Activity中xml中布局在当前界面显示的高度
int usableHeightSansKeyboard = mChildOfContent.getRootView().getHeight();
Log.e("eee", "顯示高度:" + usableHeightSansKeyboard);
//4、Activity中xml布局的高度-当前可用高度
int heightDifference = usableHeightSansKeyboard - usableHeightNow;
Log.e("eee", "鍵盤高度:" + heightDifference);
//5、高度差大于屏幕1/4时,说明键盘弹出
if (heightDifference > (usableHeightSansKeyboard / 4)) {
// 6、键盘弹出了,Activity的xml布局高度应当减去键盘高度
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
frameLayoutParams.height = usableHeightSansKeyboard - heightDifference + statusBarHeight;
} else {
frameLayoutParams.height = usableHeightSansKeyboard - heightDifference;
}
Log.e("eee", "頁面高度:" + frameLayoutParams.height);
} else {
frameLayoutParams.height = contentHeight;
}
//7、 重绘Activity的xml布局
mChildOfContent.requestLayout();
usableHeightPrevious = usableHeightNow;
}
}
private int computeUsableHeight() {
Rect r = new Rect();
mChildOfContent.getWindowVisibleDisplayFrame(r);
// 全屏模式下:直接返回r.bottom,r.top其实是状态栏的高度
return (r.bottom - r.top);
}
/**
* 软键盘弹出布局向上滑动
*
* @param rootView 根布局
* @param bottomView 需要显示的最下方View,
*/
public static void layoutSlideListener(final View rootView, final View bottomView) {
rootView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
Rect rect = new Rect();
rootView.getWindowVisibleDisplayFrame(rect);//获取rootView的可视区域
int invisibleHeight = rootView.getRootView().getHeight() - rect.bottom;//获取rootView的不可视区域高度
if (invisibleHeight > 150) { //键盘显示
int[] location = new int[2];
bottomView.getLocationInWindow(location); //获取bottomView的坐标
int scrollHeight = (location[1] + bottomView.getHeight()) - rect.bottom + 40;//算出需要滚动的高度(与初始布局的偏移量,可调整)
if (scrollHeight != 0) {//防止界面元素改变调用监听,使界面上下跳动,如验证码倒计时
rootView.scrollTo(0, scrollHeight);
}
} else {
rootView.scrollTo(0, 0);
}
}
});
}
}
......@@ -44,7 +44,9 @@ class ICommandService : Service() {
/**
* 心跳检测时间
*/
private val heartBeatRate = (30 * 1000).toLong()//每隔30秒进行一次对长连接的心跳检测
private val heartBeatRate = 30L//每隔30秒进行一次对长连接的心跳检测
private val warningTime = 60L//超過六十秒還未重連,報警推送
/**
* 可替换为自己的主机名和端口号
......@@ -288,18 +290,19 @@ class ICommandService : Service() {
// 初始化socket
private fun initSocket() {
putTimeLog("取消心跳")
putTimeLog("initSocket開始輪詢")
heartPolling?.dispose()
heartPolling = RxJavaUtils.polling(0, heartBeatRate) {
run {
//保持設備喚醒
newWakeLock?.acquire(10 * 60 * 1000L /*10 minutes*/)
putTimeLog("開啟心跳")
//先斷開之前的
client?.let { it ->
mWebSocket?.let {
it.cancel()
it.send("-1")
it.close(1000, null)
it.close(1000, "手動斷開")
putTimeLog("開啟之前先斷開心跳")
}
it.dispatcher().cancelAll()
}
......@@ -314,7 +317,7 @@ class ICommandService : Service() {
if (!this@ICommandService.isDestroy) {
mWebSocket = webSocket
send(mCurrConnectionType)
putTimeLog("連接成功")
putTimeLog("onOpen心跳連接成功")
warningDelay?.dispose()
myBind?.block?.invoke(false)
}
......@@ -328,7 +331,7 @@ class ICommandService : Service() {
postCallBack!!.callBack(type)
}
//收到服务器端传过来的消息text
putTimeLog("收到回調:$text")
putTimeLog("onMessage收到回調:$text")
//-1斷開連接,
// \n-2:消息傳輸錯誤,
// \n0:連接消息,
......@@ -362,7 +365,7 @@ class ICommandService : Service() {
override fun onMessage(webSocket: WebSocket, bytes: ByteString) {
super.onMessage(webSocket, bytes)
val json = JSONObject(bytes.toString())
putTimeLog("onMessage2:$bytes")
putTimeLog("收到消息onMessage:$bytes")
if (postCallBack != null) {
postCallBack!!.callBack(json.optInt("type"))
}
......@@ -371,27 +374,31 @@ class ICommandService : Service() {
override fun onClosing(webSocket: WebSocket, code: Int, reason: String) {
super.onClosing(webSocket, code, reason)
//連接斷開,
putTimeLog("onClosing關閉連接")
putTimeLog("onClosing關閉連接,code:$code——reason:$reason")
}
override fun onClosed(webSocket: WebSocket, code: Int, reason: String) {
super.onClosed(webSocket, code, reason)
putTimeLog("onClosed斷開連接")
putTimeLog("onClosed斷開連接,Code:$code——reason:$reason")
webSocket.cancel()
}
override fun onFailure(webSocket: WebSocket, t: Throwable, response: Response?) {//长连接连接失败的回调
super.onFailure(webSocket, t, response)
Log.e(TAG, "onFailure " + t.message)
putTimeLog("onFailure連接失敗,——reason:$t")
if (!this@ICommandService.isDestroy) {
//連接斷開,定時五秒,如果未重連,播放提示音
warningDelay = RxJavaUtils.delay(60) {
putTimeLog("onFailure連接失敗,延時任務狀態${warningDelay?.isDisposed}")
if (warningDelay == null || warningDelay!!.isDisposed) {
warningDelay = RxJavaUtils.delay(warningTime) {
putTimeLog("執行心跳斷開六十秒報警延時任務")
initSoundPool(R.raw.raw_disconnect)
myBind?.block?.invoke(true)
//推送給相關人員
OkHttp3Utils.noticePersonnel(AppConstans.RP_HEART_ERROR, "心跳斷開十秒以上未連接成功:" + t.message)
OkHttp3Utils.noticePersonnel(AppConstans.RP_HEART_ERROR, "心跳斷開六十秒以上未連接成功:" + t.message)
}
putTimeLog("onFailure連接失敗,開始等待一分鐘後重新連接")
}
putTimeLog("onFailure連接失敗,等待一分鐘後重新連接")
} else {
webSocket.cancel()
it.dispatcher().cancelAll()
......
......@@ -36,10 +36,20 @@ public class InputFilterUtils {
* 只能輸入英文和數字
*/
public static final Pattern enAndNum = Pattern.compile("[a-zA-Z0-9]+");
/**
* 只允許輸入小寫字母
*/
public static final Pattern enPattern = Pattern.compile("[a-z]");
/**
* 只允許輸入數字
*/
private final static Pattern pattern = Pattern.compile("[0-9]*");
/**
* 驗證小數,兩位
*/
private final static Pattern decimalPattern = Pattern.compile("^[0-9]*\\.?[0-9]{0,2}");
/**
* 只能輸入中英文和數字還有一些標點符號
* Punctuation
*/
......@@ -65,9 +75,11 @@ public class InputFilterUtils {
public static InputFilter getChAndEnAndNumAndPtInputFilter(Context mContext) {
return InputFilterUtils.getTypeFilter(mContext, "請輸入正確的字符", chAndEnAndNumAndPt);
}
public static InputFilter getChAndEnNumPtWrapInputFilter(Context mContext) {
return InputFilterUtils.getTypeFilter(mContext, "請輸入正確的字符", chAndEnNumPtWrap);
}
public static InputFilter getTypeFilter(Context mContext, Pattern p) {
return InputFilterUtils.getTypeFilter(mContext, "不支持輸入此內容", p);
}
......@@ -88,6 +100,10 @@ public class InputFilterUtils {
return InputFilterUtils.getMaxLengthFilter(mContext, "最多輸入" + maxLength + "個字", maxLength);
}
public static InputFilter getNumberFilter(Context context) {
return getNumberFilter(context, "只允許輸入數字");
}
/**
* source 新输入的字符串
* start 新输入的字符串起始下标,一般为0
......@@ -229,8 +245,8 @@ public class InputFilterUtils {
public void onTextChanged(CharSequence s, int start, int before, int count) {
Log.e("eee", "onTextChanged:" + s + "——start:" + start + "——count:" + count + "——before:" + before);
if (s.length() > 0) {
String str = s.toString().trim().charAt(0)+"";
if(enPattern.matcher( str).matches()){
String str = s.toString().trim().charAt(0) + "";
if (enPattern.matcher(str).matches()) {
}
}
......@@ -242,5 +258,61 @@ public class InputFilterUtils {
}
};
}
/**
* 輸入小數
*
* @param context
* @param tipString 超過最大長度限制的提示
* @return source 當前輸入內容
* dest 輸入框中的內容
*/
public static InputFilter getNumberFilter(Context context, String tipString) {
return (source, start, end, dest, dstart, dend) -> {
if (source.equals(".")) {
if (dstart == 0 || !(dest.charAt(dstart - 1) >= '0' && dest.charAt(dstart - 1) <= '9') || dest.charAt(0) == '0') {
return "";
}
}
if (source.equals("0") && (dest.toString()).contains(".") && dstart == 0) { //防止在369.369的最前面输入0变成0369.369这种不合法的形式
return "";
}
StringBuilder builder = new StringBuilder(dest);
builder.delete(dstart, dend);
builder.insert(dstart, source);
if (!decimalPattern.matcher(builder.toString()).matches()) {
ToastUtils.show(context, tipString);
return "";
}
// if (TextUtils.isEmpty(source)) {
// return null;
// }
// if (!isNumeric(source + "")) {
// return "";
// }
// String dValue = dest.toString();
// String[] splitArray = dValue.split("\\.");
// if (splitArray.length > 1) {
// String dotValue = splitArray[1];
// // 2 表示输入框的小数位数
// int diff = dotValue.length() + 1 - 2;
// if (diff > 0) {
// return source.subSequence(start, end - diff);
// }
// }
return null;
};
}
/**
* 是否是數字
*
* @param str
* @return
*/
public static boolean isNumeric(String str) {
return pattern.matcher(str).matches();
}
}
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="@dimen/dp_12" />
<solid android:color="@color/other_order_details_print_btn_color" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="@dimen/dp_12" />
<solid android:color="@color/brick_red" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="@dimen/dp_12" />
<stroke
android:width="@dimen/dp_1"
android:color="@color/theme_color" />
<solid android:color="@color/white" />
</shape>
\ No newline at end of file
......@@ -479,6 +479,7 @@
<color name="color_48">#484848</color>
<color name="color_75">#757575</color>
<color name="color_b8">#B8B8B8</color>
<color name="common_pressed">#20000000</color> <!--白色背景按下去的颜色-->
<color name="tran_twenty_send_order_btn_bg_color">#331196DB</color>
<color name="tran_fifty_order_state0_color">#7F009788</color>
<!-- 待確認背景色-->
......
......@@ -237,7 +237,11 @@
<string name="str_operating">操作</string>
<string name="str_serial_number">序號</string>
<string name="str_info_no_save_leave">信息未保存,是否離開?</string>
<string name="str_about_to_leave">即將離開,信息是否保存?</string>
<string name="str_save_and_leave">保存並離開</string>
<string name="str_leave">離開</string>
<string name="str_yes"></string>
<string name="str_no"></string>
</resources>
package com.gingersoft.gsa.cloud.ui;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.gingersoft.gsa.cloud.ui.test", appContext.getPackageName());
}
}
\ No newline at end of file
......@@ -20,9 +20,9 @@ import java.util.List;
* User: admin
* Date: 2020/11/28
* Time: 11:45
* Use:
* Use: 繼承重寫自己的layout
*/
public class BaseCategoryAdapter extends BaseQuickAdapter<CategoryBean, BaseViewHolder> {
public abstract class BaseSelectorAdapter<T, VH extends BaseViewHolder> extends BaseQuickAdapter<T, VH> {
private int selectedIndex = 0;
private int selectedBg;
......@@ -30,45 +30,16 @@ public class BaseCategoryAdapter extends BaseQuickAdapter<CategoryBean, BaseView
private int selectColor;
private int unSelectColor;
private boolean showDelete = false;
public BaseCategoryAdapter(@Nullable List<CategoryBean> data) {
super(R.layout.item_base_category, data);
addChildClickViewIds(R.id.iv_category_delete);
selectedBg = R.drawable.shape_left_radio_shadow;
unSelectedBg = R.color.trans;
selectColor = R.color.s_btn_blue_3c_text;
unSelectColor = R.color.color_ccc;
}
public BaseCategoryAdapter(int layoutRes, @Nullable List<CategoryBean> data) {
public BaseSelectorAdapter(int layoutRes, @Nullable List<T> data) {
super(layoutRes, data);
addChildClickViewIds(R.id.iv_category_delete);
selectedBg = R.drawable.shape_left_radio_shadow;
unSelectedBg = R.color.trans;
selectedBg = R.drawable.shape_white_eight_corners_bg;
unSelectedBg = R.drawable.shape_theme_eight_corners_bg;
selectColor = R.color.s_btn_blue_3c_text;
unSelectColor = R.color.color_ccc;
}
@Override
protected void convert(@NotNull BaseViewHolder viewHolder, CategoryBean categoryBean) {
viewHolder.setText(R.id.tv_base_item_title, categoryBean.getCategoryName());
notifyCheckState(viewHolder.getAdapterPosition(), viewHolder.getView(R.id.tv_base_item_title), viewHolder.getView(R.id.item_layout_root));
viewHolder.setGone(R.id.iv_category_delete, !showDelete);
}
@Override
public void onBindViewHolder(@NotNull BaseViewHolder holder, int position, @NotNull List<Object> payloads) {
super.onBindViewHolder(holder, position, payloads);
//list为空时,必须调用两个参数的onBindViewHolder(@NonNull LabelHolder holder, int position)
if (payloads.isEmpty()) {
onBindViewHolder(holder, position);
} else {
notifyCheckState(position, holder.getView(R.id.tv_base_item_title), holder.getView(R.id.item_layout_root));
}
}
private void notifyCheckState(int position, TextView tvName, View view) {
protected void notifyCheckState(int position, TextView tvName, View view) {
if (position == selectedIndex) {
view.setBackground(ContextCompat.getDrawable(getContext(), selectedBg));
tvName.setTextColor(selectColor);
......@@ -80,32 +51,27 @@ public class BaseCategoryAdapter extends BaseQuickAdapter<CategoryBean, BaseView
}
}
public void setShowDelete(boolean showDelete) {
this.showDelete = showDelete;
notifyDataSetChanged();
}
public BaseCategoryAdapter setSelectedBg(int selectedBg) {
public BaseSelectorAdapter setSelectedBg(int selectedBg) {
this.selectedBg = selectedBg;
return this;
}
public BaseCategoryAdapter setUnSelectedBg(int unSelectedBg) {
public BaseSelectorAdapter setUnSelectedBg(int unSelectedBg) {
this.unSelectedBg = unSelectedBg;
return this;
}
public BaseCategoryAdapter setSelectColor(int selectColor) {
public BaseSelectorAdapter setSelectColor(int selectColor) {
this.selectColor = selectColor;
return this;
}
public BaseCategoryAdapter setUnSelectColor(int unSelectColor) {
public BaseSelectorAdapter setUnSelectColor(int unSelectColor) {
this.unSelectColor = unSelectColor;
return this;
}
public BaseCategoryAdapter setSelectedIndex(int selectedIndex) {
public BaseSelectorAdapter setSelectedIndex(int selectedIndex) {
this.selectedIndex = selectedIndex;
notifyDataSetChanged();
return this;
......
......@@ -227,8 +227,9 @@ public class InfoMultiBean {
return maxLength;
}
public void setMaxLength(int maxLength) {
public InfoMultiBean setMaxLength(int maxLength) {
this.maxLength = maxLength;
return this;
}
public List<InfoMultiBean> getInfoMultiBeans() {
......
......@@ -99,24 +99,27 @@ public class MultiInputBean extends InfoMultiBean {
}
@Override
public void setMaxLength(int maxLength) {
public MultiInputBean setMaxLength(int maxLength) {
this.maxLength = maxLength;
return this;
}
public TextWatcher getTextWatcher() {
return textWatcher;
}
public void setTextWatcher(TextWatcher textWatcher) {
public MultiInputBean setTextWatcher(TextWatcher textWatcher) {
this.textWatcher = textWatcher;
return this;
}
public boolean isEdit() {
return isEdit;
}
public void setEdit(boolean edit) {
public MultiInputBean setEdit(boolean edit) {
isEdit = edit;
return this;
}
public View.OnFocusChangeListener getOnFocusChangeListener() {
......
......@@ -32,5 +32,6 @@ public class BooleanItemProvider<T extends InfoMultiBean> extends MyBaseItemProv
SwitchCompat sw = baseViewHolder.getView(R.id.switch_multi_boolean_state);
sw.setChecked(infoMultiBean.isChecked());
sw.setOnCheckedChangeListener((buttonView, isChecked) -> infoMultiBean.setChecked(isChecked));
baseViewHolder.itemView.setOnClickListener(v -> sw.toggle());
}
}
package com.gingersoft.gsa.cloud.ui.bean
import android.graphics.Color
/**
* <pre>
* @author : Allen
* e-mail : lygttpod@163.com
* date : 2019/09/22
* desc :
* </pre>
*/
class AttributeSetData {
var shapeType = -1
var solidColor = -1
var strokeWidth = -1
var strokeColor = -1
var strokeDashWidth = 0.0f
var strokeDashGap = 0.0f
var cornersRadius = 0.0f
var cornersTopLeftRadius = 0.0f
var cornersTopRightRadius = 0.0f
var cornersBottomLeftRadius = 0.0f
var cornersBottomRightRadius = 0.0f
var gradientAngle = -1
var gradientCenterX: Int = 0
var gradientCenterY: Int = 0
var gradientGradientRadius: Int = 0
var gradientStartColor = -1
var gradientCenterColor = -1
var gradientEndColor = -1
var gradientType: Int = 0
var gradientUseLevel: Boolean = false
var sizeWidth = -1
var sizeHeight = -1
var selectorPressedColor: Int = 0
var selectorDisableColor: Int = 0
var selectorNormalColor: Int = 0
var useSelector: Boolean = false
//////////阴影相关////////
var showShadow: Boolean = false
var shadowColor: Int = Color.GRAY
var shadowColorAlpha: Float = 0.2f
var shadowLeftWidth: Float = 0f
var shadowTopWidth: Float = 0f
var shadowRightWidth: Float = 0f
var shadowBottomWidth: Float = 0f
var shadowCornersRadius: Float = 0f
var shadowCornersTopLeftRadius: Float = 0f
var shadowCornersTopRightRadius: Float = 0f
var shadowCornersBottomLeftRadius: Float = 0f
var shadowCornersBottomRightRadius: Float = 0f
}
\ No newline at end of file
......@@ -122,6 +122,7 @@ public class AppDialog {
if (sureOnclickListener != null) {
sureOnclickListener.onclick(v, dialog);
}
dialog.dismiss();
});
hepler.getView(R.id.tv_dialog_cancel).setOnClickListener(v -> {
dismiss();
......
package com.gingersoft.gsa.cloud.ui.view;
import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PaintFlagsDrawFilter;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.animation.Animation;
import android.view.animation.CycleInterpolator;
import android.view.animation.TranslateAnimation;
import androidx.appcompat.widget.AppCompatEditText;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.drawable.DrawableCompat;
import com.gingersoft.gsa.cloud.ui.R;
/**
* @author 宇航.
* User: admin
* Date: 2021/1/28
* Time: 12:28
* Use:
*/
public class ClearEditText extends AppCompatEditText {
//按钮资源
private final int CLEAR = R.drawable.ic_clear_text;
//动画时长
private final int ANIMATOR_TIME = 200;
//按钮左右间隔,单位DP
private final int INTERVAL = 5;
//清除按钮宽度,单位DP
private final int WIDTH_OF_CLEAR = 23;
//间隔记录
private int Interval;
//清除按钮宽度记录
private int mWidth_clear;
//右内边距
private int mPaddingRight;
//清除按钮的bitmap
private Bitmap mBitmap_clear;
//清除按钮出现动画
private ValueAnimator mAnimator_visible;
//消失动画
private ValueAnimator mAnimator_gone;
//是否显示的记录
private boolean isVisible = false;
//右边添加其他按钮时使用
private int mRight = 0;
public ClearEditText(final Context context) {
super(context);
init(context);
}
public ClearEditText(final Context context, final AttributeSet attrs) {
super(context, attrs);
init(context);
}
public ClearEditText(final Context context, final AttributeSet attrs, final int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context);
}
private void init(Context context) {
mBitmap_clear = createBitmap(CLEAR, context);
Interval = dp2px(INTERVAL);
mWidth_clear = dp2px(WIDTH_OF_CLEAR);
mPaddingRight = Interval + mWidth_clear + Interval;
mAnimator_gone = ValueAnimator.ofFloat(1f, 0f).setDuration(ANIMATOR_TIME);
mAnimator_visible = ValueAnimator.ofInt(mWidth_clear + Interval, 0).setDuration(ANIMATOR_TIME);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
//设置内边距
// setPadding(getPaddingLeft(), getPaddingTop(), mPaddingRight + mRight, getPaddingBottom());
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.setDrawFilter(new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG));//抗锯齿
if (mAnimator_visible.isRunning()) {
int x = (int) mAnimator_visible.getAnimatedValue();
drawClear(x, canvas);
invalidate();
} else if (isVisible) {
drawClear(0, canvas);
}
if (mAnimator_gone.isRunning()) {
float scale = (float) mAnimator_gone.getAnimatedValue();
drawClearGone(scale, canvas);
invalidate();
}
}
/**
* 绘制清除按钮出现的图案
*
* @param translationX 水平移动距离
* @param canvas
*/
protected void drawClear(int translationX, Canvas canvas) {
int right = getWidth() + getScrollX() - Interval - mRight + translationX;
int left = right - mWidth_clear;
int top = (getHeight() - mWidth_clear) / 2;
int bottom = top + mWidth_clear;
Rect rect = new Rect(left, top, right, bottom);
canvas.drawBitmap(mBitmap_clear, null, rect, null);
}
/**
* 绘制清除按钮消失的图案
*
* @param scale 缩放比例
* @param canvas
*/
protected void drawClearGone(float scale, Canvas canvas) {
int right = (int) (getWidth() + getScrollX() - Interval - mRight - mWidth_clear * (1f - scale) / 2f);
int left = (int) (getWidth() + getScrollX() - Interval - mRight - mWidth_clear * (scale + (1f - scale) / 2f));
int top = (int) ((getHeight() - mWidth_clear * scale) / 2);
int bottom = (int) (top + mWidth_clear * scale);
Rect rect = new Rect(left, top, right, bottom);
canvas.drawBitmap(mBitmap_clear, null, rect, null);
}
/**
* 开始清除按钮的显示动画
*/
private void startVisibleAnimator() {
endAnimator();
mAnimator_visible.start();
invalidate();
}
/**
* 开始清除按钮的消失动画
*/
private void startGoneAnimator() {
endAnimator();
mAnimator_gone.start();
invalidate();
}
/**
* 结束所有动画
*/
private void endAnimator() {
mAnimator_gone.end();
mAnimator_visible.end();
}
/**
* Edittext内容变化的监听
*/
@Override
protected void onTextChanged(CharSequence text, int start, int lengthBefore, int lengthAfter) {
super.onTextChanged(text, start, lengthBefore, lengthAfter);
if (text.length() > 0) {
if (!isVisible) {
isVisible = true;
startVisibleAnimator();
}
} else {
if (isVisible) {
isVisible = false;
startGoneAnimator();
}
}
}
/**
* 触控执行的监听
*
* @param event
* @return
*/
@Override
public boolean onTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_UP) {
boolean touchable = (getWidth() - Interval - mRight - mWidth_clear < event.getX()) && (event.getX() < getWidth() - Interval - mRight);
if (touchable) {
setError(null);
this.setText("");
}
}
return super.onTouchEvent(event);
}
/**
* 开始晃动动画
*/
public void startShakeAnimation() {
if (getAnimation() == null) {
this.setAnimation(shakeAnimation(4));
}
this.startAnimation(getAnimation());
}
/**
* 晃动动画
*
* @param counts 0.5秒钟晃动多少下
* @return
*/
private Animation shakeAnimation(int counts) {
Animation translateAnimation = new TranslateAnimation(0, 10, 0, 0);
translateAnimation.setInterpolator(new CycleInterpolator(counts));
translateAnimation.setDuration(500);
return translateAnimation;
}
/**
* 给图标染上当前提示文本的颜色并且转出Bitmap
*
* @param resources
* @param context
* @return
*/
public Bitmap createBitmap(int resources, Context context) {
final Drawable drawable = ContextCompat.getDrawable(context, resources);
final Drawable wrappedDrawable = DrawableCompat.wrap(drawable);
DrawableCompat.setTint(wrappedDrawable, getCurrentHintTextColor());
return drawableToBitamp(wrappedDrawable);
}
/**
* drawable转换成bitmap
*
* @param drawable
* @return
*/
private Bitmap drawableToBitamp(Drawable drawable) {
int w = drawable.getIntrinsicWidth();
int h = drawable.getIntrinsicHeight();
Bitmap.Config config = drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565;
Bitmap bitmap = Bitmap.createBitmap(w, h, config);
Canvas canvas = new Canvas(bitmap);
drawable.setBounds(0, 0, w, h);
drawable.draw(canvas);
return bitmap;
}
public int dp2px(float dipValue) {
final float scale = getResources().getDisplayMetrics().density;
return (int) (dipValue * scale + 0.5f);
}
}
\ No newline at end of file
package com.gingersoft.gsa.cloud.ui.view.helper
import android.annotation.TargetApi
import android.os.Build
import android.widget.EditText
import android.widget.TextView
import androidx.annotation.DrawableRes
import java.lang.reflect.Field
/**
* @name SuperTextView
* @author Realmo
* @email momo.weiye@gmail.com
* @version 1.0.0
* @time 2020/12/14 10:27
* @describe
*/
object EditTextHelper {
@TargetApi(Build.VERSION_CODES.O)
fun setCursorDrawable(editText:EditText,@DrawableRes drawableRes:Int){
try { //修改光标的颜色(反射)
val f: Field = TextView::class.java.getDeclaredField("mCursorDrawableRes")
f.setAccessible(true)
f.set(editText, drawableRes)
} catch (e: Exception) {
e.printStackTrace()
}
}
}
\ No newline at end of file
package com.gingersoft.gsa.cloud.ui.view;
package com.gingersoft.gsa.cloud.ui.view.textview;
import android.content.Context;
import android.graphics.Canvas;
......
package com.gingersoft.gsa.cloud.ui.view.textview;
import android.content.Context;
import android.text.InputFilter;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.appcompat.widget.AppCompatTextView;
/**
* Created by Allen on 2017/6/29.
* <p>
* 基础TextView
*/
public class BaseTextView extends LinearLayout {
private Context mContext;
private AppCompatTextView topTextView, centerTextView, bottomTextView;
private LinearLayout.LayoutParams topTVParams, centerTVParams, bottomTVParams;
public BaseTextView(Context context) {
this(context, null);
}
public BaseTextView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public BaseTextView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
this.setOrientation(VERTICAL);
mContext = context;
initView();
}
private void initView() {
initTopView();
initCenterView();
initBottomView();
}
private void initTopView() {
if (topTVParams == null) {
topTVParams = getParams(topTVParams);
}
if (topTextView == null) {
topTextView = initTextView(topTVParams, topTextView);
}
}
private void initCenterView() {
if (centerTVParams == null) {
centerTVParams = getParams(centerTVParams);
}
if (centerTextView == null) {
centerTextView = initTextView(centerTVParams, centerTextView);
}
}
private void initBottomView() {
if (bottomTVParams == null) {
bottomTVParams = getParams(bottomTVParams);
}
if (bottomTextView == null) {
bottomTextView = initTextView(bottomTVParams, bottomTextView);
}
}
private AppCompatTextView initTextView(LinearLayout.LayoutParams params, AppCompatTextView textView) {
textView = getTextView(textView, params);
// textView.setGravity(Gravity.CENTER);
addView(textView);
return textView;
}
/**
* 初始化textView
*
* @param textView 对象
* @param layoutParams 对象
* @return 返回
*/
public AppCompatTextView getTextView(AppCompatTextView textView, LinearLayout.LayoutParams layoutParams) {
if (textView == null) {
textView = new AppCompatTextView(mContext);
textView.setLayoutParams(layoutParams);
textView.setVisibility(GONE);
}
return textView;
}
/**
* 初始化Params
*
* @param params 对象
* @return 返回
*/
public LayoutParams getParams(LayoutParams params) {
if (params == null) {
// TODO: 2017/7/21 问题记录 :之前设置 MATCH_PARENT导致每次重新设置string的时候,textView的宽度都已第一次为准,在列表中使用的时候服用出现混乱,特此记录一下,以后处理好布局之间套用时候设置WRAP_CONTENT和MATCH_PARENT出现问题
params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
}
return params;
}
private void setTextString(AppCompatTextView textView, CharSequence textString) {
textView.setText(textString);
if (!TextUtils.isEmpty(textString)) {
textView.setVisibility(VISIBLE);
}
}
public void setTopTextString(CharSequence s) {
setTextString(topTextView, s);
}
public void setCenterTextString(CharSequence s) {
setTextString(centerTextView, s);
}
public void setBottomTextString(CharSequence s) {
setTextString(bottomTextView, s);
}
public AppCompatTextView getTopTextView() {
return topTextView;
}
public AppCompatTextView getCenterTextView() {
return centerTextView;
}
public AppCompatTextView getBottomTextView() {
return bottomTextView;
}
public void setMaxEms(int topMaxEms, int centerMaxEms, int bottomMaxEms) {
if (topMaxEms != 0) {
topTextView.setEllipsize(TextUtils.TruncateAt.END);
topTextView.setFilters(new InputFilter[]{new InputFilter.LengthFilter(topMaxEms)});
}
if (centerMaxEms != 0) {
centerTextView.setEllipsize(TextUtils.TruncateAt.END);
centerTextView.setFilters(new InputFilter[]{new InputFilter.LengthFilter(centerMaxEms)});
}
if (bottomMaxEms != 0) {
bottomTextView.setEllipsize(TextUtils.TruncateAt.END);
bottomTextView.setFilters(new InputFilter[]{new InputFilter.LengthFilter(bottomMaxEms)});
}
}
public void setFakeBoldText(TextView textView, boolean isBold) {
if (textView != null) {
textView.getPaint().setFakeBoldText(isBold);
//在点击事件里边设置setFakeBoldText是无效的,必须调用invalidate刷新一下view
textView.invalidate();
}
}
public void setCenterSpaceHeight(int centerSpaceHeight) {
topTVParams.setMargins(0, 0, 0, centerSpaceHeight);
centerTVParams.setMargins(0, 0, 0, 0);
bottomTVParams.setMargins(0, centerSpaceHeight, 0, 0);
}
}
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@color/common_pressed"
android:state_pressed="true" />
<item
android:drawable="@color/white" />
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/card_base_select_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:cardCornerRadius="@dimen/dp_12"
app:cardElevation="@dimen/dp_3">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_sn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_8"
android:layout_marginTop="@dimen/dp_5"
android:layout_marginBottom="@dimen/dp_5"
android:gravity="center"
android:textSize="@dimen/dp_10"
android:textStyle="bold"
android:text="SN" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_base_select_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_8"
android:layout_marginTop="@dimen/dp_5"
android:layout_marginRight="@dimen/dp_8"
android:layout_marginBottom="@dimen/dp_5"
android:gravity="center"
android:textSize="@dimen/dp_12"
tools:text="掛果類" />
</LinearLayout>
</androidx.cardview.widget.CardView>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
style="@style/Multi_Layout_Style"
android:layout_width="match_parent"
android:gravity="center_vertical">
......
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="sLeftViewId" type="id" />
<item name="sCenterViewId" type="id" />
<item name="sRightViewId" type="id" />
<item name="sLeftImgId" type="id" />
<item name="sRightImgId" type="id" />
<item name="sRightCheckBoxId" type="id" />
<item name="sRightSwitchId" type="id" />
<item name="sRightEditTextId" type="id" />
</resources>
\ No newline at end of file
package com.gingersoft.gsa.cloud.ui;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}
\ No newline at end of file
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