Commit 2194c6e3 by 宁斌

Merge branch 'dev' of http://gitlab.ricepon.com/ningbin/GSA-Cloud into dev

 Conflicts:
	library-common/build.gradle
parents 476dc755 09fb6511
......@@ -63,14 +63,8 @@ public class OrderListPresenter extends BasePresenter<OrderListContract.Model, O
}
private List<OrderList.DataBeanX.DataBean> orderList = new ArrayList<>();
private Disposable disposable;
public void getOrderList(int restaurantId, int page, String status, String type, String phone) {
if (disposable != null) {
if (!disposable.isDisposed()) {
return;
}
}
RequestBody requestBody = new FormBody.Builder()
.add("restaurantId", restaurantId + "")
.add("page", page + "")
......@@ -91,13 +85,10 @@ public class OrderListPresenter extends BasePresenter<OrderListContract.Model, O
@Override
public void onSubscribe(Disposable d) {
super.onSubscribe(d);
disposable = d;
}
@Override
public void onNext(@NonNull OrderList info) {
disposable.dispose();
disposable = null;
if (page == 1) {
orderList.clear();
}
......
......@@ -53,23 +53,16 @@ import com.qmuiteam.qmui.util.QMUIDisplayHelper;
import com.qmuiteam.qmui.widget.QMUITopBar;
import com.qmuiteam.qmui.widget.popup.QMUIPopup;
import com.qmuiteam.qmui.widget.popup.QMUIPopups;
import com.xuexiang.rxutil2.exception.RxException;
import com.xuexiang.rxutil2.rxjava.RxJavaUtils;
import com.xuexiang.rxutil2.subsciber.BaseSubscriber;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;
import butterknife.BindView;
import butterknife.OnClick;
import io.reactivex.Observable;
import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;
import static androidx.fragment.app.FragmentStatePagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT;
import static com.jess.arms.utils.Preconditions.checkNotNull;
......@@ -85,7 +78,6 @@ public class ColdChainMainActivity extends BaseFragmentActivity<ColdChainMainPre
TabLayout tabLayout;
@BindView(R2.id.tv_balance)
TextView tvBalance;
@BindView(R2.id.cold_chain_takeaway_progress)
ProgressBar mTakeAwayPb;
@BindView(R2.id.tv_cold_chain_takeaway_num)
......@@ -161,7 +153,6 @@ public class ColdChainMainActivity extends BaseFragmentActivity<ColdChainMainPre
initService();
initHearBroadcast();
autoReceivingOrders.setChecked(RestaurantExpandInfoUtils.getValue(ExpandConstant.FrozenChainAutoOrder, false));
autoReceivingOrders.setOnCheckedChangeListener((buttonView, isChecked) -> {
RestaurantExpandInfoUtils.setValue(ExpandConstant.FrozenChainAutoOrder, isChecked);
if (autoOrderDisposable != null && !autoOrderDisposable.isDisposed()) {
......@@ -174,6 +165,7 @@ public class ColdChainMainActivity extends BaseFragmentActivity<ColdChainMainPre
mPresenter.stopAutoReceivingOrders();
}
});
autoReceivingOrders.setChecked(RestaurantExpandInfoUtils.getValue(ExpandConstant.FrozenChainAutoOrder, false));
}
public void getNumByOrderTypeInvoke(String functionName) {
......@@ -261,9 +253,6 @@ public class ColdChainMainActivity extends BaseFragmentActivity<ColdChainMainPre
if (type == 3 || type == 6 || type == 7) {
getNumByOrderTypeInvoke("loadNumber");
}
if (autoReceivingOrders.isChecked()) {
mPresenter.startToBeConfirmedOrderList(restaurantId);
}
});
bind.execute(aBoolean -> null);
bind.setJumpActivity(ColdChainMainActivity.class);
......
......@@ -200,7 +200,7 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl
super.onResume();
initFuncationData();
if (((int) SPUtils.get("isFormal", 0)) != 0) {
tv_version_name.setText("v_" + DeviceUtils.getVersionName(this) + "\u1500Beta");
tv_version_name.setText("v_" + DeviceUtils.getVersionName(this) + "\u3000Beta");
} else {
tv_version_name.setText("v_" + DeviceUtils.getVersionName(this));
}
......
<?xml version="1.0" encoding="utf-8"?>
<com.qmuiteam.qmui.alpha.QMUIAlphaLinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/dp_20"
android:gravity="center"
......@@ -18,10 +18,11 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:maxLength="4"
android:layout_marginTop="@dimen/dp_8"
android:text="餐檯模式"
android:singleLine="true"
android:ellipsize="marquee"
android:ellipsize="end"
android:textColor="@color/normal_color"
android:textSize="@dimen/sp_12" />
......
......@@ -151,8 +151,9 @@ public class PrintServe extends PrinterRoot<PrintServingPaperContent> {
//訂單信息
layout.addView(getDiningTableOrderInfo(mContext, "餐檯:" + mPrintServingPaperContent.getTableName(), "人數:" + mPrintServingPaperContent.getPerson(), orderNo, "日期:" + TimeUtils.getCurrentTimeInString(TimeUtils.DEFAULT_DATE_FORMAT)));
layout.addView(getLine(mContext));
//食品
layout.addView(getDiningFoodList(mContext, foodItemList, printerDeviceBean, 0, false));
//打印紙
layout.addView(getLine(mContext));
layout.addView(getTextView(mContext, "Thank you!", Gravity.CENTER_HORIZONTAL, getDimensionPixelSize(mContext, R.dimen.dp_8)));
layout.addView(getTextView(mContext, TimeUtils.getCurrentTimeInString(TimeUtils.DEFAULT_DATE_FORMAT), Gravity.CENTER_HORIZONTAL, getDimensionPixelSize(mContext, R.dimen.dp_8)));
......
......@@ -76,6 +76,10 @@ import com.joe.print.mvp.ui.adapter.BillAdapter;
import com.joe.print.mvp.ui.adapter.BillItemAdapter;
import com.joe.print.mvp.ui.adapter.BillTypeAdapter;
import com.joe.print.mvp.ui.adapter.FoodAdapter;
import com.joe.print.mvp.ui.view.BillItemView;
import com.joe.print.mvp.ui.view.BillTypeView;
import com.joe.print.mvp.ui.view.BillView;
import com.joe.print.mvp.ui.view.PrintFoodView;
import com.sunmi.peripheral.printer.InnerResultCallbcak;
import java.io.IOException;
......@@ -732,7 +736,8 @@ public abstract class PrinterRoot<T extends PrintContent> implements PrintSocket
}
protected View getTakeawayBillInfoView(Context mContext, List<PrintBillItem> data) {
return getVerticalRecyclerView(mContext, new BillItemAdapter(data));
// return getVerticalRecyclerView(mContext, new BillItemAdapter(data));
return new BillItemView(mContext, data);
}
protected void addTakeawayPayViews(Context mContext, ViewGroup parent, List<OrderDetails.DataBean.PayMultiple> payMultiples, double payAmount) {
......@@ -825,40 +830,63 @@ public abstract class PrinterRoot<T extends PrintContent> implements PrintSocket
}
/**
* 獲取食品列表
* 結賬單、印單。外送都用這個
* @param mContext
* @param foodList
* @param deviceBean
* @param foodList 食品信息
* @param deviceBean 打印設備
* @param type 0 食品清單,1 結賬單
* @param showPrice 是否顯示價格
* @return
*/
public View getDiningFoodList(Context mContext, List<PrintFoodItem> foodList, PrinterDeviceBean deviceBean, int type, boolean showPrice) {
// List<OrderDetail> newsFoodList = new ArrayList<>();
// for (OrderDetail orderDetail : foodList) {
// //如果食品設置了0元不打印並且食品等於0元,或者設置了不打印到單,就不打印
// if (!(orderDetail.getPrintToBill() == 0 && orderDetail.getPrice() == 0)
// || OrderDetail.isPrint((int) orderDetail.getPrintTo(), type)) {
// newsFoodList.add(orderDetail);
// }
// }
return getVerticalRecyclerView(mContext, new FoodAdapter(foodList, deviceBean, showPrice));
//// List<OrderDetail> newsFoodList = new ArrayList<>();
//// for (OrderDetail orderDetail : foodList) {
//// //如果食品設置了0元不打印並且食品等於0元,或者設置了不打印到單,就不打印
//// if (!(orderDetail.getPrintToBill() == 0 && orderDetail.getPrice() == 0)
//// || OrderDetail.isPrint((int) orderDetail.getPrintTo(), type)) {
//// newsFoodList.add(orderDetail);
//// }
//// }
// return getVerticalRecyclerView(mContext, new FoodAdapter(foodList, deviceBean, showPrice));
return new PrintFoodView(mContext, foodList, deviceBean, showPrice);
}
/**
* 結賬單和印單
* @param mContext
* @param billingBeans
* @return
*/
public View getDiningBillInfo(Context mContext, List<BillingBean> billingBeans) {
return getVerticalRecyclerView(mContext, new BillAdapter(billingBeans));
// return getVerticalRecyclerView(mContext, new BillAdapter(billingBeans));
return new BillView(mContext, billingBeans);
}
/**
* 結賬單,支付方式
* @param mContext
* @param payBillMoneys 支付方式數據
* @return
*/
public View getDiningBillPayMethod(Context mContext, List<PrintBillItem> payBillMoneys) {
return getVerticalRecyclerView(mContext, new BillTypeAdapter(payBillMoneys));
// return getVerticalRecyclerView(mContext, new BillTypeAdapter(payBillMoneys));
return new BillTypeView(mContext, payBillMoneys);
}
/**
* 不用recyclerview,recyclerview可能會導致食品顯示不出來
*
* @param mContext
* @param adapter
* @return
*/
@Deprecated
public View getVerticalRecyclerView(Context mContext, RecyclerView.Adapter adapter) {
RecyclerView recyclerView = new RecyclerView(mContext);
recyclerView.setLayoutManager(new LinearLayoutManager(mContext));
recyclerView.setAdapter(adapter);
return recyclerView;
}
public View getAmountText(Context mContext, String text) {
......
......@@ -121,10 +121,6 @@ public class FoodAdapter extends BaseQuickAdapter<PrintFoodItem, BaseViewHolder>
tvNum.setTypeface(null, Typeface.NORMAL);
tvPrice.setTypeface(null, Typeface.NORMAL);
}
// tvFoodName.setTypeface(null, Typeface.BOLD_ITALIC);
// tvFoodName.setTypeface(null, Typeface.BOLD);
// tvFoodName.setTypeface(null, Typeface.ITALIC);
// tvFoodName.setTypeface(null, Typeface.NORMAL);
tvNum.setText("X" + item.getNum());
tvPrice.setText("$" + item.getPrice());
}
......
package com.joe.print.mvp.ui.view;
import android.content.Context;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.gingersoft.gsa.cloud.print.bean.base.PrintBillItem;
import com.gingersoft.gsa.cloud.print.bean.base.PrintFoodItem;
import com.joe.print.R;
import java.util.List;
/**
* @author 宇航.
* User: admin
* Date: 2021/1/30
* Time: 11:00
* Use:
*/
public class BillItemView extends LinearLayout {
private List<PrintBillItem> data;
public BillItemView(Context context, List<PrintBillItem> data) {
super(context);
this.data = data;
}
private void init() {
for (PrintBillItem item : data) {
View view = View.inflate(getContext(), R.layout.print_bill_adapter_item_bill, null);
TextView billNam = view.findViewById(R.id.print_bill_name);
TextView billValue = view.findViewById(R.id.print_bill_value);
billNam.setText(item.getBillName());
billValue.setText(item.getBillAmount());
addView(view);
}
}
}
package com.joe.print.mvp.ui.view;
import android.content.Context;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.gingersoft.gsa.cloud.print.bean.base.PrintBillItem;
import com.joe.print.R;
import java.util.List;
/**
* @author 宇航.
* User: admin
* Date: 2021/1/30
* Time: 11:16
* Use:結賬單,支付方式的view
*/
public class BillTypeView extends LinearLayout {
private List<PrintBillItem> data;
public BillTypeView(Context context, List<PrintBillItem> data) {
super(context);
this.data = data;
init();
}
private void init() {
for (PrintBillItem item : data) {
View view = View.inflate(getContext(), R.layout.base_print_item_bill_type, null);
TextView tvBillTotalText = view.findViewById(R.id.tv_total_amount_text);
TextView tvBillTotal = view.findViewById(R.id.tv_total_amount);
tvBillTotalText.setText(item.getBillName());
tvBillTotal.setText("$" + item.getBillAmount());
addView(view);
}
}
}
package com.joe.print.mvp.ui.view;
import android.content.Context;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.gingersoft.gsa.cloud.print.bean.base.PrintBillItem;
import com.joe.print.R;
import com.joe.print.mvp.model.bean.BillingBean;
import java.util.List;
/**
* @author 宇航.
* User: admin
* Date: 2021/1/30
* Time: 11:12
* Use:結賬單和印單的賬單信息
*/
public class BillView extends LinearLayout {
private List<BillingBean> data;
public BillView(Context context, List<BillingBean> data) {
super(context);
this.data = data;
init();
}
private void init() {
for (BillingBean item : data) {
View view = View.inflate(getContext(), R.layout.base_print_bill_adapter_item_bill, null);
TextView tvBillTotalText = view.findViewById(R.id.tv_bill_total_text);
TextView tvBillTotal = view.findViewById(R.id.tv_bill_total);
tvBillTotalText.setText(item.getOptionName());
if (item.getTotalAmount() < 0) {
tvBillTotal.setText("-$" + Math.abs(item.getTotalAmount()));
} else if (item.getTotalAmount() > 0) {
tvBillTotal.setText("$" + item.getTotalAmount());
}
addView(view);
}
}
}
\ No newline at end of file
package com.joe.print.mvp.ui.view;
import android.content.Context;
import android.graphics.Typeface;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean;
import com.gingersoft.gsa.cloud.print.bean.base.PrintFoodItem;
import com.joe.print.R;
import java.util.List;
/**
* @author 宇航.
* User: admin
* Date: 2021/1/30
* Time: 10:40
* Use:
*/
public class PrintFoodView extends LinearLayout {
private int foodFontSize = 24;
private int modifierFontSize = 24;
private int foodIsBold = 2;
private int modifierIsBold = 2;
private int foodIsItalic = 2;
private int modifierIsItalic = 2;
private int numberIsFlip = 2;//熱敏打印沒有顏色,翻轉用不了
private boolean showPrice = true;
private List<PrintFoodItem> data;
public PrintFoodView(Context context, List<PrintFoodItem> data, PrinterDeviceBean deviceBean, boolean showPrice) {
super(context);
this.showPrice = showPrice;
this.data = data;
init(deviceBean);
}
public void init(PrinterDeviceBean deviceBean) {
try {
this.foodFontSize = Integer.parseInt(deviceBean.getFoodFont()) * 2;//36
this.modifierFontSize = Integer.parseInt(deviceBean.getModifierFont()) * 2;
} catch (NumberFormatException e) {
e.printStackTrace();
}
this.foodIsBold = deviceBean.getFoodIsBold();
this.modifierIsBold = deviceBean.getModifierIsBold();
this.foodIsItalic = deviceBean.getFoodIsItalic();
this.modifierIsItalic = deviceBean.getModifierIsItalic();
this.numberIsFlip = deviceBean.getNumberIsFlip();
initView();
}
private void initView() {
for (PrintFoodItem item : data) {
View view = View.inflate(getContext(), R.layout.print_item_food, null);
TextView tvFoodName = view.findViewById(R.id.tv_food_name);
TextView tvNum = view.findViewById(R.id.tv_food_quantity);
TextView tvPrice = view.findViewById(R.id.tv_food_price);
if (showPrice) {
tvPrice.setVisibility(View.VISIBLE);
} else {
tvPrice.setVisibility(View.GONE);
}
boolean isBold, isItalic;
if (item.getItemType() == 2) {
//細項,縮進
tvFoodName.setText("\u3000" + item.getName());
tvFoodName.setTextSize(modifierFontSize);
tvNum.setTextSize(modifierFontSize);
tvPrice.setTextSize(modifierFontSize);
isBold = modifierIsBold == 1;
isItalic = modifierIsItalic == 1;
} else if (item.getItemType() == 3) {
//細項,縮進
tvFoodName.setText("\u3000\u3000" + item.getName());
tvFoodName.setTextSize(modifierFontSize);
tvNum.setTextSize(modifierFontSize);
tvPrice.setTextSize(modifierFontSize);
isBold = modifierIsBold == 1;
isItalic = modifierIsItalic == 1;
} else {
tvFoodName.setText(item.getName());
tvFoodName.setTextSize(foodFontSize);
tvNum.setTextSize(foodFontSize);
tvPrice.setTextSize(foodFontSize);
isBold = foodIsBold == 1;
isItalic = foodIsItalic == 1;
}
if (isBold && isItalic) {
tvFoodName.setTypeface(null, Typeface.BOLD_ITALIC);
tvNum.setTypeface(null, Typeface.BOLD_ITALIC);
tvPrice.setTypeface(null, Typeface.BOLD_ITALIC);
} else if (isBold) {
tvFoodName.setTypeface(null, Typeface.BOLD);
tvNum.setTypeface(null, Typeface.BOLD);
tvPrice.setTypeface(null, Typeface.BOLD);
} else if (isItalic) {
tvFoodName.setTypeface(null, Typeface.ITALIC);
tvNum.setTypeface(null, Typeface.ITALIC);
tvPrice.setTypeface(null, Typeface.ITALIC);
} else {
tvFoodName.setTypeface(null, Typeface.NORMAL);
tvNum.setTypeface(null, Typeface.NORMAL);
tvPrice.setTypeface(null, Typeface.NORMAL);
}
tvNum.setText("X" + item.getNum());
tvPrice.setText("$" + item.getPrice());
addView(view);
}
}
}
package com.gingersoft.supply_chain.mvp.bean;
import lombok.Data;
/**
* @author 宇航.
* User: admin
* Date: 2021/1/25
* Time: 11:54
* Use: 庫存消耗原因實體
*/
@Data
public class ConsumeReasonBean {
private int id;
private String description;
}
package com.gingersoft.supply_chain.mvp.bean;
import lombok.Data;
/**
* @author 宇航.
* User: admin
* Date: 2021/1/26
* Time: 11:23
* Use:庫存消耗流水
*/
@Data
public class ConsumeWareHousingBean {
private String name;
private String unitName;
private String foodCategoryName;
private String dates;
private String description;
private int quantity;
}
......@@ -41,7 +41,6 @@ public class FoodCategoryResultBean {
* createTime : 1605944097385
* updateTime : 1605944097044
*/
private int id;
private int uid;
private int brandId;
......
package com.gingersoft.supply_chain.mvp.bean;
import java.io.Serializable;
import java.util.List;
import lombok.Data;
......@@ -12,7 +13,7 @@ import lombok.Data;
* Use: 下單頁面的分類
*/
@Data
public class OrderCategoryBean {
public class OrderCategoryBean implements Serializable {
private boolean success;
private long sysTime;
......@@ -25,5 +26,13 @@ public class OrderCategoryBean {
private String name;
private int parentId;
private List<FoodCategoryTrees> foodCategoryTrees;
public FoodCategoryTrees() {
}
public FoodCategoryTrees(int id) {
this.id = id;
}
}
}
......@@ -2,6 +2,11 @@ package com.gingersoft.supply_chain.mvp.bean;
import com.gingersoft.supply_chain.mvp.content.Constant;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.List;
......@@ -18,7 +23,7 @@ import lombok.Data;
public class PurchaseFoodBean implements Serializable {
private static final long serialVersionUID = 7084280906070243339L;
public static final String CATEGORY_DIVIDER = "-";
private int id;
private Integer id;
private String supplierName;
private String images;
private String foodNo;
......@@ -59,12 +64,12 @@ public class PurchaseFoodBean implements Serializable {
/**
* 分類id
*/
private int foodCategoryId;
private Integer foodCategoryId;
/**
* 所屬供應商id
*/
private int supplierId;
private Integer supplierId;
/**
* 是否選中
*/
......@@ -72,7 +77,6 @@ public class PurchaseFoodBean implements Serializable {
/**
* 是否刪除
* {@link Constant.DELETE,Constant.NORMAL}
*
*/
private int deletes;
private int restaurantId;
......@@ -83,7 +87,7 @@ public class PurchaseFoodBean implements Serializable {
* 預警的信息,獲取詳情接口返回的不是對象,傳遞給後台時需要轉為對象
* 所以需要在這裡建這幾個字段,用於接收
*/
private int inventoryWarningId;
private Integer inventoryWarningId;
private boolean reviews;
private int minimumInventory;
private int shelfLife;
......@@ -93,8 +97,8 @@ public class PurchaseFoodBean implements Serializable {
* 庫存預警 模塊
*/
@Data
public static class InventoryAlarm {
private int id;
public static class InventoryAlarm implements Serializable {
private Integer id;
/**
* 是否審核 0否 1是
*/
......@@ -125,4 +129,26 @@ public class PurchaseFoodBean implements Serializable {
public void setChecked(boolean checked) {
isChecked = checked;
}
/**
* 复制一個類
* @param old
* @return
*/
public static Object copy(Object old) {
Object clazz = null;
try {
// 写入字节流
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(old);
// 读取字节流
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bais);
clazz = (Object) ois.readObject();
} catch (IOException | ClassNotFoundException e) {
e.printStackTrace();
}
return clazz;
}
}
......@@ -35,7 +35,22 @@ public class PurchaseOrderDetailsBean {
private double totalAmount;
private int shipping;
private double actualPayment;
/**
* 入库单号
*/
private String warehousingOrderNo;
/**
* 入庫備註
*/
private String warehousingRemarks;
/**
* 下採購單時的備註
*/
private String remarks;
/**
* 收貨時上傳的圖片,可以多張,用逗號隔開
*/
private String files;
/**
* 狀態:0全部 1待收貨 2部分收貨 3已完成 4拒收
......@@ -101,6 +116,9 @@ public class PurchaseOrderDetailsBean {
*/
private int foodQuantity;
private double foodPrice;
/**
* 看上面{@link WAIT_RECEIVED}
*/
private int status;
private int purchaseFoodId;
private String images;
......@@ -135,7 +153,7 @@ public class PurchaseOrderDetailsBean {
/**
* 已入庫數量
*/
private int warehousingQuantity;
private double warehousingQuantity;
// List<DeputyUnitBean> deputyUnitBeans;
/**
* 沒有入庫單號,暫時用訂單編號
......
......@@ -83,14 +83,15 @@ public class WareHouseListBean {
* foodAmount : 267
*/
private int id;
private String foodNo;
private String name;
private String cateName;
private String supplierName;
private String basicUnitName;
private String foodCategoryName;
// private String supplierName;
private String unitName;
private double foodPrice;
private int foodNum;
private double foodAmount;
private String images;
}
}
}
package com.gingersoft.supply_chain.mvp.bean;
import java.util.ArrayList;
import java.util.List;
import lombok.Data;
......@@ -13,32 +14,67 @@ import lombok.Data;
*/
@Data
public class WarehouseDetailsBean {
/**
* foodNum : 151
* purchaseWarehousingOrderDetailsContents : [{"name":"去微软","purchase":"採購入庫","orderNo":"JK11820389311","foodQuantity":17,"totalPrice":102,"createTime":2021,"warningDays":""},{"name":"去微软","purchase":"採購入庫","orderNo":"JK11820389311","foodQuantity":17,"totalPrice":102,"createTime":2021,"warningDays":""}]
* name : 去微软
* purchase : 採購入庫
* orderNo : JK11820389311
* foodQuantity : 17
* totalPrice : 102.0
* createTime : 2021
* warningDays :
*/
private String name;
private String purchase;
private String orderNo;
private double foodQuantity;
private double totalPrice;
// private String createTime;
private String supplierName;
/**
* 單位
*/
private String unitName;
private String foodCategoryName;
/**
* 入庫時間
*/
private String warehousingTime;
/**
* 採購時間
*/
private String images;
private int foodNum;
private List<PurchaseWarehousingOrderDetailsContentsBean> purchaseWarehousingOrderDetailsContents;
private String purchaseTime;
/**
* 還有多少天過期,如果是負的,則是已經過期了
*/
private int distanceExpiresTime;
/**
* 預警天數
*/
private int warningDays;
/**
* 消耗狀態,1從未被消耗,2消耗了一部分,3完全消耗
*/
private int consumeStatus;
public final static int WAREHOUSE_STATE_NEVER_CONSUMED = 1;
public final static int WAREHOUSE_STATE_PART_CONSUMED = 2;
public final static int WAREHOUSE_STATE_ALL_CONSUMED = 3;
public static WarehouseDetailsBean getWarehousingByConsume(ConsumeWareHousingBean consumeWareHousingBean) {
WarehouseDetailsBean warehousingBean = new WarehouseDetailsBean();
warehousingBean.name = consumeWareHousingBean.getName();
warehousingBean.unitName = consumeWareHousingBean.getUnitName();
warehousingBean.foodCategoryName = consumeWareHousingBean.getFoodCategoryName();
warehousingBean.purchase = consumeWareHousingBean.getDescription();
warehousingBean.foodQuantity = consumeWareHousingBean.getQuantity();
warehousingBean.purchaseTime = consumeWareHousingBean.getDates();
return warehousingBean;
}
@Data
public static class PurchaseWarehousingOrderDetailsContentsBean {
/**
* name : 去微软
* purchase : 採購入庫
* orderNo : JK11820389311
* foodQuantity : 17
* totalPrice : 102.0
* createTime : 2021
* warningDays :
*/
private String name;
private String purchase;
private String orderNo;
private int foodQuantity;
private double totalPrice;
private int createTime;
private String warningDays;
public static List<WarehouseDetailsBean> getWarehousingByConsumes(List<ConsumeWareHousingBean> consumeWareHousingBeans) {
List<WarehouseDetailsBean> warehousings = new ArrayList<>();
for (ConsumeWareHousingBean consumeWareHousingBean : consumeWareHousingBeans) {
warehousings.add(getWarehousingByConsume(consumeWareHousingBean));
}
return warehousings;
}
}
......@@ -6,6 +6,9 @@ import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import java.util.Map;
import lombok.NonNull;
import okhttp3.FormBody;
/**
* @author 宇航.
* User: admin
......@@ -16,8 +19,12 @@ import java.util.Map;
public class Constant {
public static final int PAGE_SIZE = 10;
public static final int PURCHASE_FOOD_MAX = 9999;
/**
* 庫存消耗——盤點消耗的id
*/
public static final int INVENTORY_CONSUME_ID = 5;
public static final int UPDATE = 2;
public static final int DELETE = 1;
public static final int NORMAL = 0;
/**
......@@ -37,7 +44,6 @@ public class Constant {
public static final String IMG_UPLOAD_LOADING = "圖片上傳中...";
public static final String IMG_UPLOAD_FAIL = "圖片上傳失敗,請稍後重試";
public static final String NULL_INFO_ERROR = "未獲取到數據,請退出後重試";
public static final String SAVE_LOADING = "保存中...";
public static final String SAVE_SUCCESS = "保存成功";
......@@ -49,14 +55,23 @@ public class Constant {
public static final String DELETE_LOADING = "刪除中...";
public static final String DELETE_SUCCESS = "刪除成功";
public static final String DELETE_FAIL = "刪除失敗,請稍後重試";
public static void addBrandId(Map<String, Object> map) {
public static void addBrandId(@NonNull Map<String, Object> map) {
map.put("brandId", RestaurantInfoManager.newInstance().getBrandId());
}
public static void addRestaurantId(Map<String, Object> map) {
public static void addRestaurantId(@NonNull Map<String, Object> map) {
map.put("restaurantId", RestaurantInfoManager.newInstance().getRestaurantId());
}
public static void addBrandId(@NonNull FormBody.Builder builder) {
builder.add("brandId", String.valueOf(RestaurantInfoManager.newInstance().getBrandId()));
}
public static void addRestaurantId(@NonNull FormBody.Builder builder) {
builder.add("restaurantId", String.valueOf(RestaurantInfoManager.newInstance().getRestaurantId()));
}
public static void addPageSize(Map<String, Object> map) {
map.put("pageSize", PAGE_SIZE);
}
......
package com.gingersoft.supply_chain.mvp.content;
import com.gingersoft.supply_chain.mvp.bean.OrderCategoryBean;
import com.gingersoft.supply_chain.mvp.bean.PurchaseFoodBean;
import com.xuexiang.rxutil2.rxjava.RxJavaUtils;
import com.xuexiang.rxutil2.rxjava.task.RxIOTask;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Observable;
/**
* @author 宇航.
......@@ -22,8 +25,6 @@ public class SupplyShoppingCart {
private static SupplyShoppingCart shoppingCart;
private int goodsNumber = 0;
public static SupplyShoppingCart getInstance() {
if (shoppingCart == null) {
shoppingCart = new SupplyShoppingCart();
......@@ -35,12 +36,120 @@ public class SupplyShoppingCart {
if (cartFoods == null) {
cartFoods = new ArrayList<>();
}
if (cartFoods.size() != goodsNumber) {
goodsNumber = cartFoods.size();
}
return cartFoods;
}
public void clear() {
if (cartFoods == null) {
return;
}
cartFoods.clear();
cartFoods = null;
}
public void removeFoodsByFoodId(int foodId) {
RxJavaUtils.doInIOThread(new RxIOTask<Object>(0) {
@Override
public Void doInIOThread(Object o) {
//刪除供應商成功後,需要從購物車數據中將這個供應商的食材都刪除掉
List<PurchaseFoodBean> cartFoods = SupplyShoppingCart.getInstance().getCartFoods();
Iterator<PurchaseFoodBean> iterator = cartFoods.iterator();
while (iterator.hasNext()) {
PurchaseFoodBean next = iterator.next();
if (next.getId() != null && next.getId() == foodId) {
iterator.remove();
break;
}
}
return null;
}
});
}
public void removeFoodsBySupplier(int supplierId) {
RxJavaUtils.doInIOThread(new RxIOTask<Object>(0) {
@Override
public Void doInIOThread(Object o) {
//刪除供應商成功後,需要從購物車數據中將這個供應商的食材都刪除掉
List<PurchaseFoodBean> cartFoods = SupplyShoppingCart.getInstance().getCartFoods();
Iterator<PurchaseFoodBean> iterator = cartFoods.iterator();
while (iterator.hasNext()) {
PurchaseFoodBean next = iterator.next();
if (next.getSupplierId() != null && next.getSupplierId() == supplierId) {
iterator.remove();
}
}
return null;
}
});
}
public void removeFoodsByCategoryId(int categoryId) {
RxJavaUtils.doInIOThread(new RxIOTask<Object>(0) {
@Override
public Void doInIOThread(Object o) {
//刪除供應商成功後,需要從購物車數據中將這個供應商的食材都刪除掉
List<PurchaseFoodBean> cartFoods = SupplyShoppingCart.getInstance().getCartFoods();
Iterator<PurchaseFoodBean> iterator = cartFoods.iterator();
while (iterator.hasNext()) {
PurchaseFoodBean next = iterator.next();
if (next.getFoodCategoryId() != null && next.getFoodCategoryId() == categoryId) {
iterator.remove();
}
}
return null;
}
});
}
public void removeFoodsByCategoryTress(OrderCategoryBean.FoodCategoryTrees foodCategoryTrees) {
RxJavaUtils.doInIOThread(new RxIOTask<Object>(0) {
@Override
public Void doInIOThread(Object o) {
//刪除分類成功後,需要從購物車數據中將這個分類的食材都刪除掉
List<PurchaseFoodBean> cartFoods = SupplyShoppingCart.getInstance().getCartFoods();
Iterator<PurchaseFoodBean> iterator = cartFoods.iterator();
while (iterator.hasNext()) {
PurchaseFoodBean next = iterator.next();
if (next.getFoodCategoryId() != null && next.getFoodCategoryId() == foodCategoryTrees.getId()) {
iterator.remove();
}
}
//分類中的刪除完了,需要刪除分類下子分類的食材
List<OrderCategoryBean.FoodCategoryTrees> childCategory = foodCategoryTrees.getFoodCategoryTrees();
if (childCategory != null) {
//遍歷二級分類
for (OrderCategoryBean.FoodCategoryTrees categoryTrees : childCategory) {
for (PurchaseFoodBean cartFood : cartFoods) {
if (cartFood.getFoodCategoryId() == categoryTrees.getId()) {
cartFoods.remove(cartFood);
break;
}
}
//對三級分類進行遍歷
List<OrderCategoryBean.FoodCategoryTrees> thirdCategory = categoryTrees.getFoodCategoryTrees();
removeFoodsByCategoryTress(thirdCategory);
}
}
return null;
}
});
}
public void removeFoodsByCategoryTress(List<OrderCategoryBean.FoodCategoryTrees> thirdCategory) {
if (thirdCategory != null) {
for (OrderCategoryBean.FoodCategoryTrees trees : thirdCategory) {
for (PurchaseFoodBean cartFood : cartFoods) {
if (cartFood.getFoodCategoryId() == trees.getId()) {
cartFoods.remove(cartFood);
}
}
}
}
}
public void setCartFoods(List<PurchaseFoodBean> cartFoods) {
SupplyShoppingCart.cartFoods = cartFoods;
}
......
......@@ -2,6 +2,8 @@ package com.gingersoft.supply_chain.mvp.contract;
import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.supply_chain.mvp.bean.FoodCategoryResultBean;
import com.gingersoft.supply_chain.mvp.bean.OrderCategoryBean;
import com.gingersoft.supply_chain.mvp.content.Constant;
import com.jess.arms.mvp.IModel;
import com.jess.arms.mvp.IView;
......@@ -27,19 +29,54 @@ import okhttp3.RequestBody;
public interface CategoryContract {
//对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
interface View extends IView {
void loadCategoryInfo(List<FoodCategoryResultBean.DataBean.FoodCategoryBean> list, int hierarchy);
/**
* 加載一級級分類,用於新增、修改、刪除分類後,刷新頁面
*
* @param data 分類
*/
void loadCategoryInfo(List<OrderCategoryBean.FoodCategoryTrees> data);
void refreshInfo(int hierarchy, int position);
/**
* 加載二級分類,用於新增、修改、刪除二級分類後,刷新頁面
*
* @param data 分類
*/
void loadSecondCategory(List<OrderCategoryBean.FoodCategoryTrees> data);
void loadCategoryFail();
/**
* 加載三級分類,用於新增、修改、刪除三級分類後,刷新頁面
*
* @param data 分類
*/
void loadThirdCategory(List<OrderCategoryBean.FoodCategoryTrees> data);
void loadCategoryError();
/**
* 新增分類
*
* @param categoryTrees 分類信息
* @param hierarchy 新增的是第幾級分類
*/
void addCategory(OrderCategoryBean.FoodCategoryTrees categoryTrees, int hierarchy);
/**
* 修改或刪除分類
*
* @param type 操作類型:刪除或修改 Constant.DELETE Constant.UPDATE
* @param hierarchy 第幾級分類
* @param position 分類下標
* @param categoryName 分類名稱
*/
void updateCategory(int type, int hierarchy, String categoryName, int position);
void onError();
}
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
interface Model extends IModel {
Observable<FoodCategoryResultBean> getFoodCategoryList(Map<String, Object> map);
Observable<OrderCategoryBean> getCategoryTrees(Map<String, Object> map);
Observable<BaseResult> createFoodCategory(RequestBody requestBody);
Observable<BaseResult> updateFoodCategory(RequestBody requestBody);
......
......@@ -2,6 +2,7 @@ package com.gingersoft.supply_chain.mvp.contract;
import com.gingersoft.gsa.cloud.ui.bean.SectionCheckItem;
import com.gingersoft.supply_chain.mvp.bean.FoodCategoryResultBean;
import com.gingersoft.supply_chain.mvp.bean.OrderCategoryBean;
import com.jess.arms.mvp.IModel;
import com.jess.arms.mvp.IView;
import com.qmuiteam.qmui.widget.section.QMUISection;
......@@ -27,12 +28,13 @@ import io.reactivex.Observable;
public interface CategorySelectContract {
//对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
interface View extends IView {
void loadFoodCategory(List<QMUISection<SectionCheckItem, SectionCheckItem>> sections);
void loadFoodCategory(List<OrderCategoryBean.FoodCategoryTrees> foodCategoryTrees);
}
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
interface Model extends IModel {
Observable<FoodCategoryResultBean> getFoodCategoryList(Map<String, Object> map);
Observable<OrderCategoryBean> getCategoryTrees(Map<String, Object> map);
}
}
......@@ -31,8 +31,16 @@ import okhttp3.RequestBody;
public interface FoodIngredientsContract {
//对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
interface View extends IView {
/**
* 加載左側供應商
* @param categoryBeans 供應商
*/
void loadLeftSupplierInfo(List<CategoryBean> categoryBeans);
/**
* 加載右側食品
* @param purchaseFoodListVOS 食品信息
*/
void loadRightFoodIngredients(List<PurchaseFoodBean> purchaseFoodListVOS);
/**
......@@ -49,8 +57,15 @@ public interface FoodIngredientsContract {
*/
void loadCategory(List<OrderCategoryBean.FoodCategoryTrees> foodCategoryTrees);
/**
* 加載失敗
*/
void loadFail();
/**
* 修改當前供應商名稱
* @param name 供應商名稱
*/
void setCurrentSupplierName(String name);
}
......
package com.gingersoft.supply_chain.mvp.contract;
import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.supply_chain.mvp.bean.ConsumeReasonBean;
import com.gingersoft.supply_chain.mvp.bean.WareHouseListBean;
import com.gingersoft.supply_chain.mvp.bean.WarehouseDetailsBean;
import com.jess.arms.mvp.IView;
......@@ -10,6 +11,7 @@ import java.util.List;
import java.util.Map;
import io.reactivex.Observable;
import okhttp3.RequestBody;
/**
......@@ -29,17 +31,50 @@ public interface WarehouseDetailsContract {
interface View extends IView {
/**
* 加載入庫信息和列表
*
* @param warehouseDetailsBean
*/
void loadWarehousing(WarehouseDetailsBean warehouseDetailsBean);
void loadAdapter(List<WarehouseDetailsBean> warehouseDetailsBean);
void loadAdapter(List<WarehouseDetailsBean.PurchaseWarehousingOrderDetailsContentsBean> purchaseWarehousingOrderDetailsContents);
/**
* 加載消耗原因
*
* @param consumeReasonBeans
*/
void loadConsumeReason(List<ConsumeReasonBean> consumeReasonBeans);
/**
* 獲取頁面數據
*/
void getPageInfo();
/**
* 修改庫存數量
*/
void setWarehousingNum(int num);
}
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
interface Model extends IModel {
Observable<BaseResult> getWarehousingOrderDetails(Map<String, Object> map);
Observable<BaseResult> getOutStockDetails(Map<String, Object> map);
Observable<BaseResult> getWarehouseInventoryReason();
/**
* 庫存消耗
*
* @param requestBody
* @return
*/
Observable<BaseResult> consumeWareHousing(RequestBody requestBody);
/**
* 獲取庫存數量
*/
Observable<BaseResult> getWarehousingNum(Map<String, Object> map);
}
}
package com.gingersoft.supply_chain.mvp.contract;
import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.jess.arms.mvp.IView;
import com.jess.arms.mvp.IModel;
import io.reactivex.Observable;
import okhttp3.RequestBody;
/**
* ================================================
......@@ -19,11 +23,17 @@ import com.jess.arms.mvp.IModel;
public interface WarehousingInventoryContract {
//对于经常使用的关于UI的方法可以定义到IView中,如显示隐藏进度条,和显示文字消息
interface View extends IView {
void updateSuccess();
}
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
interface Model extends IModel {
/**
* 庫存消耗
*
* @param requestBody
* @return
*/
Observable<BaseResult> consumeWareHousing(RequestBody requestBody);
}
}
......@@ -4,6 +4,7 @@ import android.app.Application;
import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.supply_chain.mvp.bean.FoodCategoryResultBean;
import com.gingersoft.supply_chain.mvp.bean.OrderCategoryBean;
import com.gingersoft.supply_chain.mvp.contract.CategoryContract;
import com.gingersoft.supply_chain.mvp.server.SupplierServer;
import com.google.gson.Gson;
......@@ -57,6 +58,11 @@ public class CategoryModel extends BaseModel implements CategoryContract.Model {
}
@Override
public Observable<OrderCategoryBean> getCategoryTrees(Map<String, Object> map) {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).getCategoryTrees(map);
}
@Override
public Observable<BaseResult> createFoodCategory(RequestBody requestBody) {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).addFoodCategory(requestBody);
}
......
......@@ -3,6 +3,7 @@ package com.gingersoft.supply_chain.mvp.model;
import android.app.Application;
import com.gingersoft.supply_chain.mvp.bean.FoodCategoryResultBean;
import com.gingersoft.supply_chain.mvp.bean.OrderCategoryBean;
import com.gingersoft.supply_chain.mvp.contract.CategorySelectContract;
import com.gingersoft.supply_chain.mvp.server.SupplierServer;
import com.google.gson.Gson;
......@@ -52,4 +53,9 @@ public class CategorySelectModel extends BaseModel implements CategorySelectCont
public Observable<FoodCategoryResultBean> getFoodCategoryList(Map<String, Object> map) {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).getFoodCategoryList(map);
}
@Override
public Observable<OrderCategoryBean> getCategoryTrees(Map<String, Object> map) {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).getCategoryTrees(map);
}
}
\ No newline at end of file
......@@ -17,6 +17,7 @@ import com.gingersoft.supply_chain.mvp.contract.WarehouseDetailsContract;
import java.util.Map;
import io.reactivex.Observable;
import okhttp3.RequestBody;
/**
......@@ -56,7 +57,24 @@ public class WarehouseDetailsModel extends BaseModel implements WarehouseDetails
}
@Override
public Observable<BaseResult> getOutStockDetails(Map<String, Object> map) {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).getOutStockDetails(map);
}
@Override
public Observable<BaseResult> getWarehouseInventoryReason() {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).getWarehouseInventoryReason();
}
@Override
public Observable<BaseResult> consumeWareHousing(RequestBody requestBody) {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).consumeWareHousing(requestBody);
}
@Override
public Observable<BaseResult> getWarehousingNum(Map<String, Object> map) {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).getWarehousingNum(map);
}
}
\ No newline at end of file
......@@ -2,6 +2,8 @@ package com.gingersoft.supply_chain.mvp.model;
import android.app.Application;
import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.supply_chain.mvp.server.SupplierServer;
import com.google.gson.Gson;
import com.jess.arms.integration.IRepositoryManager;
import com.jess.arms.mvp.BaseModel;
......@@ -12,6 +14,9 @@ import javax.inject.Inject;
import com.gingersoft.supply_chain.mvp.contract.WarehousingInventoryContract;
import io.reactivex.Observable;
import okhttp3.RequestBody;
/**
* ================================================
......@@ -43,4 +48,9 @@ public class WarehousingInventoryModel extends BaseModel implements WarehousingI
this.mGson = null;
this.mApplication = null;
}
@Override
public Observable<BaseResult> consumeWareHousing(RequestBody requestBody) {
return mRepositoryManager.obtainRetrofitService(SupplierServer.class).consumeWareHousing(requestBody);
}
}
\ No newline at end of file
......@@ -6,8 +6,12 @@ import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.common.core.restaurant.RestaurantInfoManager;
import com.gingersoft.gsa.cloud.common.utils.gson.GsonUtils;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.order.cart.ShoppingCart;
import com.gingersoft.supply_chain.mvp.bean.CategoryFoodTreeBean;
import com.gingersoft.supply_chain.mvp.bean.FoodCategoryResultBean;
import com.gingersoft.supply_chain.mvp.bean.OrderCategoryBean;
import com.gingersoft.supply_chain.mvp.content.Constant;
import com.gingersoft.supply_chain.mvp.content.SupplyShoppingCart;
import com.gingersoft.supply_chain.mvp.contract.CategoryContract;
import com.jess.arms.di.scope.FragmentScope;
import com.jess.arms.http.imageloader.ImageLoader;
......@@ -15,9 +19,7 @@ import com.jess.arms.integration.AppManager;
import com.jess.arms.mvp.BasePresenter;
import com.jess.arms.utils.RxLifecycleUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.inject.Inject;
......@@ -54,10 +56,6 @@ public class CategoryPresenter extends BasePresenter<CategoryContract.Model, Cat
ImageLoader mImageLoader;
@Inject
AppManager mAppManager;
/**
* Key為一級分類ID,對應的二級數據
*/
private Map<Integer, List<FoodCategoryResultBean.DataBean.FoodCategoryBean>> primaryCategory;
public final int primaryCategoryTag = 1;
public final int secondCategoryTag = 2;
......@@ -78,101 +76,40 @@ public class CategoryPresenter extends BasePresenter<CategoryContract.Model, Cat
}
/**
* 根據父分類id獲取子分類
*
* @param name
* @param parentId
* @param hierarchy
* 獲取分類的結構:所有分類和分類的子分類都有
*/
public void getFoodCategoryList(String name, int parentId, int hierarchy) {
Map<String, Object> map = new HashMap<>(6);
map.put("pageSize", 1000);
map.put("pageIndex", 0);
map.put("parentId", parentId);
map.put("restaurantId", RestaurantInfoManager.newInstance().getRestaurantId());
map.put("brandId", RestaurantInfoManager.newInstance().getBrandId());
if (!TextUtil.isEmptyOrNullOrUndefined(name)) {
map.put("name", name);
}
mModel.getFoodCategoryList(map)
public void getCategoryTrees() {
Map<String, Object> map = new HashMap<>(2);
Constant.addBrandId(map);
Constant.addRestaurantId(map);
mModel.getCategoryTrees(map)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(Constant.GET_INFO_LOADING))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> {
})
.doAfterTerminate(() -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<FoodCategoryResultBean>(mErrorHandler) {
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new ErrorHandleSubscriber<OrderCategoryBean>(mErrorHandler) {
@Override
public void onNext(@NonNull FoodCategoryResultBean info) {
if (info != null) {
if (info.isSuccess()) {
if (info.getData() != null) {
List<FoodCategoryResultBean.DataBean.FoodCategoryBean> categoryBeans = info.getData().getList();
if (categoryBeans == null) {
categoryBeans = new ArrayList<>();
}
if (hierarchy == primaryCategoryTag) {
//如果獲取的是一級分類。將一級分類的id保存到map的key中
if (primaryCategory == null) {
primaryCategory = new HashMap<>(5);
for (FoodCategoryResultBean.DataBean.FoodCategoryBean categoryBean : categoryBeans) {
primaryCategory.put(categoryBean.getId(), null);
}
} else {
//第一類,不是空,判斷裡面數據是否為空,不為空的就不覆蓋數據
for (FoodCategoryResultBean.DataBean.FoodCategoryBean categoryBean : categoryBeans) {
if (primaryCategory.get(categoryBean.getId()) != null
&& primaryCategory.get(categoryBean.getId()).size() > 0) {
} else {
primaryCategory.put(categoryBean.getId(), null);
}
}
}
} else {
//如果獲取到的是二級、三級分類
if (categoryBeans.size() > 0) {
categoryBeans.add(0, new FoodCategoryResultBean.DataBean.FoodCategoryBean());
}
primaryCategory.put(parentId, new ArrayList<>(categoryBeans));
}
mRootView.loadCategoryInfo(categoryBeans, hierarchy);
} else {
mRootView.hideLoading();
mRootView.showMessage("獲取" + hierarchy + "級分類失敗");
}
} else if (TextUtil.isNotEmptyOrNullOrUndefined(info.getErrMsg())) {
mRootView.showMessage(info.getErrMsg());
mRootView.hideLoading();
}
public void onNext(OrderCategoryBean orderCategoryBean) {
if (orderCategoryBean.isSuccess()) {
mRootView.loadCategoryInfo(orderCategoryBean.getData());
} else if (TextUtil.isNotEmptyOrNullOrUndefined(orderCategoryBean.getErrMsg())) {
mRootView.showMessage(orderCategoryBean.getErrMsg());
} else {
mRootView.hideLoading();
mRootView.showMessage(Constant.GET_INFO_ERROR);
}
}
@Override
public void onError(Throwable t) {
super.onError(t);
mRootView.showMessage("獲取" + hierarchy + "級分類失敗");
mRootView.hideLoading();
if (hierarchy == primaryCategoryTag) {
mRootView.loadCategoryError();
}
mRootView.onError();
}
});
}
public void getCategoryBeansById(int id, int hierarchy) {
List<FoodCategoryResultBean.DataBean.FoodCategoryBean> foodCategoryBeans = primaryCategory.get(id);
if (foodCategoryBeans == null) {
getFoodCategoryList("", id, hierarchy);
} else {
mRootView.loadCategoryInfo(foodCategoryBeans, hierarchy);
}
}
/**
* 新增分類
......@@ -186,7 +123,7 @@ public class CategoryPresenter extends BasePresenter<CategoryContract.Model, Cat
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), GsonUtils.GsonString(foodCategoryBean));
mModel.createFoodCategory(requestBody)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading("保存中..."))
.doOnSubscribe(disposable -> mRootView.showLoading(Constant.SAVE_LOADING))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
......@@ -197,17 +134,32 @@ public class CategoryPresenter extends BasePresenter<CategoryContract.Model, Cat
public void onNext(@NonNull BaseResult info) {
if (info != null) {
if (info.isSuccess()) {
getFoodCategoryList("", parentId, hierarchy);
//新增分類成功,本地刷新
FoodCategoryResultBean.DataBean.FoodCategoryBean categoryBean = GsonUtils.GsonToBean(info.getData(), FoodCategoryResultBean.DataBean.FoodCategoryBean.class);
if (categoryBean != null) {
OrderCategoryBean.FoodCategoryTrees categoryTrees = new OrderCategoryBean.FoodCategoryTrees();
categoryTrees.setId(categoryBean.getId());
categoryTrees.setName(categoryBean.getName());
categoryTrees.setParentId(categoryBean.getParentId());
mRootView.addCategory(categoryTrees, hierarchy);
}
} else if (TextUtil.isNotEmptyOrNullOrUndefined(info.getErrMsg())) {
mRootView.showMessage(info.getErrMsg());
} else {
mRootView.showMessage("保存失敗");
mRootView.showMessage(Constant.SAVE_FAIL);
}
}
}
});
}
/**
* 將信息轉為後台需要的數據對象
*
* @param parentId 分類的父類id
* @param categoryName 分類名稱
* @param id 分類id
*/
public FoodCategoryResultBean.DataBean.FoodCategoryBean toFoodCategoryBean(int parentId, String categoryName, int id) {
FoodCategoryResultBean.DataBean.FoodCategoryBean foodCategoryBean = new FoodCategoryResultBean.DataBean.FoodCategoryBean();
foodCategoryBean.setBrandId(RestaurantInfoManager.newInstance().getBrandId());
......@@ -218,11 +170,18 @@ public class CategoryPresenter extends BasePresenter<CategoryContract.Model, Cat
return foodCategoryBean;
}
public void deleteFoodCategory(int id, int hierarchy, int position) {
/**
* 刪除分類
*
* @param foodCategoryTrees 分類信息
* @param hierarchy 第幾級分類,用於刪除後刷新
* @param position 刪除的分類下標
*/
public void deleteFoodCategory(OrderCategoryBean.FoodCategoryTrees foodCategoryTrees, int hierarchy, int position) {
RequestBody requestBody = new FormBody.Builder()
.add("id", id + "")
.add("id", foodCategoryTrees.getId() + "")
.add("brandId", RestaurantInfoManager.newInstance().getBrandId() + "")
.add("restaurantId", RestaurantInfoManager.newInstance().getRestaurantId() +"")
.add("restaurantId", RestaurantInfoManager.newInstance().getRestaurantId() + "")
.build();
mModel.deleteFoodCategory(requestBody)
.subscribeOn(Schedulers.io())
......@@ -235,7 +194,9 @@ public class CategoryPresenter extends BasePresenter<CategoryContract.Model, Cat
@Override
public void onNext(@NonNull BaseResult info) {
if (info.isSuccess()) {
mRootView.refreshInfo(hierarchy, position);
//需要刪除購物車中被刪除的分類下的食材
SupplyShoppingCart.getInstance().removeFoodsByCategoryTress(foodCategoryTrees);
mRootView.updateCategory(Constant.DELETE, hierarchy, "", position);
} else if (TextUtil.isNotEmptyOrNullOrUndefined(info.getErrMsg())) {
mRootView.showMessage(info.getErrMsg());
} else {
......@@ -247,7 +208,9 @@ public class CategoryPresenter extends BasePresenter<CategoryContract.Model, Cat
/**
* @param foodCategoryBean
* 修改分類
*
* @param foodCategoryBean 分類信息
* @param hierarchy 修改的是第幾級分類
* @param position 分類的位置
*/
......@@ -255,7 +218,7 @@ public class CategoryPresenter extends BasePresenter<CategoryContract.Model, Cat
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), GsonUtils.GsonString(foodCategoryBean));
mModel.updateFoodCategory(requestBody)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(foodCategoryBean.getDeletes() == Constant.DELETE ? Constant.DELETE_LOADING : Constant.UPDATE_LOADING))
.doOnSubscribe(disposable -> mRootView.showLoading(Constant.UPDATE_LOADING))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
......@@ -264,11 +227,11 @@ public class CategoryPresenter extends BasePresenter<CategoryContract.Model, Cat
@Override
public void onNext(@NonNull BaseResult info) {
if (info.isSuccess()) {
mRootView.refreshInfo(hierarchy, position);
mRootView.updateCategory(Constant.UPDATE, hierarchy, foodCategoryBean.getName(), position);
} else if (TextUtil.isNotEmptyOrNullOrUndefined(info.getErrMsg())) {
mRootView.showMessage(info.getErrMsg());
} else {
mRootView.showMessage(foodCategoryBean.getDeletes() == Constant.DELETE ? Constant.DELETE_FAIL : Constant.UPDATE_FAIL);
mRootView.showMessage(Constant.UPDATE_FAIL);
}
}
});
......
......@@ -2,19 +2,17 @@ package com.gingersoft.supply_chain.mvp.presenter;
import android.app.Application;
import com.gingersoft.gsa.cloud.common.core.restaurant.RestaurantInfoManager;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.ui.bean.SectionCheckItem;
import com.gingersoft.supply_chain.mvp.bean.FoodCategoryResultBean;
import com.gingersoft.supply_chain.mvp.bean.OrderCategoryBean;
import com.gingersoft.supply_chain.mvp.content.Constant;
import com.gingersoft.supply_chain.mvp.contract.CategorySelectContract;
import com.jess.arms.di.scope.FragmentScope;
import com.jess.arms.http.imageloader.ImageLoader;
import com.jess.arms.integration.AppManager;
import com.jess.arms.mvp.BasePresenter;
import com.jess.arms.utils.RxLifecycleUtils;
import com.qmuiteam.qmui.widget.section.QMUISection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -22,13 +20,10 @@ import java.util.Map;
import javax.inject.Inject;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull;
import io.reactivex.schedulers.Schedulers;
import me.jessyan.rxerrorhandler.core.RxErrorHandler;
import me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber;
import static com.gingersoft.gsa.cloud.ui.adapter.BaseRadioSectionAdapter.SEPARATOR;
/**
* ================================================
......@@ -70,113 +65,143 @@ public class CategorySelectPresenter extends BasePresenter<CategorySelectContrac
this.mApplication = null;
}
public void getFoodCategoryList(String name, int parentId, String position) {
Map<String, Object> map = new HashMap<>(6);
map.put("pageSize", 1000);
map.put("pageIndex", 0);
map.put("parentId", parentId);
map.put("restaurantId", RestaurantInfoManager.newInstance().getRestaurantId());
map.put("brandId", RestaurantInfoManager.newInstance().getBrandId());
if (!TextUtil.isEmptyOrNullOrUndefined(name)) {
map.put("name", name);
}
mModel.getFoodCategoryList(map)
/**
* 獲取分類的結構:所有分類和分類的子分類都有
*/
public void getCategoryTrees() {
Map<String, Object> map = new HashMap<>(2);
Constant.addBrandId(map);
Constant.addRestaurantId(map);
mModel.getCategoryTrees(map)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading("獲取中..."))
.doOnSubscribe(disposable -> mRootView.showLoading(Constant.GET_INFO_LOADING))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<FoodCategoryResultBean>(mErrorHandler) {
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new ErrorHandleSubscriber<OrderCategoryBean>(mErrorHandler) {
@Override
public void onNext(@NonNull FoodCategoryResultBean info) {
if (info != null) {
if (info.isSuccess()) {
if (list == null) {
list = new ArrayList<>();
}
if (info.getData().getCount() > 0) {
if (list.size() > 0) {
//list數量大於0時,最外一層已經獲取,這次獲取的是裡面某一層,然後通過遞歸返回的下標位置精確插入數據
String[] split = position.split(SEPARATOR);
getTheDeepest(list, split, 0).setList(info.getData().getList());
} else {
list.addAll(info.getData().getList());
}
List<QMUISection<SectionCheckItem, SectionCheckItem>> sections = new ArrayList<>();
for (int i = 0; i < list.size(); i++) {
if (list.get(i).getParentId() == 0) {
SectionCheckItem sectionCheckItem = new SectionCheckItem(list.get(i).getId(), list.get(i).getName(), i);
sections.add(new QMUISection<>(sectionCheckItem, genList(list.get(i).getList(), i), false));
}
}
mRootView.loadFoodCategory(sections);
}
} else if (TextUtil.isNotEmptyOrNullOrUndefined(info.getErrMsg())) {
mRootView.showMessage(info.getErrMsg());
}
}
}
public FoodCategoryResultBean.DataBean.FoodCategoryBean getTheDeepest(List<FoodCategoryResultBean.DataBean.FoodCategoryBean> list, String[] split, int i) {
if (i + 1 < split.length) {
return getTheDeepest(list.get(Integer.parseInt(split[i])).getList(), split, i + 1);
} else {
return list.get(Integer.parseInt(split[i]));
}
}
public List<SectionCheckItem> genList(List<FoodCategoryResultBean.DataBean.FoodCategoryBean> list, int parentIndex) {
if (list != null && list.size() > 0) {
List<SectionCheckItem> sectionCheckItems = new ArrayList<>();
for (int i = 0; i < list.size(); i++) {
SectionCheckItem sectionCheckItem = new SectionCheckItem(list.get(i).getId(), list.get(i).getName(), parentIndex);
if (list.get(i).getList() != null && list.get(i).getList().size() > 0) {
sectionCheckItem.setSectionCheckItems(genList(list.get(i).getList(), i));
}
sectionCheckItems.add(sectionCheckItem);
}
return sectionCheckItems;
public void onNext(OrderCategoryBean orderCategoryBean) {
if (orderCategoryBean.isSuccess()) {
mRootView.loadFoodCategory(orderCategoryBean.getData());
} else if (TextUtil.isNotEmptyOrNullOrUndefined(orderCategoryBean.getErrMsg())) {
mRootView.showMessage(orderCategoryBean.getErrMsg());
} else {
return null;
mRootView.showMessage(Constant.GET_INFO_ERROR);
}
}
public void addList(FoodCategoryResultBean.DataBean.FoodCategoryBean categoryBean, int parentId, List<FoodCategoryResultBean.DataBean.FoodCategoryBean> childList) {
if (categoryBean.getId() == parentId) {
if (categoryBean.getList() == null) {
categoryBean.setList(childList);
}
//如果有數據了,就是已經請求過了,不需要再次請求
} else {
List<FoodCategoryResultBean.DataBean.FoodCategoryBean> list = categoryBean.getList();
if (list != null && list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
if (list.get(i).getId() == parentId) {
if (list.get(i).getList() == null) {
list.get(i).setList(childList);
} else {
list.get(i).getList().addAll(childList);
}
return;
} else {
addList(list.get(i), parentId, childList);
}
}
}
}
}
@Override
public void onError(Throwable t) {
super.onError(t);
}
});
}
// public void getFoodCategoryList(String name, int parentId, String position) {
// Map<String, Object> map = new HashMap<>(6);
// map.put("pageSize", 1000);
// map.put("pageIndex", 0);
// map.put("parentId", parentId);
// map.put("restaurantId", RestaurantInfoManager.newInstance().getRestaurantId());
// map.put("brandId", RestaurantInfoManager.newInstance().getBrandId());
// if (!TextUtil.isEmptyOrNullOrUndefined(name)) {
// map.put("name", name);
// }
// mModel.getFoodCategoryList(map)
// .subscribeOn(Schedulers.io())
// .doOnSubscribe(disposable -> mRootView.showLoading("獲取中..."))
// .subscribeOn(AndroidSchedulers.mainThread())
// .observeOn(AndroidSchedulers.mainThread())
// .doAfterTerminate(() -> mRootView.hideLoading())
// .compose(RxLifecycleUtils.bindToLifecycle(mRootView))
// .subscribe(new ErrorHandleSubscriber<FoodCategoryResultBean>(mErrorHandler) {
//
// @Override
// public void onNext(@NonNull FoodCategoryResultBean info) {
// if (info != null) {
// if (info.isSuccess()) {
// if (list == null) {
// list = new ArrayList<>();
// }
// if (info.getData().getCount() > 0) {
// if (list.size() > 0) {
// //list數量大於0時,最外一層已經獲取,這次獲取的是裡面某一層,然後通過遞歸返回的下標位置精確插入數據
// String[] split = position.split(SEPARATOR);
// getTheDeepest(list, split, 0).setList(info.getData().getList());
// } else {
// list.addAll(info.getData().getList());
// }
//
// List<QMUISection<SectionCheckItem, SectionCheckItem>> sections = new ArrayList<>();
// for (int i = 0; i < list.size(); i++) {
// if (list.get(i).getParentId() == 0) {
// SectionCheckItem sectionCheckItem = new SectionCheckItem(list.get(i).getId(), list.get(i).getName(), i);
// sections.add(new QMUISection<>(sectionCheckItem, genList(list.get(i).getList(), i), false));
// }
// }
// mRootView.loadFoodCategory(sections);
// }
// } else if (TextUtil.isNotEmptyOrNullOrUndefined(info.getErrMsg())) {
// mRootView.showMessage(info.getErrMsg());
// }
// }
// }
//
// public FoodCategoryResultBean.DataBean.FoodCategoryBean getTheDeepest(List<FoodCategoryResultBean.DataBean.FoodCategoryBean> list, String[] split, int i) {
// if (i + 1 < split.length) {
// return getTheDeepest(list.get(Integer.parseInt(split[i])).getList(), split, i + 1);
// } else {
// return list.get(Integer.parseInt(split[i]));
// }
// }
//
//
// public List<SectionCheckItem> genList(List<FoodCategoryResultBean.DataBean.FoodCategoryBean> list, int parentIndex) {
// if (list != null && list.size() > 0) {
// List<SectionCheckItem> sectionCheckItems = new ArrayList<>();
// for (int i = 0; i < list.size(); i++) {
// SectionCheckItem sectionCheckItem = new SectionCheckItem(list.get(i).getId(), list.get(i).getName(), parentIndex);
// if (list.get(i).getList() != null && list.get(i).getList().size() > 0) {
// sectionCheckItem.setSectionCheckItems(genList(list.get(i).getList(), i));
// }
// sectionCheckItems.add(sectionCheckItem);
// }
// return sectionCheckItems;
// } else {
// return null;
// }
// }
//
//
// public void addList(FoodCategoryResultBean.DataBean.FoodCategoryBean categoryBean, int parentId, List<FoodCategoryResultBean.DataBean.FoodCategoryBean> childList) {
// if (categoryBean.getId() == parentId) {
// if (categoryBean.getList() == null) {
// categoryBean.setList(childList);
// }
// //如果有數據了,就是已經請求過了,不需要再次請求
// } else {
// List<FoodCategoryResultBean.DataBean.FoodCategoryBean> list = categoryBean.getList();
// if (list != null && list.size() > 0) {
// for (int i = 0; i < list.size(); i++) {
// if (list.get(i).getId() == parentId) {
// if (list.get(i).getList() == null) {
// list.get(i).setList(childList);
// } else {
// list.get(i).getList().addAll(childList);
// }
// return;
// } else {
// addList(list.get(i), parentId, childList);
// }
// }
// }
// }
// }
//
// @Override
// public void onError(Throwable t) {
// super.onError(t);
// }
// });
//
// }
}
......@@ -127,17 +127,10 @@ public class FoodIngredientsPresenter extends BasePresenter<FoodIngredientsContr
if (supplierId != -1) {
map.put("supplierId", supplierId);
}
Log.e("eee", "loadFoodIngredientsData" + android.os.Process.myTid());
mModel.getFoodIngredientsData(map)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> {
Log.e("eee", "doOnSubscribe" + android.os.Process.myTid());
mRootView.showLoading("獲取中...");
})
.doAfterTerminate(() -> {
Log.e("eee", "doAfterTerminate" + android.os.Process.myTid());
mRootView.hideLoading();
})
.doOnSubscribe(disposable -> mRootView.showLoading(Constant.GET_INFO_LOADING))
.doAfterTerminate(() -> mRootView.hideLoading())
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(AndroidSchedulers.mainThread())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
......@@ -145,7 +138,6 @@ public class FoodIngredientsPresenter extends BasePresenter<FoodIngredientsContr
.subscribe(new ErrorHandleSubscriber<FoodListInfoBean>(mErrorHandler) {
@Override
public void onNext(@NonNull FoodListInfoBean info) {
Log.e("eee", "onNext" + android.os.Process.myTid());
if (info.isSuccess() && info.getData() != null) {
categoryBeans = new ArrayList<>();
if (supplierFoodsMap == null) {
......@@ -173,8 +165,6 @@ public class FoodIngredientsPresenter extends BasePresenter<FoodIngredientsContr
RxJavaUtils.doInUIThread(new RxUITask<Object>(0) {
@Override
public void doInUIThread(Object o) {
Log.e("eee", "doInUIThread" + android.os.Process.myTid());
mRootView.loadLeftSupplierInfo(categoryBeans);
if (info.getData().size() > 0) {
mRootView.setCurrentSupplierName(info.getData().get(0).getSupplierName());
......@@ -300,6 +290,16 @@ public class FoodIngredientsPresenter extends BasePresenter<FoodIngredientsContr
return supplierId;
}
/**
* 清除指定供應商的緩存
* @return
*/
public void removeSupplierCacheById(int supplierId) {
if (supplierFoodsMap != null) {
List<PurchaseFoodBean> purchaseFoodBeans = supplierFoodsMap.get(supplierId);
supplierFoodsMap.put(supplierId, null);
}
}
/**
* 獲取選中的食品,存入購物車
......@@ -325,18 +325,29 @@ public class FoodIngredientsPresenter extends BasePresenter<FoodIngredientsContr
*
* @param position
*/
public void deleteFood(int foodId, int position) {
public void deleteFood(int foodId, int supplierId, int categoryId, int position) {
mModel.deleteFood(foodId)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading("刪除中..."))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
.doAfterNext(dis -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<BaseResult>(mErrorHandler) {
@Override
public void onNext(BaseResult baseResult) {
if (baseResult.isSuccess()) {
//需要在供應商和分類的緩存中這個食品移除
if (supplierFoodsMap != null) {
List<PurchaseFoodBean> purchaseFoodBeans = supplierFoodsMap.get(supplierId);
if (purchaseFoodBeans != null && position < purchaseFoodBeans.size()) {
purchaseFoodBeans.remove(position);
}
}
//移除在分類中的緩存
removeCacheByCategoryId(categoryId);
//移除在購物車中的緩存
SupplyShoppingCart.getInstance().removeFoodsByFoodId(foodId);
mRootView.onDeleteFoodSuccess(position);
} else if (TextUtil.isNotEmptyOrNullOrUndefined(baseResult.getErrMsg())) {
mRootView.showMessage(baseResult.getErrMsg());
......@@ -360,7 +371,7 @@ public class FoodIngredientsPresenter extends BasePresenter<FoodIngredientsContr
Constant.addRestaurantId(map);
mModel.getCategoryTrees(map)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading("獲取中..."))
.doOnSubscribe(disposable -> mRootView.showLoading(Constant.GET_INFO_LOADING))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
......@@ -389,7 +400,7 @@ public class FoodIngredientsPresenter extends BasePresenter<FoodIngredientsContr
} else if (TextUtil.isNotEmptyOrNullOrUndefined(orderCategoryBean.getErrMsg())) {
mRootView.showMessage(orderCategoryBean.getErrMsg());
} else {
mRootView.showMessage("獲取失敗,請稍候重試");
mRootView.showMessage(Constant.GET_INFO_ERROR);
}
}
......@@ -423,21 +434,45 @@ public class FoodIngredientsPresenter extends BasePresenter<FoodIngredientsContr
});
}
// private void getCategoryById(){
// foodCategoryTrees
// }
/**
* 根據分類id移除緩存
*
* @param categoryId
*/
public void removeCacheByCategoryId(int categoryId) {
RxJavaUtils.doInIOThread(new RxIOTask<Integer>(categoryId) {
if (categoryFoodTreeBeans != null) {
for (CategoryFoodTreeBean categoryFoodTreeBean : categoryFoodTreeBeans) {
if (categoryFoodTreeBean.getCategoryIds().contains(categoryId)) {
//清空這個分類下所有的食材
categoryFoodTreeBean.setFoodInfo(null);
break;
}
}
}
}
/**
* 根據分類名字移除緩存
*
* @param categoryName 分類名字
*/
public void removeCacheByCategoryName(String categoryName) {
RxJavaUtils.doInIOThread(new RxIOTask<String>(categoryName) {
@Override
public Void doInIOThread(Integer id) {
public Void doInIOThread(String name) {
for (CategoryFoodTreeBean categoryFoodTreeBean : categoryFoodTreeBeans) {
if (categoryFoodTreeBean.getCategoryIds().contains(id)) {
if (categoryFoodTreeBean.getCategoryNames().contains(name)) {
// int categoryIndex = categoryFoodTreeBean.getCategoryNames().indexOf(name);
//清空這個分類下所有的食材
categoryFoodTreeBean.setFoodInfo(null);
//重新從接口獲取
// getFoodByCategory(categoryId);
// //重新從接口獲取
// if (categoryIndex != -1) {
// getFoodByCategory(categoryFoodTreeBean.getCategoryIds().get(categoryIndex));
// }
break;
}
}
......@@ -447,16 +482,19 @@ public class FoodIngredientsPresenter extends BasePresenter<FoodIngredientsContr
}
/**
* 根據分類名字移除緩存
* 根據分類Id移除緩存
*
* @param categoryName 分類名字
* @param categoryId 分類名字
*/
public void removeCacheByCategoryName(String categoryName) {
RxJavaUtils.doInIOThread(new RxIOTask<String>(categoryName) {
public void removeCacheByCategoryId(Integer categoryId) {
RxJavaUtils.doInIOThread(new RxIOTask<Integer>(categoryId) {
@Override
public Void doInIOThread(String name) {
public Void doInIOThread(Integer categoryId) {
if (categoryId == null) {
return null;
}
for (CategoryFoodTreeBean categoryFoodTreeBean : categoryFoodTreeBeans) {
if (categoryFoodTreeBean.getCategoryNames().contains(name)) {
if (categoryFoodTreeBean.getCategoryIds().contains(categoryId)) {
// int categoryIndex = categoryFoodTreeBean.getCategoryNames().indexOf(name);
//清空這個分類下所有的食材
categoryFoodTreeBean.setFoodInfo(null);
......@@ -523,7 +561,7 @@ public class FoodIngredientsPresenter extends BasePresenter<FoodIngredientsContr
//用於提前終止循環,如果已經拿到過這個分類下的數據,後面沒有這個分類下的數據了,就終止循環
boolean hasFood = false;
for (PurchaseFoodBean purchaseFoodBean : foodInfo) {
if (purchaseFoodBean.getFoodCategoryId() == id) {
if (id.equals(purchaseFoodBean.getFoodCategoryId())) {
hasFood = true;
foods.add(purchaseFoodBean);
} else if (hasFood) {
......@@ -550,7 +588,7 @@ public class FoodIngredientsPresenter extends BasePresenter<FoodIngredientsContr
.doOnSubscribe(disposable -> mRootView.showLoading("獲取中..."))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
.doAfterNext(dis -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<FoodByCategoryResultBean>(mErrorHandler) {
......
......@@ -149,7 +149,7 @@ public class FoodUnitPagePresenter extends BasePresenter<FoodUnitPageContract.Mo
}
public void addDeputyUnit(List<DeputyUnitBean> data) {
//新增為true,修改為false
//新增為false,修改為true
if (isUpdate) {
if (data == null) {
mRootView.callBackDeputyUnit(null);
......@@ -158,11 +158,13 @@ public class FoodUnitPagePresenter extends BasePresenter<FoodUnitPageContract.Mo
}
} else {
//如果是新增食材,那麼單位返回到新增食材頁面就好,不用做其他處理
Iterator<DeputyUnitBean> iterator = data.iterator();
while (iterator.hasNext()) {
if (TextUtil.isEmptyOrNullOrUndefined(iterator.next().getDeputyUnit())) {
//單位為空,移除掉
iterator.remove();
if (data != null) {
Iterator<DeputyUnitBean> iterator = data.iterator();
while (iterator.hasNext()) {
if (TextUtil.isEmptyOrNullOrUndefined(iterator.next().getDeputyUnit())) {
//單位為空,移除掉
iterator.remove();
}
}
}
mRootView.callBackDeputyUnit(data);
......@@ -248,12 +250,13 @@ public class FoodUnitPagePresenter extends BasePresenter<FoodUnitPageContract.Mo
/**
* 添加基本單位-快捷輸入
* @param content 新增的基本單位
*
* @param content 新增的基本單位
* @param basicUnitBeans 已有的基本單位——需要判斷是否已經存在了
*/
public void addBasicUnit(String content, List<BasicUnitBean> basicUnitBeans) {
for (BasicUnitBean basicUnitBean : basicUnitBeans) {
if(basicUnitBean.getContent().equals(content)){
if (basicUnitBean.getContent().equals(content)) {
mRootView.showMessage("此單位已存在,不能重複添加");
return;
}
......
......@@ -8,6 +8,7 @@ import android.view.inputmethod.EditorInfo;
import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.common.core.restaurant.RestaurantInfoManager;
import com.gingersoft.gsa.cloud.common.utils.CollectionUtils;
import com.gingersoft.gsa.cloud.common.utils.JsonUtils;
import com.gingersoft.gsa.cloud.common.utils.gson.GsonUtils;
import com.gingersoft.gsa.cloud.common.utils.inputFilter.DecimalDigitsInputFilter;
......@@ -21,6 +22,7 @@ import com.gingersoft.gsa.cloud.ui.adapter.bean.UploadPicMultiBean;
import com.gingersoft.gsa.cloud.ui.bean.SectionCheckItem;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.mvp.bean.DeputyUnitBean;
import com.gingersoft.supply_chain.mvp.bean.OrderCategoryBean;
import com.gingersoft.supply_chain.mvp.bean.PurchaseFoodBean;
import com.gingersoft.supply_chain.mvp.bean.SupplierInfoBean;
import com.gingersoft.supply_chain.mvp.content.Constant;
......@@ -111,7 +113,7 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient
* 副單位集合
*/
private List<DeputyUnitBean> deputyUnitBeans;
private String categoryName = "";
// private String categoryName = "";
private String picUrl;
/**
* 如果是修改食材,則不為空
......@@ -144,6 +146,13 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient
this.categoryNames = categoryNames;
}
public String getCategoryName() {
if (categoryNames != null && categoryNames.size() > 0) {
return categoryNames.get(categoryNames.size() - 1);
}
return "";
}
/**
* 獲取食材詳情
*/
......@@ -195,7 +204,7 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient
infoMultiBeans.add(new MultiInputBean(InfoMultiBean.ITEM_TYPE_INPUT, "食材名稱", true, "請輸入名稱"));
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, "請輸入包裝說明"));
infoMultiBeans.add(new MultiInputBean(InfoMultiBean.ITEM_TYPE_INPUT, "包裝說明", false, "請輸入包裝說明", new InputFilter[]{new InputFilter.LengthFilter(10)}));
infoMultiBeans.add(new MultiInputBean(InfoMultiBean.ITEM_TYPE_INPUT, "食材編號", 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));
......@@ -213,11 +222,8 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient
//食品名稱
infoMultiBeans.get(foodNameIndex).setShowValue(purchaseFoodBean.getName());
//食品分類
if (categoryNames != null && categoryNames.size() > 0) {
categoryName = categoryNames.get(categoryNames.size() - 1);
} else {
categoryName = purchaseFoodBean.getFoodCategoryName();
}
categoryNames = new ArrayList<>();
categoryNames.add(purchaseFoodBean.getFoodCategoryName());
infoMultiBeans.get(foodIngredientCategoryIndex).setShowValue(purchaseFoodBean.getFoodCategoryName());
//基本單位
infoMultiBeans.get(basicUnitIndex).setShowValue(purchaseFoodBean.getBasicUnitName());
......@@ -255,11 +261,11 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient
return infoMultiBeans.get(basicUnitIndex).getShowValue();
}
public int getFoodId() {
public Integer getFoodId() {
if (purchaseFoodBean != null) {
return purchaseFoodBean.getId();
}
return 0;
return null;
}
public void setPicUrl(List<InfoMultiBean> data, List<String> picUrls) {
......@@ -275,7 +281,7 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient
/**
* 設置供應商信息
* 設置供應商信息R
*
* @param supplierInfoBean
* @param infoMultiBeans
......@@ -300,19 +306,18 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient
mRootView.refreshAdapterByPosition(basicUnitIndex);
}
public void setCategoryInfo(List<SectionCheckItem> sectionCheckItems, List<InfoMultiBean> infoMultiBeans) {
public void setCategoryInfo(List<OrderCategoryBean.FoodCategoryTrees> foodCategoryTrees, List<InfoMultiBean> infoMultiBeans) {
StringBuilder categoryName = new StringBuilder();
if (categoryNames == null) {
categoryNames = new ArrayList<>();
}
categoryNames.clear();
for (SectionCheckItem sectionCheckItem : sectionCheckItems) {
categoryNames.add(sectionCheckItem.getText());
categoryName.append(sectionCheckItem.getText())
for (OrderCategoryBean.FoodCategoryTrees categoryTrees : foodCategoryTrees) {
categoryNames.add(categoryTrees.getName());
categoryName.append(categoryTrees.getName())
.append(PurchaseFoodBean.CATEGORY_DIVIDER);
}
this.categoryName = sectionCheckItems.get(sectionCheckItems.size() - 1).getText();
categoryName.deleteCharAt(categoryName.lastIndexOf(PurchaseFoodBean.CATEGORY_DIVIDER));
infoMultiBeans.get(foodIngredientCategoryIndex).setShowValue(categoryName.toString());
mRootView.refreshAdapterByPosition(foodIngredientCategoryIndex);
......@@ -320,6 +325,7 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient
/**
* 上傳圖片
*
* @param filePath 圖片路徑
*/
public void uploadPic(String filePath) {
......@@ -385,6 +391,8 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient
* @param purchaseFoodBean
*/
public void updateFood(PurchaseFoodBean purchaseFoodBean) {
//後台不要,不然修改供應商不成功
purchaseFoodBean.setSupplierId(null);
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), GsonUtils.GsonString(purchaseFoodBean));
mModel.updateFood(requestBody)
.subscribeOn(Schedulers.io())
......@@ -414,7 +422,7 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient
msg = "請輸入供應商名稱";
} else if (TextUtil.isEmptyOrNullOrUndefined(infoMultiBeans.get(foodNameIndex).getShowValue())) {
msg = "請輸入食材名稱";
} else if (TextUtil.isEmptyOrNullOrUndefined(categoryName)) {
} else if (TextUtil.isEmptyOrNullOrUndefined(getCategoryName())) {
msg = "請選擇食材類別";
} else if (TextUtil.isEmptyOrNullOrUndefined(infoMultiBeans.get(basicUnitIndex).getShowValue())) {
msg = "請選擇基本單位";
......@@ -430,6 +438,8 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient
if (purchaseFoodBean == null) {
purchaseFoodBean = new PurchaseFoodBean();
}
//這裡拷貝一個類出來,如果本次修改食材沒有成功,也不會影響原有數據
PurchaseFoodBean purchaseFoodBean = (PurchaseFoodBean) PurchaseFoodBean.copy(this.purchaseFoodBean);
//食材圖片
if (TextUtil.isNotEmptyOrNullOrUndefined(picUrl)) {
purchaseFoodBean.setImages(picUrl);
......@@ -437,15 +447,20 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient
//食材所屬供應商
purchaseFoodBean.setSupplierName(infoMultiBeans.get(supplierIndex).getShowValue());
//食材名稱
purchaseFoodBean.setName(infoMultiBeans.get(foodNameIndex).getShowValue());
purchaseFoodBean.setName(infoMultiBeans.get(foodNameIndex).getShowValue().trim());
//食材類別名稱
purchaseFoodBean.setFoodCategoryName(categoryName);
purchaseFoodBean.setFoodCategoryName(getCategoryName());
//食材基本單位
purchaseFoodBean.setBasicUnitName(infoMultiBeans.get(basicUnitIndex).getShowValue());
//包裝描述
purchaseFoodBean.setPackingDescription(infoMultiBeans.get(packingDescriptionIndex).getShowValue());
//食材編號
purchaseFoodBean.setFoodNo(infoMultiBeans.get(foodNoIndex).getShowValue());
String foodNo = infoMultiBeans.get(foodNoIndex).getShowValue();
if (TextUtil.isNotEmptyOrNullOrUndefined(foodNo)) {
purchaseFoodBean.setFoodNo(infoMultiBeans.get(foodNoIndex).getShowValue());
} else {
purchaseFoodBean.setFoodNo(null);
}
//單價
String unitPriceStr = infoMultiBeans.get(foodIngredientPriceIndex).getShowValue();
if (TextUtil.isNotEmptyOrNullOrUndefined(unitPriceStr)) {
......@@ -489,18 +504,19 @@ public class NewFoodIngredientsPresenter extends BasePresenter<NewFoodIngredient
if (inventoryAlarm.getReviews() != purchaseFoodBean.getInventoryAlarm().getReviews()) {
isUpdateAlarm = true;
}
if (!isUpdateAlarm && mixInventory.equals(purchaseFoodBean.getInventoryAlarm().getMinimumInventory() + "")) {
if (!isUpdateAlarm && !mixInventory.equals(purchaseFoodBean.getInventoryAlarm().getMinimumInventory() + "")) {
isUpdateAlarm = true;
}
if (!isUpdateAlarm && shelfLife.equals(purchaseFoodBean.getInventoryAlarm().getShelfLife() + "")) {
if (!isUpdateAlarm && !shelfLife.equals(purchaseFoodBean.getInventoryAlarm().getShelfLife() + "")) {
isUpdateAlarm = true;
}
if (!isUpdateAlarm && shelfLifeWarning.equals(purchaseFoodBean.getInventoryAlarm().getWarningDays() + "")) {
if (!isUpdateAlarm && !shelfLifeWarning.equals(purchaseFoodBean.getInventoryAlarm().getWarningDays() + "")) {
isUpdateAlarm = true;
}
if (!isUpdateAlarm) {
if (isUpdateAlarm) {
//修改了庫存預警,並且之前的預警不為空,把id設置上
inventoryAlarm.setId(purchaseFoodBean.getInventoryAlarm().getId());
purchaseFoodBean.setInventoryAlarm(inventoryAlarm);
} else {
//沒修改庫存預警,就不傳給後台
purchaseFoodBean.setInventoryAlarm(null);
......
......@@ -22,8 +22,10 @@ import com.gingersoft.gsa.cloud.ui.adapter.bean.MultiSelectBean;
import com.gingersoft.gsa.cloud.ui.adapter.multi.InfoMultiAdapter;
import com.gingersoft.gsa.cloud.ui.adapter.multi.RemarkProvider;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.mvp.bean.PurchaseFoodBean;
import com.gingersoft.supply_chain.mvp.bean.SupplierInfoBean;
import com.gingersoft.supply_chain.mvp.content.Constant;
import com.gingersoft.supply_chain.mvp.content.SupplyShoppingCart;
import com.gingersoft.supply_chain.mvp.contract.NewSupplierContract;
import com.jess.arms.di.scope.FragmentScope;
import com.jess.arms.http.imageloader.ImageLoader;
......@@ -31,6 +33,8 @@ import com.jess.arms.integration.AppManager;
import com.jess.arms.mvp.BasePresenter;
import com.jess.arms.utils.EnAndNumInputFilter;
import com.jess.arms.utils.RxLifecycleUtils;
import com.xuexiang.rxutil2.rxjava.RxJavaUtils;
import com.xuexiang.rxutil2.rxjava.task.RxIOTask;
import java.util.ArrayList;
import java.util.HashMap;
......@@ -176,22 +180,27 @@ public class NewSupplierPresenter extends BasePresenter<NewSupplierContract.Mode
infoMultiAdapter.setOnItemChildClickListener((adapter, view, position) -> {
if (view.getId() == R.id.cb_multi_check) {
// 聯繫方式的選中
//先找到之前的默認聯繫方式
List<InfoMultiBean> data = infoMultiAdapter.getData();
InfoMultiBean infoMultiBean = data.get(position);
if (infoMultiBean instanceof MultiCheckInputBean) {
int lastDefault = emailIndex;
for (int i = emailIndex; i < smsIndex + 1; i++) {
//從email開始,到sms,是所有的聯繫方式
//將聯繫方式的選中設為false
InfoMultiBean infoMultiBean = data.get(i);
//拿到對象,找到上一次被設為默認的那個聯繫方式,修改為false
MultiCheckInputBean multiCheckInputBean = (MultiCheckInputBean) infoMultiBean;
int index = contactInfo.indexOf(multiCheckInputBean);
if (index >= 0) {
MultiCheckInputBean multiCheckInputBean1 = contactInfo.get(index);
if (multiCheckInputBean1 != null) {
for (MultiCheckInputBean checkInputBean : contactInfo) {
checkInputBean.setDefault(false);
}
multiCheckInputBean1.setDefault(true);
}
if (multiCheckInputBean.isDefault()) {
lastDefault = i;
multiCheckInputBean.setDefault(false);
break;
}
infoMultiAdapter.notifyDataSetChanged();
}
//然後再將本次選中的設為true,刷新這兩個item
InfoMultiBean infoMultiBean = data.get(position);
MultiCheckInputBean multiCheckInputBean = (MultiCheckInputBean) infoMultiBean;
multiCheckInputBean.setDefault(true);
infoMultiAdapter.notifyItemChanged(lastDefault);
infoMultiAdapter.notifyItemChanged(position);
}
});
return infoMultiAdapter;
......@@ -202,11 +211,10 @@ public class NewSupplierPresenter extends BasePresenter<NewSupplierContract.Mode
if (v instanceof EditText) {
if (!hasFocus) {
EditText editText = (EditText) v;
if (TextUtil.isNotEmptyOrNullOrUndefined(editText)) {
if(TextUtil.isNotEmptyOrNullOrUndefined(supplierName)){
if (TextUtil.isNotEmptyOrNullOrUndefined(supplierName)) {
//當供應商名稱不為空時,是修改供應商
if(!editText.getText().toString().equals(supplierName)){
if (!editText.getText().toString().equals(supplierName)) {
//輸入的供應商名稱和之前的名稱不相同,說明進行了修改,需要進行查詢
getSupplierInfo(editText, editText.getText().toString());
}
......@@ -300,7 +308,7 @@ public class NewSupplierPresenter extends BasePresenter<NewSupplierContract.Mode
public void deleteSupplier(int supplierId) {
mModel.deleteSupplier(supplierId)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading("保存中..."))
.doOnSubscribe(disposable -> mRootView.showLoading(Constant.SAVE_LOADING))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
......@@ -311,11 +319,12 @@ public class NewSupplierPresenter extends BasePresenter<NewSupplierContract.Mode
public void onNext(@NonNull BaseResult info) {
if (info != null) {
if (info.isSuccess()) {
SupplyShoppingCart.getInstance().removeFoodsBySupplier(supplierId);
mRootView.saveSuccess();
} else if (TextUtil.isNotEmptyOrNullOrUndefined(info.getErrMsg())) {
mRootView.showMessage(info.getErrMsg());
} else {
mRootView.showMessage("保存失敗");
mRootView.showMessage(Constant.SAVE_FAIL);
}
}
}
......
......@@ -38,6 +38,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
......@@ -45,6 +46,8 @@ import java.util.Objects;
import static com.gingersoft.supply_chain.mvp.content.Constant.GET_INFO_ERROR;
import static com.gingersoft.supply_chain.mvp.content.Constant.GET_INFO_LOADING;
import static com.gingersoft.supply_chain.mvp.content.Constant.NULL_INFO_ERROR;
import static com.gingersoft.supply_chain.mvp.content.Constant.SAVE_FAIL;
import static com.gingersoft.supply_chain.mvp.content.Constant.SAVE_LOADING;
/**
......@@ -75,6 +78,14 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
* 所上傳的圖片路徑集合
*/
private List<String> imgs;
/**
* 逗號分隔符
*/
private final String COMMA_SEPARATED = ",";
/**
* 訂單狀態
*/
public int orderState;
@Inject
public OrderDetailsPresenter(OrderDetailsContract.Model model, OrderDetailsContract.View rootView) {
......@@ -110,8 +121,16 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
PurchaseOrderDetailsBean orderDetailsBean = GsonUtils.GsonToBean(GsonUtils.GsonString(baseResult.getData()), PurchaseOrderDetailsBean.class);
if (orderDetailsBean != null) {
OrderDetailsPresenter.this.orderId = orderId;
transformationWareHouse(orderDetailsBean);
mRootView.loadOrderDetails(orderDetailsBean);
try {
transformationWareHouse(orderDetailsBean);
orderState = orderDetailsBean.getStatus();
//加載圖片
loadImages(orderDetailsBean.getFiles());
mRootView.loadOrderDetails(orderDetailsBean);
} catch (NullPointerException e) {
mRootView.showMessage(e.getMessage());
mRootView.killMyself();
}
} else {
mRootView.showMessage(GET_INFO_ERROR);
}
......@@ -130,7 +149,7 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
* 收過貨的單:不可操作單位,顯示入庫單位 purchaseWarehousingUnits
* showUnit 用於顯示的單位,進行收貨操作時傳遞給後台
*/
private void transformationWareHouse(PurchaseOrderDetailsBean orderDetailsBean) {
private void transformationWareHouse(PurchaseOrderDetailsBean orderDetailsBean) throws NullPointerException {
List<PurchaseOrderDetailsBean.PurchaseOrderDetailsInfoVosBean> purchaseOrderDetailsInfoVos = orderDetailsBean.getPurchaseOrderDetailsInfoVOS();
if (purchaseOrderDetailsInfoVos != null) {
//遍歷訂單商品
......@@ -138,30 +157,31 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
purchaseOrderDetailsInfoVO.setOrderNo(orderDetailsBean.getOrderNo());
//單位
List<DeputyUnitBean> deputyUnitBeans = purchaseOrderDetailsInfoVO.getFoodUnits();
//計算出當前食材總金額
double warehousingAmount = MoneyUtil.priceCalculation(purchaseOrderDetailsInfoVO.getFoodPrice(), purchaseOrderDetailsInfoVO.getFoodQuantity());
//待收貨的
if (purchaseOrderDetailsInfoVO.getStatus() == PurchaseOrderDetailsBean.WAIT_RECEIVED) {
//副單位為空,設置顯示主單位
if (deputyUnitBeans == null) {
deputyUnitBeans = new ArrayList<>();
//添加主單位到副單位列表,用戶可手動切換
DeputyUnitBean deputyUnitBean = new DeputyUnitBean(purchaseOrderDetailsInfoVO.getBasicUnitName(), purchaseOrderDetailsInfoVO.getFoodQuantity());
deputyUnitBean.setDeputyValue(purchaseOrderDetailsInfoVO.getFoodQuantity());
deputyUnitBean.setUnitPrice(purchaseOrderDetailsInfoVO.getFoodPrice());
deputyUnitBeans.add(deputyUnitBean);
//设置显示的单位為主單位
purchaseOrderDetailsInfoVO.setShowUnit(deputyUnitBeans.get(0));
purchaseOrderDetailsInfoVO.setFoodUnits(deputyUnitBeans);
}
if (TextUtil.isEmptyOrNullOrUndefined(purchaseOrderDetailsInfoVO.getBasicUnitName())) {
throw new NullPointerException("未獲取到食品主單位,請檢查後重試");
}
//添加主單位到副單位列表,用戶可手動切換
DeputyUnitBean deputyUnitBean = new DeputyUnitBean(purchaseOrderDetailsInfoVO.getBasicUnitName(), purchaseOrderDetailsInfoVO.getFoodQuantity());
deputyUnitBean.setDeputyValue(purchaseOrderDetailsInfoVO.getFoodQuantity());
deputyUnitBean.setUnitPrice(purchaseOrderDetailsInfoVO.getFoodPrice());
deputyUnitBeans.add(0, deputyUnitBean);
//设置显示的单位,如果大於1,則顯示第一個,因為第一個是副單位,默認顯示副單位
if (deputyUnitBeans.size() > 1) {
purchaseOrderDetailsInfoVO.setShowUnit(deputyUnitBeans.get(1));
} else {
//设置显示的单位為第一個副單位
DeputyUnitBean deputyUnitBean = purchaseOrderDetailsInfoVO.getFoodUnits().get(0);
deputyUnitBean.setDeputyValue(purchaseOrderDetailsInfoVO.getFoodQuantity());
deputyUnitBean.setUnitPrice(purchaseOrderDetailsInfoVO.getFoodPrice());
purchaseOrderDetailsInfoVO.setShowUnit(deputyUnitBean);
//只有一個單位,顯示主單位
purchaseOrderDetailsInfoVO.setShowUnit(deputyUnitBeans.get(0));
}
//設置單位集合
purchaseOrderDetailsInfoVO.setFoodUnits(deputyUnitBeans);
} else {
//如果不是待收貨的商品:部分收貨和已完成,都不可再更改收貨單位,只顯示一個固定的單位
//拿到入庫的那個單位
......@@ -169,6 +189,13 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
if (wareHousingUnitBean != null) {
//只有一個入庫單位
DeputyUnitBean warehouseUnit = DeputyUnitBean.getDeputyUnitByWareHousingUnit(wareHousingUnitBean);
if (purchaseOrderDetailsInfoVO.getStatus() == PurchaseOrderDetailsBean.COMPLETE_RECEIVED) {
//已經全部收貨,顯示已入庫數量
warehouseUnit.setDeputyValue(purchaseOrderDetailsInfoVO.getWarehousingQuantity());
} else {
//已經入庫一次的食材,數量顯示為食材總數-已入庫數量
warehouseUnit.setDeputyValue(Math.max(MoneyUtil.sub(purchaseOrderDetailsInfoVO.getFoodQuantity(), purchaseOrderDetailsInfoVO.getWarehousingQuantity()), 0));
}
purchaseOrderDetailsInfoVO.setShowUnit(warehouseUnit);
purchaseOrderDetailsInfoVO.setFoodUnits(Collections.singletonList(warehouseUnit));
}
......@@ -189,6 +216,26 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
}
/**
* 加載圖片
*
* @param images
*/
public void loadImages(String images) {
if (TextUtil.isNotEmptyOrNullOrUndefined(images)) {
String[] split = images.split(COMMA_SEPARATED);
if (imgs == null) {
imgs = new ArrayList<>();
}
for (String s : split) {
if (TextUtil.isNotEmptyOrNullOrUndefined(s)) {
mRootView.uploadPicSuccess(s);
imgs.add(s);
}
}
}
}
/**
* 入庫
*
* @param state 入庫狀態
......@@ -205,7 +252,7 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), GsonUtils.GsonString(wareHouseBean));
mModel.addWarehouse(requestBody)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(GET_INFO_LOADING))
.doOnSubscribe(disposable -> mRootView.showLoading(SAVE_LOADING))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
......@@ -219,7 +266,7 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
} else if (TextUtil.isNotEmptyOrNullOrUndefined(baseResult.getErrMsg())) {
mRootView.showMessage(baseResult.getErrMsg());
} else {
mRootView.showMessage(GET_INFO_ERROR);
mRootView.showMessage(SAVE_FAIL);
}
}
});
......@@ -240,7 +287,7 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
if (imgs != null) {
StringBuilder files = new StringBuilder();
for (String img : imgs) {
files.append(img).append(",");
files.append(img).append(COMMA_SEPARATED);
}
String substring = files.substring(0, files.length());
purchaseWarehousingOrder.setFiles(substring);
......@@ -264,7 +311,7 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
}
List<OrderWareHouseBean.PurchaseWarehousingOrderDetail> purchaseWarehousingOrderDetails = new ArrayList<>();
for (PurchaseOrderDetailsBean.PurchaseOrderDetailsInfoVosBean purchaseOrderDetailsInfoVosBean : purchaseOrderDetailsInfoVosBeans) {
if (purchaseOrderDetailsInfoVosBean.isChecked()) {
if (purchaseOrderDetailsInfoVosBean.getStatus() != PurchaseOrderDetailsBean.COMPLETE_RECEIVED && purchaseOrderDetailsInfoVosBean.isChecked()) {
OrderWareHouseBean.PurchaseWarehousingOrderDetail purchaseWarehousingOrderDetail = new OrderWareHouseBean.PurchaseWarehousingOrderDetail();
purchaseWarehousingOrderDetail.setOrderDetailsId(purchaseOrderDetailsInfoVosBean.getId());
purchaseWarehousingOrderDetail.setPurchaseFoodId(purchaseOrderDetailsInfoVosBean.getPurchaseFoodId());
......
......@@ -347,15 +347,8 @@ public class ShoppingCatPresenter extends BasePresenter<ShoppingCatContract.Mode
ShoppingCartBean shoppingCartBean = shoppingCartBeans.get(i);
//判斷選中了多少個商品,如果這個供應商的食品一個都沒被選中,就不用管
if (shoppingCartBean.getSelectSpeciesNum() > 0) {
//計算已選中食品的總金額
double totalAmount = 0;
for (PurchaseFoodBean purchaseFoodBean : shoppingCartBean.getFoodList()) {
if (purchaseFoodBean.isChecked()) {
totalAmount = MoneyUtil.sum(totalAmount, MoneyUtil.priceCalculation(purchaseFoodBean.getUnitPrice(), purchaseFoodBean.getFoodQuantity()));
}
}
//判斷總金額是否滿足最低採購金額
if (MoneyUtil.compareTo(totalAmount, shoppingCartBean.getMinimumAmount()) == -1) {
if (MoneyUtil.compareTo(shoppingCartBean.getSelectFoodAmount(), shoppingCartBean.getMinimumAmount()) == -1) {
//不滿足最低採購金額
return false;
}
......
......@@ -6,9 +6,11 @@ import com.gingersoft.gsa.cloud.common.core.restaurant.RestaurantInfoManager;
import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.common.utils.gson.GsonUtils;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.supply_chain.mvp.bean.PurchaseFoodBean;
import com.gingersoft.supply_chain.mvp.bean.SupplierInfoBean;
import com.gingersoft.supply_chain.mvp.bean.SupplierResultBean;
import com.gingersoft.supply_chain.mvp.content.Constant;
import com.gingersoft.supply_chain.mvp.content.SupplyShoppingCart;
import com.gingersoft.supply_chain.mvp.contract.SupplierListContract;
import com.jess.arms.di.scope.FragmentScope;
import com.jess.arms.http.imageloader.ImageLoader;
......@@ -17,9 +19,11 @@ import com.jess.arms.mvp.BasePresenter;
import com.jess.arms.utils.RxLifecycleUtils;
import com.xuexiang.rxutil2.rxjava.RxJavaUtils;
import com.xuexiang.rxutil2.rxjava.task.RxAsyncTask;
import com.xuexiang.rxutil2.rxjava.task.RxIOTask;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
......@@ -125,7 +129,7 @@ public class SupplierListPresenter extends BasePresenter<SupplierListContract.Mo
RxJavaUtils.executeAsyncTask(new RxAsyncTask<Object, Integer>(1) {
@Override
public void doInUIThread(Integer o) {
if(o != null){
if (o != null) {
mRootView.setSelectIndex(o);
}
}
......@@ -164,7 +168,8 @@ public class SupplierListPresenter extends BasePresenter<SupplierListContract.Mo
/**
* 刪除供應商
* @param id 供應商id
*
* @param id 供應商id
* @param position 所刪除的供應商下標
*/
public void deleteSupplier(int id, int position) {
......@@ -181,6 +186,7 @@ public class SupplierListPresenter extends BasePresenter<SupplierListContract.Mo
public void onNext(@NonNull BaseResult info) {
if (info != null) {
if (info.isSuccess()) {
SupplyShoppingCart.getInstance().removeFoodsBySupplier(id);
mRootView.deleteSuccess(position);
} else if (TextUtil.isNotEmptyOrNullOrUndefined(info.getErrMsg())) {
mRootView.showMessage(info.getErrMsg());
......
......@@ -3,8 +3,11 @@ package com.gingersoft.supply_chain.mvp.presenter;
import android.app.Application;
import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.common.utils.JsonUtils;
import com.gingersoft.gsa.cloud.common.utils.gson.GsonUtils;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.supply_chain.mvp.bean.ConsumeReasonBean;
import com.gingersoft.supply_chain.mvp.bean.ConsumeWareHousingBean;
import com.gingersoft.supply_chain.mvp.bean.WareHouseListBean;
import com.gingersoft.supply_chain.mvp.bean.WarehouseDetailsBean;
import com.gingersoft.supply_chain.mvp.content.Constant;
......@@ -18,6 +21,8 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import me.jessyan.rxerrorhandler.core.RxErrorHandler;
import me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber;
import okhttp3.FormBody;
import okhttp3.RequestBody;
import javax.inject.Inject;
......@@ -25,6 +30,7 @@ import com.gingersoft.supply_chain.mvp.contract.WarehouseDetailsContract;
import com.jess.arms.utils.RxLifecycleUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -66,12 +72,16 @@ public class WarehouseDetailsPresenter extends BasePresenter<WarehouseDetailsCon
this.mApplication = null;
}
public void getWarehousingOrderDetails(int foodId, String basicUnitName) {
/**
* 獲取入庫訂單流水
*
* @param foodNo 食材編號
*/
public void getWarehousingOrderDetails(String foodNo) {
Map<String, Object> map = new HashMap<>(4);
Constant.addBrandId(map);
Constant.addRestaurantId(map);
map.put("id", foodId);
map.put("basicUnitName", basicUnitName);
map.put("foodNo", foodNo);
mModel.getWarehousingOrderDetails(map)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(Constant.GET_INFO_LOADING))
......@@ -83,9 +93,41 @@ public class WarehouseDetailsPresenter extends BasePresenter<WarehouseDetailsCon
@Override
public void onNext(BaseResult baseResult) {
if (baseResult != null && baseResult.isSuccess()) {
WarehouseDetailsBean warehouseDetailsBean = GsonUtils.GsonToBean(baseResult.getData(), WarehouseDetailsBean.class);
mRootView.loadWarehousing(warehouseDetailsBean);
} else if(baseResult != null && TextUtil.isNotEmptyOrNullOrUndefined(baseResult.getErrMsg())) {
List<WarehouseDetailsBean> warehouseDetailsBean = GsonUtils.jsonToList(baseResult.getData(), WarehouseDetailsBean.class);
mRootView.loadAdapter(warehouseDetailsBean);
} else if (baseResult != null && TextUtil.isNotEmptyOrNullOrUndefined(baseResult.getErrMsg())) {
mRootView.showMessage(baseResult.getErrMsg());
} else {
mRootView.showMessage(Constant.GET_INFO_ERROR);
}
}
});
}
/**
* 獲取出庫庫訂單流水
*
* @param foodNo
*/
public void getOutStockDetails(String foodNo) {
Map<String, Object> map = new HashMap<>(4);
Constant.addBrandId(map);
Constant.addRestaurantId(map);
map.put("foodNo", foodNo);
mModel.getOutStockDetails(map)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(Constant.GET_INFO_LOADING))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<BaseResult>(mErrorHandler) {
@Override
public void onNext(BaseResult baseResult) {
if (baseResult != null && baseResult.isSuccess()) {
List<ConsumeWareHousingBean> consumeWareHousingBeans = GsonUtils.GsonToList(baseResult.getData(), ConsumeWareHousingBean.class);
mRootView.loadAdapter(WarehouseDetailsBean.getWarehousingByConsumes(consumeWareHousingBeans));
} else if (baseResult != null && TextUtil.isNotEmptyOrNullOrUndefined(baseResult.getErrMsg())) {
mRootView.showMessage(baseResult.getErrMsg());
} else {
mRootView.showMessage(Constant.GET_INFO_ERROR);
......@@ -97,7 +139,7 @@ public class WarehouseDetailsPresenter extends BasePresenter<WarehouseDetailsCon
/**
* 獲取庫存消耗原因
*/
public void getWarehouseInventoryReason(){
public void getWarehouseInventoryReason() {
mModel.getWarehouseInventoryReason()
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(Constant.GET_INFO_LOADING))
......@@ -109,8 +151,49 @@ public class WarehouseDetailsPresenter extends BasePresenter<WarehouseDetailsCon
@Override
public void onNext(BaseResult baseResult) {
if (baseResult != null && baseResult.isSuccess()) {
List<ConsumeReasonBean> consumeReasonBeans = GsonUtils.GsonToList(baseResult.getData(), ConsumeReasonBean.class);
mRootView.loadConsumeReason(consumeReasonBeans);
} else if (baseResult != null && TextUtil.isNotEmptyOrNullOrUndefined(baseResult.getErrMsg())) {
mRootView.showMessage(baseResult.getErrMsg());
} else {
mRootView.showMessage(Constant.GET_INFO_ERROR);
}
}
});
}
} else if(baseResult != null && TextUtil.isNotEmptyOrNullOrUndefined(baseResult.getErrMsg())) {
/**
* 庫存消耗
*
* @param foodNo 食材編號
* @param consumeQuantity 消耗數量
* @param purchaseConsumeReasonId 原因id
* @param remarks 備註
*/
public void consumeWareHousing(String foodNo, int consumeQuantity, int purchaseConsumeReasonId, String remarks) {
FormBody.Builder formBody = new FormBody.Builder()
.add("foodNo", foodNo)
.add("consumeQuantity", String.valueOf(consumeQuantity))
.add("purchaseConsumeReasonId", String.valueOf(purchaseConsumeReasonId))
.add("remarks", remarks);
Constant.addRestaurantId(formBody);
Constant.addBrandId(formBody);
mModel.consumeWareHousing(formBody.build())
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(Constant.UPDATE_LOADING))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<BaseResult>(mErrorHandler) {
@Override
public void onNext(BaseResult baseResult) {
if (baseResult != null && baseResult.isSuccess()) {
//消耗完之後,刷新列表
mRootView.getPageInfo();
//重新獲取庫存數量
getWarehousingNum(foodNo);
} else if (baseResult != null && TextUtil.isNotEmptyOrNullOrUndefined(baseResult.getErrMsg())) {
mRootView.showMessage(baseResult.getErrMsg());
} else {
mRootView.showMessage(Constant.GET_INFO_ERROR);
......@@ -119,4 +202,33 @@ public class WarehouseDetailsPresenter extends BasePresenter<WarehouseDetailsCon
});
}
/**
* 獲取庫存數量
*/
public void getWarehousingNum(String foodNo) {
Map<String, Object> map = new HashMap<>(3);
Constant.addBrandId(map);
Constant.addRestaurantId(map);
map.put("foodNo", foodNo);
mModel.getWarehousingNum(map)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(Constant.QUERY_LOADING))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<BaseResult>(mErrorHandler) {
@Override
public void onNext(BaseResult baseResult) {
if (baseResult != null && baseResult.isSuccess()) {
try {
mRootView.setWarehousingNum((int) Double.parseDouble(GsonUtils.GsonString(baseResult.getData())));
} catch (NumberFormatException e) {
mRootView.killMyself();
e.printStackTrace();
}
}
}
});
}
}
......@@ -2,16 +2,24 @@ package com.gingersoft.supply_chain.mvp.presenter;
import android.app.Application;
import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.supply_chain.mvp.content.Constant;
import com.jess.arms.integration.AppManager;
import com.jess.arms.di.scope.FragmentScope;
import com.jess.arms.mvp.BasePresenter;
import com.jess.arms.http.imageloader.ImageLoader;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import me.jessyan.rxerrorhandler.core.RxErrorHandler;
import me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber;
import okhttp3.FormBody;
import javax.inject.Inject;
import com.gingersoft.supply_chain.mvp.contract.WarehousingInventoryContract;
import com.jess.arms.utils.RxLifecycleUtils;
/**
......@@ -50,4 +58,41 @@ public class WarehousingInventoryPresenter extends BasePresenter<WarehousingInve
this.mImageLoader = null;
this.mApplication = null;
}
/**
* 庫存消耗
*
* @param foodNo 食材編號
* @param consumeQuantity 消耗數量
*/
public void consumeWareHousing(String foodNo, int consumeQuantity) {
FormBody.Builder formBody = new FormBody.Builder()
.add("foodNo", foodNo)
.add("consumeQuantity", String.valueOf(consumeQuantity))
.add("purchaseConsumeReasonId", String.valueOf(Constant.INVENTORY_CONSUME_ID));
Constant.addRestaurantId(formBody);
Constant.addBrandId(formBody);
mModel.consumeWareHousing(formBody.build())
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(Constant.SAVE_LOADING))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<BaseResult>(mErrorHandler) {
@Override
public void onNext(BaseResult baseResult) {
if (baseResult != null && baseResult.isSuccess()) {
//消耗完之後,關閉頁面
mRootView.showMessage(Constant.SAVE_SUCCESS);
mRootView.updateSuccess();
mRootView.killMyself();
} else if (baseResult != null && TextUtil.isNotEmptyOrNullOrUndefined(baseResult.getErrMsg())) {
mRootView.showMessage(baseResult.getErrMsg());
} else {
mRootView.showMessage(Constant.SAVE_FAIL);
}
}
});
}
}
......@@ -402,11 +402,31 @@ public interface SupplierServer {
Observable<BaseResult> getWarehousingOrderDetails(@QueryMap Map<String, Object> map);
/**
* 查詢出庫流水
*/
@Headers({"Domain-Name: ricepon-purchase"})
@GET("purchaseConsume/get/running/water" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> getOutStockDetails(@QueryMap Map<String, Object> map);
/**
* 查詢庫存消耗原因
*/
@Headers({"Domain-Name: ricepon-purchase"})
@GET("purchaseConsumeReason/list" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> getWarehouseInventoryReason();
/**
* 庫存消耗
*/
@Headers({"Domain-Name: ricepon-purchase"})
@POST("purchaseConsume/add" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> consumeWareHousing(@Body RequestBody requestBody);
/**
* 查詢庫存數量
*/
@Headers({"Domain-Name: ricepon-purchase"})
@GET("purchaseConsume/get/remaining/quantity" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> getWarehousingNum(@QueryMap Map<String, Object> map);
}
......@@ -10,9 +10,11 @@ import android.widget.EditText;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.gingersoft.gsa.cloud.ui.adapter.multi.InfoMultiAdapter;
import com.gingersoft.gsa.cloud.ui.widget.dialog.LoadingDialog;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.di.component.DaggerSupplyChainMainComponent;
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;
......@@ -54,14 +56,17 @@ public class SupplyChainMainActivity extends BaseFragmentActivity<SupplyChainMai
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
if(getTopFragment() instanceof NotDispatchListener){
if (getTopFragment() instanceof NotDispatchListener) {
return super.dispatchTouchEvent(ev);
}
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
// 获得当前得到焦点的View,一般情况下就是EditText(特殊情况就是轨迹求或者实体案件会移动焦点)
View v = getCurrentFocus();
if(v != null && v.getTag() != null && v.getTag() == InfoMultiAdapter.NOT_HIDE_KEYBOARD){
return super.dispatchTouchEvent(ev);
}
if (isShouldHideInput(v, ev)) {
if(v instanceof EditText){
if (v instanceof EditText) {
//不然不會觸發焦點監聽事件
v.clearFocus();
}
......@@ -147,6 +152,12 @@ public class SupplyChainMainActivity extends BaseFragmentActivity<SupplyChainMai
}
@Override
protected void onDestroy() {
super.onDestroy();
SupplyShoppingCart.getInstance().clear();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
}
......
package com.gingersoft.gsa.cloud.ui.adapter;
package com.gingersoft.supply_chain.mvp.ui.adapter;
import android.content.Context;
import android.graphics.drawable.Drawable;
......@@ -11,6 +11,7 @@ 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.gsa.cloud.ui.bean.view.CategoryBean;
import com.gingersoft.supply_chain.mvp.bean.OrderCategoryBean;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
......
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_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;
}
}
package com.gingersoft.supply_chain.mvp.ui.adapter;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.widget.TextView;
import androidx.cardview.widget.CardView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.mvp.bean.FoodCategoryResultBean;
import com.gingersoft.supply_chain.mvp.bean.OrderCategoryBean;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
......@@ -21,7 +24,7 @@ import java.util.List;
* Time: 15:41
* Use:
*/
public class SecondCategoryAdapter extends BaseQuickAdapter<FoodCategoryResultBean.DataBean.FoodCategoryBean, BaseViewHolder> {
public class FoodCategoryAdapter extends BaseQuickAdapter<OrderCategoryBean.FoodCategoryTrees, BaseViewHolder> {
private int selectIndex = 0;
private Drawable checkedBg;
......@@ -31,36 +34,43 @@ public class SecondCategoryAdapter extends BaseQuickAdapter<FoodCategoryResultBe
private int unCheckedTextColor;
private boolean showDelete = false;
public SecondCategoryAdapter(@Nullable List<FoodCategoryResultBean.DataBean.FoodCategoryBean> data) {
public FoodCategoryAdapter(int layoutId, @Nullable List<OrderCategoryBean.FoodCategoryTrees> data) {
super(layoutId, data);
addChildClickViewIds(R.id.iv_category_delete);
}
public FoodCategoryAdapter(@Nullable List<OrderCategoryBean.FoodCategoryTrees> data) {
super(R.layout.item_second_category, data);
addChildClickViewIds(R.id.iv_category_delete);
}
@Override
protected void convert(@NotNull BaseViewHolder viewHolder, FoodCategoryResultBean.DataBean.FoodCategoryBean categoryBean) {
protected void convert(@NotNull BaseViewHolder viewHolder, OrderCategoryBean.FoodCategoryTrees categoryBean) {
viewHolder.setText(R.id.tv_second_category_title, categoryBean.getName());
TextView tvName = viewHolder.getView(R.id.tv_second_category_title);
CardView cardView = viewHolder.getView(R.id.card_purchase_category);
if (categoryBean.getId() == -1) {
cardView.setVisibility(View.GONE);
return;
} else {
cardView.setVisibility(View.VISIBLE);
}
viewHolder.setVisible(R.id.tv_second_category_title, TextUtil.isNotEmptyOrNullOrUndefined(categoryBean.getName()));
if (viewHolder.getAdapterPosition() == selectIndex) {
if (checkedBg != null) {
tvName.setBackground(checkedBg);
cardView.setBackground(checkedBg);
}
if (checkedTextColor != 0) {
tvName.setTextColor(checkedTextColor);
}
} else {
if (unCheckedBg != null) {
tvName.setBackground(unCheckedBg);
cardView.setBackground(unCheckedBg);
}
if (unCheckedTextColor != 0) {
tvName.setTextColor(unCheckedTextColor);
}
}
if (viewHolder.getAdapterPosition() == 0) {
viewHolder.setGone(R.id.iv_category_delete, true);
} else {
viewHolder.setGone(R.id.iv_category_delete, !showDelete);
}
}
public void setShowDelete(boolean showDelete) {
......@@ -68,28 +78,34 @@ public class SecondCategoryAdapter extends BaseQuickAdapter<FoodCategoryResultBe
notifyDataSetChanged();
}
public SecondCategoryAdapter setCheckedBg(Drawable checkedBg) {
public FoodCategoryAdapter setCheckedBg(Drawable checkedBg) {
this.checkedBg = checkedBg;
return this;
}
public SecondCategoryAdapter setUnCheckedBg(Drawable unCheckedBg) {
public FoodCategoryAdapter setUnCheckedBg(Drawable unCheckedBg) {
this.unCheckedBg = unCheckedBg;
return this;
}
public SecondCategoryAdapter setSelectIndex(int selectIndex) {
public FoodCategoryAdapter setSelectIndex(int selectIndex) {
int lastIndex = this.selectIndex;
this.selectIndex = selectIndex;
notifyDataSetChanged();
if (lastIndex >= 0 && lastIndex < getItemCount()) {
notifyItemChanged(lastIndex);
}
if (this.selectIndex >= 0 && this.selectIndex < getItemCount()) {
notifyItemChanged(this.selectIndex);
}
return this;
}
public SecondCategoryAdapter setCheckedTextColor(int checkedTextColor) {
public FoodCategoryAdapter setCheckedTextColor(int checkedTextColor) {
this.checkedTextColor = checkedTextColor;
return this;
}
public SecondCategoryAdapter setUnCheckedTextColor(int unCheckedTextColor) {
public FoodCategoryAdapter setUnCheckedTextColor(int unCheckedTextColor) {
this.unCheckedTextColor = unCheckedTextColor;
return this;
}
......@@ -98,7 +114,4 @@ public class SecondCategoryAdapter extends BaseQuickAdapter<FoodCategoryResultBe
return selectIndex;
}
public FoodCategoryResultBean.DataBean.FoodCategoryBean getSelectData() {
return getData().get(selectIndex);
}
}
......@@ -17,6 +17,8 @@ import com.gingersoft.gsa.cloud.common.utils.glide.GlideUtils;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.mvp.bean.PurchaseFoodBean;
import com.gingersoft.supply_chain.mvp.ui.fragment.food.FoodIngredientsFragment;
import com.google.android.material.textfield.TextInputEditText;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
......@@ -160,7 +162,7 @@ public class FoodListAdapter extends BaseQuickAdapter<PurchaseFoodBean, BaseView
*/
private void setEdit(@NotNull BaseViewHolder viewHolder, PurchaseFoodBean foodInfoBean) {
//食品數量
EditText editText = viewHolder.getView(R.id.ed_food_ingredient_number);
TextInputEditText editText = viewHolder.getView(R.id.ed_food_ingredient_number);
//當前食品總價
TextView mTvTotalAmount = viewHolder.getViewOrNull(R.id.tv_food_item_total_amount);
//從緩存中取出這個食品信息,如果沒有對應的食品信息,說明沒操作過這個食品
......@@ -200,7 +202,7 @@ public class FoodListAdapter extends BaseQuickAdapter<PurchaseFoodBean, BaseView
viewHolder.getView(R.id.btn_food_operation_sub).setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
Log.e("eee", "長按:" + System.currentTimeMillis());
// Log.e("eee", "長按:" + System.currentTimeMillis());
return false;
}
});
......@@ -208,7 +210,7 @@ public class FoodListAdapter extends BaseQuickAdapter<PurchaseFoodBean, BaseView
viewHolder.getView(R.id.btn_food_operation_add).setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
Log.e("eee", "長按:" + System.currentTimeMillis());
// Log.e("eee", "長按:" + System.currentTimeMillis());
return false;
}
});
......@@ -249,12 +251,15 @@ public class FoodListAdapter extends BaseQuickAdapter<PurchaseFoodBean, BaseView
};
editText.setOnFocusChangeListener((v, hasFocus) -> {
if (hasFocus) {
// if ("0".equals(editText.getText() + "")) {
// editText.setText("");
// }
editText.addTextChangedListener(foodNumTextWatcher);
} else {
//當失去焦點時,輸入框沒有值,詢問是否刪除食材
if (TextUtil.isEmptyOrNullOrUndefined(editText)) {
PurchaseFoodBean purchaseFoodBean = getData().get(viewHolder.getAdapterPosition());
if (onNumberChangeListener != null) {
if (adapterType == FoodIngredientsFragment.ORDER_TYPE) {
//購物車走這個方法
onNumberChangeListener.onChanged(purchaseFoodBean.getFoodQuantity(), 0, viewHolder.getAdapterPosition());
} else {
......
......@@ -16,13 +16,17 @@ import org.jetbrains.annotations.NotNull;
*/
public class ImageAdapter extends BaseQuickAdapter<String, BaseViewHolder> {
public ImageAdapter() {
private boolean notShowDelete;
public ImageAdapter(boolean notShowDelete) {
super(R.layout.item_image);
addChildClickViewIds(R.id.iv_img, R.id.iv_img_delete);
this.notShowDelete = notShowDelete;
}
@Override
protected void convert(@NotNull BaseViewHolder viewHolder, String s) {
GlideUtils.display(getContext(), viewHolder.getView(R.id.iv_img), s);
viewHolder.setGone(R.id.iv_img_delete, notShowDelete);
}
}
......@@ -18,6 +18,7 @@ import androidx.recyclerview.widget.RecyclerView;
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.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.other.TextUtil;
......@@ -30,6 +31,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import io.reactivex.Observable;
......@@ -48,17 +50,13 @@ import io.reactivex.schedulers.Schedulers;
public class OrderDetailsFoodAdapter extends BaseQuickAdapter<PurchaseOrderDetailsBean.PurchaseOrderDetailsInfoVosBean, BaseViewHolder> {
private Context context;
private OnValueChangeListener onValueChangeListener;
private onAmountChangeListener onAmountChangeListener;
private String formatAmount;
private InputFilter[] inputFilters;
private int canEditColor;
private int notEditableColor;
public void setOnValueChangeListener(OnValueChangeListener onValueChangeListener) {
this.onValueChangeListener = onValueChangeListener;
}
public OrderDetailsFoodAdapter(Context context, @Nullable List<PurchaseOrderDetailsBean.PurchaseOrderDetailsInfoVosBean> data) {
super(R.layout.item_order_details_food, data);
addChildClickViewIds(R.id.layout_order_details_unit);
......@@ -78,8 +76,8 @@ public class OrderDetailsFoodAdapter extends BaseQuickAdapter<PurchaseOrderDetai
viewHolder.setText(R.id.iv_order_details_item_food_select, item.getName());
//食品單位
viewHolder.setText(R.id.tv_order_details_item_purchasing_unit, item.getUnit_content());
//入庫數量
viewHolder.setText(R.id.tv_order_details_item_warehouse_warehousing_num, String.valueOf(item.getWarehousingQuantity()));
//入庫數量
viewHolder.setText(R.id.tv_order_details_item_warehouse_not_in_storage_num, String.valueOf(Math.max(MoneyUtil.sub(item.getFoodQuantity(), item.getWarehousingQuantity()), 0)));
//食品的收貨狀態
TextView tvFoodState = viewHolder.getView(R.id.tv_order_details_state);
tvFoodState.setText(PurchaseOrderDetailsBean.getStringByOrderState(item.getStatus()));
......@@ -111,17 +109,20 @@ public class OrderDetailsFoodAdapter extends BaseQuickAdapter<PurchaseOrderDetai
viewHolder.setText(R.id.tv_order_details_item_warehouse_num, String.valueOf(item.getFoodQuantity()));
//食品的總價
viewHolder.setText(R.id.tv_order_details_item_warehouse_total_amount, String.format(formatAmount, item.getTotalAmount()));
//實付
viewHolder.setText(R.id.tv_order_details_item_warehouse_actual_amount, String.format(formatAmount, item.getTotalAmount()));
if (item.getShowUnit() != null) {
viewHolder.setText(R.id.tv_order_details_show_unit, item.getShowUnit().getDeputyUnit());
} else {
viewHolder.setText(R.id.tv_order_details_show_unit, "");
}
//食品數量
EditText edFoodNum = viewHolder.getView(R.id.ed_food_num);
edFoodNum.setFilters(inputFilters);
edFoodNum.setText(String.valueOf(item.getShowUnit().getDeputyValue()));
//已入庫數量
viewHolder.setText(R.id.tv_order_details_item_warehouse_warehousing_num, MoneyUtil.formatDouble(item.getWarehousingQuantity()));
viewHolder.setText(R.id.tv_order_details_show_unit, item.getShowUnit().getDeputyUnit());
//數量編輯框,已完成顯示已入庫數量,未完成顯示待入庫數量,已在之前處理過
edFoodNum.setText(MoneyUtil.formatDouble(item.getShowUnit().getDeputyValue()));
//實付
setActualAmount(viewHolder, item.getShowUnit());
//設置入庫總價,總價是由用戶輸入的單價*基本單位數
viewHolder.setText(R.id.tv_order_details_item_warehouse_total_amount, String.format(context.getString(R.string.amount_string_s), MoneyUtil.formatDouble(item.getWarehousingAmount())));
CheckBox checkBox = viewHolder.getView(R.id.iv_order_details_item_food_select);
checkBox.setChecked(item.isChecked());
TextWatcher watcher = new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
......@@ -136,17 +137,35 @@ public class OrderDetailsFoodAdapter extends BaseQuickAdapter<PurchaseOrderDetai
@Override
public void afterTextChanged(Editable s) {
DeputyUnitBean showUnit = getItem(viewHolder.getAdapterPosition()).getShowUnit();
//修改之前的數量
double beforeNum = showUnit.getDeputyValue();
if (TextUtil.isNotEmptyOrNullOrUndefined(s + "")) {
showUnit.setDeputyValue(Double.parseDouble(s.toString()));
} else {
showUnit.setDeputyValue(0);
}
// else {
// showUnit.setDeputyValue(0);
// }
//實付金額發生改變,需要通知頁面刷新總金額
if (checkBox.isChecked()) {
//現在的數量減去之前的數量,再乘以單價,得到增加或減少了多少總價
onAmountChangeListener.onAmountChange(viewHolder.getAdapterPosition(), MoneyUtil.priceCalculation(MoneyUtil.sub(showUnit.getDeputyValue(), beforeNum), showUnit.getUnitPrice()));
}
//數量發生改變,需要修改實付金額
setActualAmount(viewHolder, item.getShowUnit());
}
};
edFoodNum.setOnFocusChangeListener((v, hasFocus) -> {
if (hasFocus) {
edFoodNum.addTextChangedListener(watcher);
if("0".equals(edFoodNum.getText().toString())){
edFoodNum.setText("");
}
} else {
if (TextUtil.isEmptyOrNullOrUndefined(edFoodNum)) {
DeputyUnitBean showUnit = getItem(viewHolder.getAdapterPosition()).getShowUnit();
showUnit.setDeputyValue(0);
edFoodNum.setText("0");
}
edFoodNum.removeTextChangedListener(watcher);
}
});
......@@ -168,90 +187,61 @@ public class OrderDetailsFoodAdapter extends BaseQuickAdapter<PurchaseOrderDetai
@Override
public void afterTextChanged(Editable s) {
DeputyUnitBean showUnit = getItem(viewHolder.getAdapterPosition()).getShowUnit();
//之前的單價
double beforePrice = showUnit.getUnitPrice();
if (TextUtil.isNotEmptyOrNullOrUndefined(s + "")) {
showUnit.setUnitPrice(Double.parseDouble(s.toString()));
} else {
showUnit.setUnitPrice(0);
}
// else {
// showUnit.setUnitPrice(0);
// }
//當前食品已選中,實付金額發生改變,需要通知頁面刷新總金額
if (checkBox.isChecked()) {
//現在的單價減去之前的單價,再乘以數量,得到增加或減少的金額
onAmountChangeListener.onAmountChange(viewHolder.getAdapterPosition(), MoneyUtil.priceCalculation(MoneyUtil.sub(showUnit.getUnitPrice(), beforePrice), showUnit.getDeputyValue()));
}
//單價發生改變,需要修改實付金額
setActualAmount(viewHolder, item.getShowUnit());
}
};
edUnitPrice.setOnFocusChangeListener((v, hasFocus) -> {
if (hasFocus) {
if (TextUtil.isNotEmptyOrNullOrUndefined(edUnitPrice)) {
double price = Double.parseDouble(edUnitPrice.getText().toString());
if(price == 0){
edUnitPrice.setText("");
}
}
edUnitPrice.addTextChangedListener(unitPriceWatcher);
} else {
if (TextUtil.isEmptyOrNullOrUndefined(edUnitPrice)) {
DeputyUnitBean showUnit = getItem(viewHolder.getAdapterPosition()).getShowUnit();
showUnit.setUnitPrice(0);
edUnitPrice.setText("0");
}
edUnitPrice.removeTextChangedListener(unitPriceWatcher);
}
});
//設置入庫總價,總價是由用戶輸入的單價*基本單位數
viewHolder.setText(R.id.tv_order_details_item_warehouse_total_amount, String.format(context.getString(R.string.amount_string_s), MoneyUtil.formatDouble(item.getWarehousingAmount())));
CheckBox checkBox = viewHolder.getView(R.id.iv_order_details_item_food_select);
checkBox.setChecked(item.isChecked());
}
private static class WareHouseUnitAdapter extends BaseQuickAdapter<DeputyUnitBean, BaseViewHolder> {
private int parentPosition;
private OnValueChangeListener onValueChangeListener;
private Disposable mDisposable;
public WareHouseUnitAdapter(List<DeputyUnitBean> wareHouseBeans, int parentPosition, OnValueChangeListener onValueChangeListener) {
super(R.layout.item_receiving_unit, wareHouseBeans);
this.parentPosition = parentPosition;
this.onValueChangeListener = onValueChangeListener;
}
@Override
protected void convert(@NotNull BaseViewHolder viewHolder, DeputyUnitBean wareHouseBean) {
viewHolder.setText(R.id.tv_receiving_unit_title, wareHouseBean.getDeputyUnit());
EditText edWareHouseValue = viewHolder.getView(R.id.ed_receiving_unit_value);
edWareHouseValue.setFilters(new InputFilter[]{new MoneyInputFilter()});
edWareHouseValue.setText(MoneyUtil.formatDouble(wareHouseBean.getDeputyValue()));
TextWatcher textWatcher = new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable editable) {
String s = editable + "";
if (TextUtil.isEmptyOrNullOrUndefined(s)) {
s = "0";
}
DeputyUnitBean item = getData().get(viewHolder.getLayoutPosition());
item.setDeputyValue(Double.parseDouble(s + ""));
if (viewHolder.getAdapterPosition() == 0 || viewHolder.getAdapterPosition() == 1) {
//如果修改的是單價,或者是主單位數量,就要刷新總價
if (mDisposable != null) {
mDisposable.dispose();
}
String finalS = s;
mDisposable = RxJavaUtils.delay(1, l -> onValueChangeListener.onValueChange(parentPosition, Double.parseDouble(finalS)));
}
}
};
edWareHouseValue.setOnFocusChangeListener((v, hasFocus) -> {
if (hasFocus) {
edWareHouseValue.addTextChangedListener(textWatcher);
} else {
edWareHouseValue.removeTextChangedListener(textWatcher);
}
});
}
/**
* 修改實付金額
*/
private void setActualAmount(BaseViewHolder viewHolder, DeputyUnitBean showUnit) {
viewHolder.setText(R.id.tv_order_details_item_warehouse_actual_amount, String.format(formatAmount, MoneyUtil.priceCalculation(showUnit.getDeputyValue(), showUnit.getUnitPrice())));
}
public interface OnValueChangeListener {
public interface onAmountChangeListener {
/**
* 入庫價格發生變化回調接口
*
* @param position 入庫食品的下標
* @param value 增加了多少價格,如果是減少,則改為負的
*/
void onValueChange(int position, double value);
void onAmountChange(int position, double value);
}
public void setOnAmountChangeListener(OrderDetailsFoodAdapter.onAmountChangeListener onAmountChangeListener) {
this.onAmountChangeListener = onAmountChangeListener;
}
}
package com.gingersoft.supply_chain.mvp.ui.adapter;
import android.content.Context;
import android.graphics.Color;
import android.util.Log;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.LinearLayout;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.mvp.bean.OrderCategoryBean;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.math.BigDecimal;
import java.util.Iterator;
import java.util.List;
/**
* @author 宇航.
* User: admin
* Date: 2021/1/25
* Time: 9:20
* Use:
*/
public class SelectCategoryAdapter extends BaseQuickAdapter<OrderCategoryBean.FoodCategoryTrees, BaseViewHolder> {
private int bgColor;
/**
* 記錄當前第幾級分類
*/
private int level;
private OnChildSelectListener onChildSelectListener;
/**
* 當前選中的下標集合
*/
private int[] positions;
/**
* 標題的縮進
*/
private String indentation;
/**
* @param data 分類數據
* @param bgColor 當前背景色
* @param level 當前是第幾級分類
* @param positions 選中下標集合 positions[level]表示獲取第level級選中的分類的下標
*/
public SelectCategoryAdapter(@Nullable List<OrderCategoryBean.FoodCategoryTrees> data, int bgColor, int level, int[] positions) {
super(R.layout.item_select_category, data);
this.bgColor = bgColor;
this.level = level;
this.positions = positions;
indentation = "";
}
public SelectCategoryAdapter setIndentation(String indentation) {
this.indentation = indentation;
return this;
}
@Override
protected void convert(@NotNull BaseViewHolder viewHolder, OrderCategoryBean.FoodCategoryTrees foodCategoryTrees) {
viewHolder.setText(R.id.tv_radio_section_title, indentation + foodCategoryTrees.getName());
viewHolder.setBackgroundColor(R.id.layout_item_select_category, bgColor);
CheckBox checkBox = viewHolder.getView(R.id.cb_radio_section);
if (level < positions.length) {
//當前分類已選中,要默認展開
if (viewHolder.getAdapterPosition() == positions[level]) {
checkBox.setChecked(true);
setChildState(viewHolder, foodCategoryTrees, false);
} else {
checkBox.setChecked(false);
viewHolder.setGone(R.id.rv_select_category, true);
}
} else {
checkBox.setChecked(false);
viewHolder.setGone(R.id.rv_select_category, true);
}
//選中狀態切換
checkBox.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (buttonView.isPressed()) {
//將低於此級別的都設置為未選中
for (int i = level; i < positions.length; i++) {
positions[i] = -1;
}
if (isChecked) {
//沒選中的情況下,才設置為選中
//當前級別存下
positions[level] = viewHolder.getAdapterPosition();
} else {
positions[level] = -1;
}
//通知父類選中或沒選中
onChildSelectListener.onSelect(viewHolder.getAdapterPosition(), isChecked);
}
});
//設置當前item點擊顯示或隱藏
LinearLayout layout = viewHolder.getView(R.id.layout_item_select_category);
layout.setOnClickListener(v -> {
//顯示就隱藏,隱藏就顯示
RecyclerView rvNextLevelCategory = viewHolder.getView(R.id.rv_select_category);
setChildState(viewHolder, foodCategoryTrees, rvNextLevelCategory.getVisibility() == View.VISIBLE);
});
}
/**
* 子類選中時的接口
*/
public interface OnChildSelectListener {
/**
* 選中時調用
*
* @param position 分類下標
* @param isChecked 選中狀態
*/
void onSelect(int position, boolean isChecked);
}
public void setOnChildSelectListener(OnChildSelectListener onChildSelectListener) {
this.onChildSelectListener = onChildSelectListener;
}
/**
* 設置子分類顯示狀態
*
* @param viewHolder
* @param foodCategoryTrees 父分類
*/
private void setChildState(@NotNull BaseViewHolder viewHolder, OrderCategoryBean.FoodCategoryTrees foodCategoryTrees, boolean notShowChild) {
RecyclerView rvNextLevelCategory = viewHolder.getView(R.id.rv_select_category);
if (foodCategoryTrees.getFoodCategoryTrees() != null) {
viewHolder.setGone(R.id.rv_select_category, notShowChild);
SelectCategoryAdapter selectCategoryAdapter = new SelectCategoryAdapter(foodCategoryTrees.getFoodCategoryTrees(), bgColor == Color.WHITE ? ContextCompat.getColor(getContext(), R.color.color_ccc) : getBgColor(bgColor), level + 1, positions);
rvNextLevelCategory.setAdapter(selectCategoryAdapter.setIndentation(indentation + "\u3000"));
selectCategoryAdapter.setOnChildSelectListener((position, isChecked) -> {
//子類被選中了,父類也要被選中
positions[level] = viewHolder.getAdapterPosition();
onChildSelectListener.onSelect(viewHolder.getAdapterPosition(), isChecked);
});
rvNextLevelCategory.setTag(selectCategoryAdapter);
} else {
viewHolder.setGone(R.id.rv_select_category, true);
}
}
private int getBgColor(int backgroundColor) {
int alpha = Color.alpha(backgroundColor) + 20;
int red = Color.red(backgroundColor) + 20;
int green = Color.green(backgroundColor) + 20;
int blue = Color.blue(backgroundColor) + 20;
if (alpha < 0 || alpha > 255) {
alpha = 0;
}
if (red < 0 || red > 255) {
red = 0;
}
if (green < 0 || green > 255) {
green = 0;
}
if (blue < 0 || blue > 255) {
blue = 0;
}
return Color.argb(alpha, red, green, blue);
}
}
package com.gingersoft.supply_chain.mvp.ui.adapter;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.widget.TextView;
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.utils.MoneyUtil;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.mvp.bean.WarehouseDetailsBean;
import com.gingersoft.supply_chain.mvp.ui.fragment.warehouse.WarehouseDetailsFragment;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
......@@ -17,27 +26,104 @@ import java.util.List;
* Time: 14:45
* Use:
*/
public class WareHousingDetailsAdapter extends BaseQuickAdapter<WarehouseDetailsBean.PurchaseWarehousingOrderDetailsContentsBean, BaseViewHolder> {
public class WareHousingDetailsAdapter extends BaseQuickAdapter<WarehouseDetailsBean, BaseViewHolder> {
/**
* 入庫還是出庫
* 入庫顯示+,出庫顯示-
*/
private int type;
/**
* 已消耗的背景色
*/
private Drawable allConsumeBg;
/**
* 已過期的背景
*/
private Drawable expiredBg;
/**
* 即將過期背景
*/
private Drawable willExpireSoonBg;
public WareHousingDetailsAdapter(@Nullable List<WarehouseDetailsBean.PurchaseWarehousingOrderDetailsContentsBean> data) {
public WareHousingDetailsAdapter(Context context, @Nullable List<WarehouseDetailsBean> data, int type) {
super(R.layout.item_warehouse_details, data);
this.type = type;
allConsumeBg = ContextCompat.getDrawable(context, R.drawable.shape_oval_48);
expiredBg = ContextCompat.getDrawable(context, R.drawable.shape_oval_red_wine);
willExpireSoonBg = ContextCompat.getDrawable(context, R.drawable.shape_oval_bright_orange);
}
@Override
protected void convert(@NotNull BaseViewHolder viewHolder, WarehouseDetailsBean.PurchaseWarehousingOrderDetailsContentsBean purchaseWarehousingOrderDetailsContentsBean) {
protected void convert(@NotNull BaseViewHolder viewHolder, WarehouseDetailsBean purchaseWarehousingOrderDetailsContentsBean) {
//食品名
viewHolder.setText(R.id.tv_warehouse_details_food_name, purchaseWarehousingOrderDetailsContentsBean.getName());
//入庫單位
viewHolder.setText(R.id.tv_warehouse_details_food_unit, "單位");
viewHolder.setText(R.id.tv_warehouse_details_food_unit, purchaseWarehousingOrderDetailsContentsBean.getUnitName());
//入庫食品數量
viewHolder.setText(R.id.tv_warehouse_details_food_num, String.format(getContext().getString(R.string.str_format_positive), purchaseWarehousingOrderDetailsContentsBean.getFoodQuantity()));
// if (purchaseWarehousingOrderDetailsContentsBean.getFoodQuantity() > 0) {
if (type == WarehouseDetailsFragment.WAREHOUSE_TYPE) {
// 入庫,顯示+
if (purchaseWarehousingOrderDetailsContentsBean.getFoodQuantity() >= 0) {
//如果大於0,前面顯示+號
viewHolder.setText(R.id.tv_warehouse_details_food_num, String.format(getContext().getString(R.string.str_format_positive), MoneyUtil.formatDouble(purchaseWarehousingOrderDetailsContentsBean.getFoodQuantity())));
} else {
//小於0,直接顯示負數
viewHolder.setText(R.id.tv_warehouse_details_food_num, String.valueOf(purchaseWarehousingOrderDetailsContentsBean.getFoodQuantity()));
}
viewHolder.setGone(R.id.tv_warehouse_time_text, false);
viewHolder.setText(R.id.tv_warehouse_order_time_text, "下單日期:");
//入庫日期
viewHolder.setText(R.id.tv_warehouse_details_time, purchaseWarehousingOrderDetailsContentsBean.getWarehousingTime());
viewHolder.setGone(R.id.tv_warehouse_details_time, false);
} else {
//出庫,顯示-
if (purchaseWarehousingOrderDetailsContentsBean.getFoodQuantity() >= 0) {
//如果大於0,前面顯示-號
viewHolder.setText(R.id.tv_warehouse_details_food_num, String.format(getContext().getString(R.string.str_format_less), MoneyUtil.formatDouble(purchaseWarehousingOrderDetailsContentsBean.getFoodQuantity())));
} else {
//小於0,顯示正數,負負得正
viewHolder.setText(R.id.tv_warehouse_details_food_num, String.format(getContext().getString(R.string.str_format_positive), MoneyUtil.formatDouble(Math.abs(purchaseWarehousingOrderDetailsContentsBean.getFoodQuantity()))));
}
// 入庫顯示消耗日期,不顯示入庫日期
viewHolder.setGone(R.id.tv_warehouse_time_text, true);
//消耗日期
viewHolder.setText(R.id.tv_warehouse_order_time_text, "消耗日期:");
viewHolder.setGone(R.id.tv_warehouse_details_time, true);
}
//下單時間
viewHolder.setText(R.id.tv_warehouse_details_order_time, "下單時間");
viewHolder.setText(R.id.tv_warehouse_details_order_time, purchaseWarehousingOrderDetailsContentsBean.getPurchaseTime());
//供應商
viewHolder.setText(R.id.tv_warehouse_details_supplier, purchaseWarehousingOrderDetailsContentsBean.getName());
//入庫日期
viewHolder.setText(R.id.tv_warehouse_details_time, "入庫日期");
viewHolder.setText(R.id.tv_warehouse_details_supplier, purchaseWarehousingOrderDetailsContentsBean.getSupplierName());
//入庫來源
viewHolder.setText(R.id.tv_warehouse_details_reason, purchaseWarehousingOrderDetailsContentsBean.getPurchase());
//設置狀態
TextView tvState = viewHolder.getView(R.id.tv_warehouse_state);
tvState.setVisibility(View.VISIBLE);
if (purchaseWarehousingOrderDetailsContentsBean.getConsumeStatus() == WarehouseDetailsBean.WAREHOUSE_STATE_ALL_CONSUMED) {
//全部消耗了
tvState.setBackground(allConsumeBg);
tvState.setText("庫存已使用");
} else {
//未消耗或消耗部分的
if (purchaseWarehousingOrderDetailsContentsBean.getDistanceExpiresTime() >= 0) {
//即將過期天數大於等於0
if (purchaseWarehousingOrderDetailsContentsBean.getWarningDays() > purchaseWarehousingOrderDetailsContentsBean.getDistanceExpiresTime()) {
//在預警天數內
//顯示即將過期
tvState.setBackground(willExpireSoonBg);
tvState.setText("即将過期:" + purchaseWarehousingOrderDetailsContentsBean.getDistanceExpiresTime() + "日");
} else {
tvState.setVisibility(View.GONE);
}
} else {
//天數為負,則是已過期
tvState.setBackground(expiredBg);
tvState.setText("已過期:" + Math.abs(purchaseWarehousingOrderDetailsContentsBean.getDistanceExpiresTime()) + "日");
}
}
}
public void setType(int type) {
this.type = type;
}
}
......@@ -34,9 +34,9 @@ public class WarehousingQueryAdapter extends BaseQuickAdapter<WareHouseListBean.
@Override
protected void convert(@NotNull BaseViewHolder viewHolder, WareHouseListBean.WareHousingDataBean.PurchaseWarehousingOrderDetailsVOSBean item) {
viewHolder.setText(R.id.tv_warehouse_item_ingredients_name, item.getName());
viewHolder.setText(R.id.tv_warehouse_item_ingredients_species, item.getCateName());
viewHolder.setText(R.id.tv_warehouse_item_supplier, item.getSupplierName());
viewHolder.setText(R.id.tv_warehouse_item_unit, item.getBasicUnitName());
viewHolder.setText(R.id.tv_warehouse_item_ingredients_species, item.getFoodCategoryName());
// viewHolder.setText(R.id.tv_warehouse_item_supplier, item.getSupplierName());
viewHolder.setText(R.id.tv_warehouse_item_unit, item.getUnitName());
viewHolder.setText(R.id.tv_warehouse_item_unit_price, item.getFoodPrice() + "");
viewHolder.setText(R.id.tv_warehouse_item_inventory_quantity, item.getFoodNum() + "");
viewHolder.setText(R.id.tv_warehouse_item_total_amount, item.getFoodAmount() + "");
......
......@@ -4,11 +4,15 @@ import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.gingersoft.gsa.cloud.common.BuildConfig;
import com.gingersoft.gsa.cloud.common.utils.other.SPUtils;
import com.gingersoft.gsa.cloud.database.bean.Function;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.R2;
......@@ -28,8 +32,10 @@ import com.gingersoft.supply_chain.mvp.ui.fragment.food.FoodIngredientsFragment;
import com.gingersoft.supply_chain.mvp.ui.fragment.warehouse.WareHouseListFragment;
import com.jess.arms.di.component.AppComponent;
import com.qmuiteam.qmui.widget.QMUITopBar;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import static com.gingersoft.supply_chain.mvp.ui.fragment.food.FoodIngredientsFragment.FOOD_INGREDIENTS;
......@@ -92,6 +98,9 @@ public class FunctionListFragment extends BaseSupplyChainFragment<FunctionListPr
List<Function> storage = new ArrayList<>();
storage.add(new Function("庫存查詢", R.drawable.ic_purchase_order));
if (BuildConfig.DEBUG) {
storage.add(new Function("切換環境", R.drawable.ic_seekbar_btn));
}
purchaseFunctionBeans.add(new PurchaseFunctionBean("庫存管理", storage));
PurchaseFunctionAdapter purchaseFunctionAdapter = new PurchaseFunctionAdapter(mContext, purchaseFunctionBeans);
......@@ -120,6 +129,16 @@ public class FunctionListFragment extends BaseSupplyChainFragment<FunctionListPr
case "庫存查詢":
start(WareHouseListFragment.newInstance());
break;
case "切換環境":
int format = (int) SPUtils.get("isFormal", 3);
if (format == 3) {
showMessage("已切換到測試環境,重啟生效");
SPUtils.put("isFormal", 1);
} else {
showMessage("已切換到本地環境,重啟生效");
SPUtils.put("isFormal", 3);
}
break;
default:
break;
......
package com.gingersoft.supply_chain.mvp.ui.fragment.category;
import android.app.Dialog;
import android.os.Bundle;
import android.text.InputFilter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
......@@ -17,34 +15,22 @@ import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.gingersoft.gsa.cloud.common.loadsir.EmptyCallback;
import com.gingersoft.gsa.cloud.common.loadsir.ErrorCallback;
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.toast.ToastUtils;
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.gsa.cloud.ui.utils.DialogUtils;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.R2;
import com.gingersoft.supply_chain.di.component.DaggerCategoryComponent;
import com.gingersoft.supply_chain.mvp.bean.FoodCategoryResultBean;
import com.gingersoft.supply_chain.mvp.bean.OrderCategoryBean;
import com.gingersoft.supply_chain.mvp.content.Constant;
import com.gingersoft.supply_chain.mvp.contract.CategoryContract;
import com.gingersoft.supply_chain.mvp.presenter.CategoryPresenter;
import com.gingersoft.supply_chain.mvp.ui.adapter.SecondCategoryAdapter;
import com.gingersoft.supply_chain.mvp.ui.adapter.CategoryAdapter;
import com.gingersoft.supply_chain.mvp.ui.adapter.FoodCategoryAdapter;
import com.gingersoft.supply_chain.mvp.ui.fragment.BaseSupplyChainFragment;
import com.gingersoft.supply_chain.mvp.ui.widget.CategoryPopup;
import com.jess.arms.base.App;
import com.jess.arms.di.component.AppComponent;
import com.kingja.loadsir.callback.Callback;
import com.kingja.loadsir.core.LoadSir;
import com.lxj.xpopup.XPopup;
import com.lxj.xpopup.enums.PopupPosition;
import com.lxj.xpopup.interfaces.OnCancelListener;
import com.lxj.xpopup.interfaces.OnConfirmListener;
import com.qmuiteam.qmui.alpha.QMUIAlphaButton;
import com.qmuiteam.qmui.alpha.QMUIAlphaTextView;
import com.qmuiteam.qmui.widget.QMUITopBar;
......@@ -84,22 +70,19 @@ public class CategoryFragment extends BaseSupplyChainFragment<CategoryPresenter>
CardView cardSecondCategory;
@BindView(R2.id.tv_new_third_category)
QMUIAlphaTextView addThirdCategory;
@BindView(R2.id.tv_new_second_category)
QMUIAlphaTextView addSecondCategory;
@BindView(R2.id.layout_category)
LinearLayout layoutCategory;
/**
* 是否顯示刪除
*/
private boolean showDelete = false;
/**
* 當前選中的是幾級分類
*/
private int currentLevel;
/**
* 當前等級分類的下標
*/
private int currentLevelPosition;
// private int currentLevelPosition;
public static CategoryFragment newInstance() {
CategoryFragment fragment = new CategoryFragment();
return fragment;
......@@ -122,10 +105,9 @@ public class CategoryFragment extends BaseSupplyChainFragment<CategoryPresenter>
@Override
public void initData(@Nullable Bundle savedInstanceState) {
loadService = LoadSir.getDefault().register(layoutCategory, (Callback.OnReloadListener) v -> mPresenter.getFoodCategoryList("", 0, mPresenter.primaryCategoryTag));
// loadService = LoadSir.getDefault().register(layoutCategory, (Callback.OnReloadListener) v -> mPresenter.getCategoryTrees());
initTopBar();
//先獲取一級分類
mPresenter.getFoodCategoryList("", 0, mPresenter.primaryCategoryTag);
mPresenter.getCategoryTrees();
}
private void initTopBar() {
......@@ -138,57 +120,42 @@ public class CategoryFragment extends BaseSupplyChainFragment<CategoryPresenter>
* 右上角編輯分類
*/
private void editCategory() {
String categoryName = null;
int categoryId = 0;
int parentId = 0;
OrderCategoryBean.FoodCategoryTrees foodCategoryTrees;
int position;
if (currentLevel == mPresenter.primaryCategoryTag) {
//如果是修改一級分類,拿到當前選中的分類的名稱,父級id,分類id
if (baseCategoryAdapter != null) {
List<CategoryBean> data = baseCategoryAdapter.getData();
if (data.size() > currentLevelPosition) {
categoryName = data.get(currentLevelPosition).getCategoryName();
categoryId = data.get(currentLevelPosition).getId();
}
}
foodCategoryTrees = getCategoryInfo(categoryAdapter);
position = categoryAdapter.getSelectIndex();
} else if (currentLevel == mPresenter.secondCategoryTag) {
//如果是修改二級分類,拿到當前選中的分類的名稱,父級id,分類id
if (secondCategoryAdapter != null) {
List<FoodCategoryResultBean.DataBean.FoodCategoryBean> secondData = secondCategoryAdapter.getData();
if (secondData.size() > currentLevelPosition) {
categoryName = secondData.get(currentLevelPosition).getName();
categoryId = secondData.get(currentLevelPosition).getId();
parentId = secondData.get(currentLevelPosition).getParentId();
}
}
foodCategoryTrees = getCategoryInfo(secondCategoryAdapter);
position = secondCategoryAdapter.getSelectIndex();
} else if (currentLevel == mPresenter.thirdCategoryTag) {
//如果是修改三級分類,拿到當前選中的分類的名稱,父級id,分類id
if (secondCategoryAdapter != null) {
List<FoodCategoryResultBean.DataBean.FoodCategoryBean> thirdData = thirdCategoryAdapter.getData();
if (thirdData.size() > currentLevelPosition) {
categoryName = thirdData.get(currentLevelPosition).getName();
categoryId = thirdData.get(currentLevelPosition).getId();
parentId = thirdData.get(currentLevelPosition).getParentId();
}
}
foodCategoryTrees = getCategoryInfo(thirdCategoryAdapter);
position = thirdCategoryAdapter.getSelectIndex();
} else {
showMessage("請選擇分類");
showMessage("請重新選擇分類");
return;
}
if (categoryId == 0) {
if (foodCategoryTrees == null) {
showMessage("請重新選擇分類");
return;
}
String finalCategoryName = categoryName;
int finalCategoryId = categoryId;
int finalParentId = parentId;
showEditCategoryPop(foodCategoryTrees, position);
}
CategoryPopup categoryPopup = new CategoryPopup(mContext, "修改", "類別名稱", "请修改當前類別名稱", categoryName, true);
/**
* 顯示編輯分類彈窗
*
* @param foodCategoryTrees 分類信息
* @param position 編輯的分類下標,編輯之後用於刷新
*/
private void showEditCategoryPop(OrderCategoryBean.FoodCategoryTrees foodCategoryTrees, int position) {
CategoryPopup categoryPopup = new CategoryPopup(mContext, "修改", "類別名稱", "请修改當前類別名稱", foodCategoryTrees.getName(), true);
categoryPopup.setOnDeleteListener(v -> {
//刪除分類
AppDialog.getInstance().showWaringDialog(mContext, "是否確認刪除該類別【" + finalCategoryName + "】,子類將一同刪除?", (view, dialog) -> {
AppDialog.getInstance().showWaringDialog(mContext, String.format(getString(R.string.str_delete_category_tip), foodCategoryTrees.getName()), (view, dialog) -> {
categoryPopup.dismiss();
dialog.dismiss();
mPresenter.deleteFoodCategory(finalCategoryId, currentLevel, currentLevelPosition);
mPresenter.deleteFoodCategory(foodCategoryTrees, currentLevel, position);
});
});
new XPopup.Builder(getContext())
......@@ -198,30 +165,33 @@ public class CategoryFragment extends BaseSupplyChainFragment<CategoryPresenter>
showMessage("請輸入分類名稱");
return;
}
mPresenter.updateFoodCategory(mPresenter.toFoodCategoryBean(finalParentId, finalCategoryName, finalCategoryId), currentLevel, currentLevelPosition);
mPresenter.updateFoodCategory(mPresenter.toFoodCategoryBean(foodCategoryTrees.getParentId(), categoryPopup.getEditText().getText().toString(), foodCategoryTrees.getId()), currentLevel, position);
}, () -> {
}))
.show();
}
/**
* 修改刪除按鈕的顯示狀態
* 獲取當前分類信息
*
* @param categoryAdapter 分類adapter
* @return 分類信息
*/
private void updateDeleteBtnState() {
if (baseCategoryAdapter != null) {
baseCategoryAdapter.setShowDelete(showDelete);
private OrderCategoryBean.FoodCategoryTrees getCategoryInfo(FoodCategoryAdapter categoryAdapter) {
if (categoryAdapter == null || categoryAdapter.getSelectIndex() == -1) {
showMessage("请选择分类");
return null;
}
if (secondCategoryAdapter != null) {
secondCategoryAdapter.setShowDelete(showDelete);
}
if (thirdCategoryAdapter != null) {
thirdCategoryAdapter.setShowDelete(showDelete);
if (categoryAdapter.getItemCount() > categoryAdapter.getSelectIndex()) {
return categoryAdapter.getItem(categoryAdapter.getSelectIndex());
}
return null;
}
@OnClick({R2.id.btn_category_search, R2.id.tv_new_second_category, R2.id.btn_add_first_category, R2.id.tv_new_third_category})
@Override
public void onClick(View v) {
//新增一級、二級、三級分類
int viewId = v.getId();
String parentCategoryName = null;
int level = 0;
......@@ -234,26 +204,30 @@ public class CategoryFragment extends BaseSupplyChainFragment<CategoryPresenter>
level = mPresenter.primaryCategoryTag;
} else if (viewId == R.id.tv_new_second_category) {
//添加二級分類
if (baseCategoryAdapter != null) {
List<CategoryBean> data = baseCategoryAdapter.getData();
if (data.size() > baseCategoryAdapter.getSelectedIndex()) {
CategoryBean categoryBean = data.get(baseCategoryAdapter.getSelectedIndex());
parentCategoryName = categoryBean.getCategoryName();
parentId = categoryBean.getId();
level = mPresenter.secondCategoryTag;
}
}
//拿到選中的一級分類信息
OrderCategoryBean.FoodCategoryTrees foodCategoryTrees = categoryAdapter.getItem(categoryAdapter.getSelectIndex());
parentCategoryName = foodCategoryTrees.getName();
parentId = foodCategoryTrees.getId();
level = mPresenter.secondCategoryTag;
} else if (viewId == R.id.tv_new_third_category) {
//添加三級分類
if (secondCategoryAdapter != null) {
FoodCategoryResultBean.DataBean.FoodCategoryBean selectData = secondCategoryAdapter.getSelectData();
parentCategoryName = selectData.getName();
parentId = selectData.getId();
level = mPresenter.thirdCategoryTag;
}
//拿到選中的二級分類信息
OrderCategoryBean.FoodCategoryTrees item = secondCategoryAdapter.getItem(secondCategoryAdapter.getSelectIndex());
parentCategoryName = item.getName();
parentId = item.getId();
level = mPresenter.thirdCategoryTag;
}
int finalParentId = parentId;
int finalLevel = level;
showAddCategory(parentCategoryName, parentId, level);
}
/**
* 顯示添加分類彈窗
*
* @param parentCategoryName 父分類名稱
* @param parentId 父分類id
* @param level 添加的是幾級分類
*/
private void showAddCategory(String parentCategoryName, int parentId, int level) {
if (TextUtil.isNotEmptyOrNullOrUndefined(parentCategoryName)) {
CategoryPopup categoryPopup = new CategoryPopup(mContext, parentCategoryName, "類別名稱", "请輸入類別名稱", null, false);
new XPopup.Builder(getContext())
......@@ -264,7 +238,7 @@ public class CategoryFragment extends BaseSupplyChainFragment<CategoryPresenter>
return;
}
//創建分類
mPresenter.addCategory(finalParentId, categoryPopup.getEditText().getText().toString(), finalLevel);
mPresenter.addCategory(parentId, categoryPopup.getEditText().getText().toString(), level);
}, () -> {
}))
.show();
......@@ -274,205 +248,282 @@ public class CategoryFragment extends BaseSupplyChainFragment<CategoryPresenter>
}
//一級
private BaseCategoryAdapter baseCategoryAdapter;
private FoodCategoryAdapter categoryAdapter;
//二級
private SecondCategoryAdapter secondCategoryAdapter;
private FoodCategoryAdapter secondCategoryAdapter;
//三級
private SecondCategoryAdapter thirdCategoryAdapter;
private FoodCategoryAdapter thirdCategoryAdapter;
private void setCurrentInfo(int level, int position) {
currentLevelPosition = position;
/**
* 設置了到時候用於編輯或刪除
*
* @param level 當前選中的是第幾級分類
*/
private void setCurrentInfo(int level) {
currentLevel = level;
}
@Override
public void loadCategoryInfo(List<FoodCategoryResultBean.DataBean.FoodCategoryBean> list, int hierarchy) {
loadService.showSuccess();
if (hierarchy == mPresenter.primaryCategoryTag) {
List<CategoryBean> data = new ArrayList<>();
if (list != null) {
for (int i = 0; i < list.size(); i++) {
data.add(new CategoryBean(list.get(i).getId(), list.get(i).getName()));
}
if (data.size() > 0) {
mPresenter.getCategoryBeansById(data.get(0).getId(), mPresenter.secondCategoryTag);
if (baseCategoryAdapter != null) {
baseCategoryAdapter.setSelectedIndex(0);
}
} else {
hideLoading();
public void loadCategoryInfo(List<OrderCategoryBean.FoodCategoryTrees> data) {
//加載一級分類
if (categoryAdapter == null) {
categoryAdapter = new FoodCategoryAdapter(R.layout.item_first_category, data)
.setUnCheckedBg(ContextCompat.getDrawable(mContext, R.color.trans))
.setCheckedBg(ContextCompat.getDrawable(mContext, R.drawable.shape_left_radio_shadow))
.setUnCheckedTextColor(ContextCompat.getColor(mContext, R.color.color_3c))
.setCheckedTextColor(ContextCompat.getColor(mContext, R.color.theme_color));
rvFirstCategory.setAdapter(categoryAdapter);
//設置當前選中一級分類
setCurrentInfo(mPresenter.primaryCategoryTag);
categoryAdapter.setOnItemClickListener((adapter, view, position) -> {
//分類點擊事件
//設置當前選中一級分類。一級分類的第position個分類
setCurrentInfo(mPresenter.primaryCategoryTag);
//修改默認選中
categoryAdapter.setSelectIndex(position);
//刷新二級分類
loadSecondCategory(categoryAdapter.getItem(position).getFoodCategoryTrees());
});
} else {
categoryAdapter.setNewInstance(data);
setCurrentInfo(mPresenter.primaryCategoryTag);
}
if (categoryAdapter.getItemCount() > 0) {
//如果有一級分類,默認顯示第一個一級分類下的二級分類
categoryAdapter.setSelectIndex(0);
loadSecondCategory(categoryAdapter.getItem(0).getFoodCategoryTrees());
//顯示新增二級分類
addSecondCategory.setVisibility(View.VISIBLE);
} else {
addSecondCategory.setVisibility(View.GONE);
categoryAdapter.setSelectIndex(-1);
}
}
/**
* 加載二級分類
*
* @param data 分類數據
*/
@Override
public void loadSecondCategory(List<OrderCategoryBean.FoodCategoryTrees> data) {
//加載二級時,並沒有默認選中二級,所以這時候三級不展示
//顯示新增二級分類按鈕
addSecondCategory.setVisibility(View.VISIBLE);
//隱藏新增三級分類按鈕
addThirdCategory.setVisibility(View.GONE);
//隱藏三級分類
if (thirdCategoryAdapter != null) {
thirdCategoryAdapter.setNewInstance(null);
} else {
rvThirdCategory.setVisibility(View.GONE);
}
//判斷是否需要給二級分類添加一個"新增類別"按鈕
addNewAddBtn(data);
//加載二級分類adapter
if (secondCategoryAdapter == null) {
secondCategoryAdapter = new FoodCategoryAdapter(data);
//因為第一個數據是空的,用來顯示按鈕,所以下標跳過0,默認選中1
//設置adapter的信息
secondCategoryAdapter.setCheckedBg(ContextCompat.getDrawable(mContext, R.drawable.shape_app_btn_small_radius))
.setUnCheckedBg(ContextCompat.getDrawable(mContext, R.drawable.shape_five_radius_gray_stroke))
.setCheckedTextColor(ContextCompat.getColor(mContext, R.color.white))
.setUnCheckedTextColor(ContextCompat.getColor(mContext, R.color.color_3c))
.setOnItemClickListener((adapter, view, position) -> {
//二級分類點擊事件,設置當前數據為二級分類
setCurrentInfo(mPresenter.secondCategoryTag);
secondCategoryAdapter.setSelectIndex(position);
//加載三級分類
loadThirdCategory(secondCategoryAdapter.getItem(position).getFoodCategoryTrees());
});
rvSecondCategory.setLayoutManager(new GridLayoutManager(mContext, 3) {
@Override
public boolean canScrollHorizontally() {
return true;
}
} else {
mPresenter.getCategoryBeansById(-1, mPresenter.secondCategoryTag);
}
if (baseCategoryAdapter == null) {
baseCategoryAdapter = new BaseCategoryAdapter(data, mContext)
.setUnSelectColor(ContextCompat.getColor(mContext, R.color.color_3c))
.setSelectColor(ContextCompat.getColor(mContext, R.color.theme_color));
setCurrentInfo(mPresenter.primaryCategoryTag, 0);
});
rvSecondCategory.setAdapter(secondCategoryAdapter);
} else {
//重置選中
secondCategoryAdapter.setSelectIndex(-1);
secondCategoryAdapter.setNewInstance(data);
}
}
rvFirstCategory.setAdapter(baseCategoryAdapter);
baseCategoryAdapter.setOnItemClickListener((adapter, view, position) -> {
setCurrentInfo(mPresenter.primaryCategoryTag, position);
/**
* 加載三級分類
*
* @param data
*/
@Override
public void loadThirdCategory(List<OrderCategoryBean.FoodCategoryTrees> data) {
//顯示新增三級分類按鈕
addThirdCategory.setVisibility(View.VISIBLE);
rvThirdCategory.setVisibility(View.VISIBLE);
//第一個位置是新增類別按鈕
addNewAddBtn(data);
if (thirdCategoryAdapter == null) {
thirdCategoryAdapter = new FoodCategoryAdapter(data);
thirdCategoryAdapter.setSelectIndex(-1)
.setCheckedBg(ContextCompat.getDrawable(mContext, R.drawable.shape_color_theme_stoke_fifteen_corners))
.setUnCheckedBg(ContextCompat.getDrawable(mContext, R.drawable.shape_color_da_stoke_fifteen_corners))
.setCheckedTextColor(ContextCompat.getColor(mContext, R.color.white))
.setUnCheckedTextColor(ContextCompat.getColor(mContext, R.color.color_68))
.setOnItemClickListener((adapter, view, position) -> {
setCurrentInfo(mPresenter.thirdCategoryTag);
thirdCategoryAdapter.setSelectIndex(position);
});
rvThirdCategory.setLayoutManager(new GridLayoutManager(mContext, 3));
rvThirdCategory.setAdapter(thirdCategoryAdapter);
} else {
//重置選中
thirdCategoryAdapter.setSelectIndex(-1);
thirdCategoryAdapter.setNewInstance(data);
}
}
baseCategoryAdapter.setSelectedIndex(position);
List<CategoryBean> categoryBeans = baseCategoryAdapter.getData();
mPresenter.getCategoryBeansById(categoryBeans.get(position).getId(), mPresenter.secondCategoryTag);
});
baseCategoryAdapter.setOnItemChildClickListener((adapter, view, position) -> {
if (view.getId() == R.id.iv_category_delete) {
//刪除該分類
CategoryBean categoryBean = baseCategoryAdapter.getData().get(position);
new AppDialog().showWaringDialog(mContext, "是否確認刪除該類別【" + categoryBean.getCategoryName() + "】,子類將一同刪除?", (view1, dialog) -> {
mPresenter.deleteFoodCategory(categoryBean.getId(), mPresenter.primaryCategoryTag, position);
dialog.dismiss();
});
}
});
} else {
baseCategoryAdapter.setList(data);
setCurrentInfo(mPresenter.primaryCategoryTag, 0);
}
/**
* 添加分類成功後的回調
*
* @param categoryTrees 分類信息
* @param hierarchy 新增的是第幾級分類
*/
@Override
public void addCategory(OrderCategoryBean.FoodCategoryTrees categoryTrees, int hierarchy) {
if (hierarchy == mPresenter.primaryCategoryTag) {
//添加到尾部
categoryAdapter.addData(categoryAdapter.getItemCount(), categoryTrees);
int clickIndex = categoryAdapter.getItemCount() - 1;
//滑動到尾部去
rvFirstCategory.scrollToPosition(clickIndex);
//設置為選中
categoryAdapter.setSelectIndex(clickIndex);
//調用點擊事件,刷新下面的二級分類
categoryAdapter.getOnItemClickListener().onItemClick(categoryAdapter, null, clickIndex);
} else if (hierarchy == mPresenter.secondCategoryTag) {
if (list == null || list.size() <= 0) {
addThirdCategory.setVisibility(View.GONE);
mPresenter.getCategoryBeansById(-1, mPresenter.thirdCategoryTag);
} else {
//因為第一個是按鈕,沒有id
addThirdCategory.setVisibility(View.VISIBLE);
mPresenter.getCategoryBeansById(list.get(1).getId(), mPresenter.thirdCategoryTag);
}
//二級分類
if (secondCategoryAdapter == null) {
secondCategoryAdapter = new SecondCategoryAdapter(list);
//因為第一個數據是空的,用來顯示按鈕,所以下標跳過0
secondCategoryAdapter.setSelectIndex(1);
setCurrentInfo(mPresenter.secondCategoryTag, 1);
secondCategoryAdapter.setCheckedBg(ContextCompat.getDrawable(mContext, R.drawable.shape_app_btn_small_radius))
.setUnCheckedBg(ContextCompat.getDrawable(mContext, R.drawable.shape_five_radius_gray_stroke))
.setCheckedTextColor(ContextCompat.getColor(mContext, R.color.white))
.setUnCheckedTextColor(ContextCompat.getColor(mContext, R.color.color_3c))
.setOnItemClickListener((adapter, view, position) -> {
setCurrentInfo(mPresenter.secondCategoryTag, position);
secondCategoryAdapter.setSelectIndex(position);
List<FoodCategoryResultBean.DataBean.FoodCategoryBean> categoryBeans = secondCategoryAdapter.getData();
mPresenter.getCategoryBeansById(categoryBeans.get(position).getId(), mPresenter.thirdCategoryTag);
});
addOnDelete(secondCategoryAdapter, "】,子類將一同刪除?", mPresenter.secondCategoryTag);
rvSecondCategory.setLayoutManager(new GridLayoutManager(mContext, 3) {
@Override
public boolean canScrollHorizontally() {
return true;
}
});
rvSecondCategory.setAdapter(secondCategoryAdapter);
} else {
setCurrentInfo(mPresenter.secondCategoryTag, 1);
secondCategoryAdapter.setSelectIndex(1);
secondCategoryAdapter.setList(list);
}
//如果是添加的二級分類,就要拿到當前的一級分類,給一級分類的子分類集合中添加分類
newCategory(categoryTrees, categoryAdapter);
} else if (hierarchy == mPresenter.thirdCategoryTag) {
hideLoading();
if (thirdCategoryAdapter == null) {
thirdCategoryAdapter = new SecondCategoryAdapter(list);
setCurrentInfo(mPresenter.thirdCategoryTag, 1);
thirdCategoryAdapter.setSelectIndex(1)
.setCheckedBg(ContextCompat.getDrawable(mContext, R.drawable.shape_color_theme_stoke_fifteen_corners))
.setUnCheckedBg(ContextCompat.getDrawable(mContext, R.drawable.shape_color_da_stoke_fifteen_corners))
.setCheckedTextColor(ContextCompat.getColor(mContext, R.color.white))
.setUnCheckedTextColor(ContextCompat.getColor(mContext, R.color.color_68))
.setOnItemClickListener((adapter, view, position) -> {
setCurrentInfo(mPresenter.thirdCategoryTag, position);
thirdCategoryAdapter.setSelectIndex(position);
});
addOnDelete(thirdCategoryAdapter, "】?", mPresenter.thirdCategoryTag);
rvThirdCategory.setLayoutManager(new GridLayoutManager(mContext, 3));
rvThirdCategory.setAdapter(thirdCategoryAdapter);
} else {
setCurrentInfo(mPresenter.thirdCategoryTag, 1);
thirdCategoryAdapter.setSelectIndex(1);
thirdCategoryAdapter.setList(list);
}
//如果是添加的二級分類,就要拿到當前的一級分類,給一級分類的子分類集合中添加分類
newCategory(categoryTrees, secondCategoryAdapter);
}
}
private void addOnDelete(SecondCategoryAdapter categoryAdapter, String s, int categoryLevel) {
categoryAdapter.setOnItemChildClickListener((adapter, view, position) -> {
if (view.getId() == R.id.iv_category_delete) {
//刪除該分類
new AppDialog().showWaringDialog(mContext, "是否確認刪除該類別【" + categoryAdapter.getData().get(position).getName() + s, (view1, dialog) -> {
mPresenter.deleteFoodCategory(categoryAdapter.getData().get(position).getId(), categoryLevel, position);
dialog.dismiss();
});
}
});
/**
* 新增分類
*
* @param categoryTrees 分類
* @param adapter 父分類adapter
*/
public void newCategory(OrderCategoryBean.FoodCategoryTrees categoryTrees, FoodCategoryAdapter adapter) {
OrderCategoryBean.FoodCategoryTrees item = adapter.getItem(adapter.getSelectIndex());
List<OrderCategoryBean.FoodCategoryTrees> foodCategoryTrees = item.getFoodCategoryTrees();
if (foodCategoryTrees == null) {
foodCategoryTrees = new ArrayList<>();
foodCategoryTrees.add(0, new OrderCategoryBean.FoodCategoryTrees(-1));
}
foodCategoryTrees.add(categoryTrees);
item.setFoodCategoryTrees(foodCategoryTrees);
//調用點擊事件,刷新下面的二級分類
OnItemClickListener onItemClickListener = adapter.getOnItemClickListener();
if (onItemClickListener != null) {
onItemClickListener.onItemClick(adapter, null, adapter.getSelectIndex());
}
}
/**
* @param type 操作類型:刪除或修改 Constant.DELETE Constant.UPDATE
* @param hierarchy 第幾級分類
* @param categoryName 分類名稱
* @param position 分類下標
*/
@Override
public void refreshInfo(int hierarchy, int position) {
showDelete = false;
updateDeleteBtnState();
if (hierarchy == mPresenter.primaryCategoryTag && baseCategoryAdapter != null) {
baseCategoryAdapter.removeAt(position);
if (baseCategoryAdapter.getItemCount() > 0) {
if (position - 1 < 0) {
position = 0;
public void updateCategory(int type, int hierarchy, String categoryName, int position) {
if (hierarchy == mPresenter.primaryCategoryTag && categoryAdapter != null) {
if (type == Constant.DELETE) {
//如果是刪除,就移除掉
categoryAdapter.removeAt(position);
if (categoryAdapter.getItemCount() > 0) {
// 總數量大於0,選中第0個
rvFirstCategory.scrollToPosition(0);
categoryAdapter.getOnItemClickListener().onItemClick(categoryAdapter, null, 0);
} else {
position -= 1;
//沒有一級分類了
//清除二級三級分類
secondCategoryAdapter.setList(null);
secondCategoryAdapter.setList(null);
addSecondCategory.setVisibility(View.GONE);
addThirdCategory.setVisibility(View.GONE);
}
baseCategoryAdapter.setSelectedIndex(position);
baseCategoryAdapter.getOnItemClickListener().onItemClick(baseCategoryAdapter, rvFirstCategory.getChildAt(position), position);
} else if (type == Constant.UPDATE) {
//修改了分類名稱,拿到對應數據刷新
OrderCategoryBean.FoodCategoryTrees item = categoryAdapter.getItem(position);
item.setName(categoryName);
categoryAdapter.notifyItemChanged(position);
}
} else if (hierarchy == mPresenter.secondCategoryTag && secondCategoryAdapter != null) {
notifyAdapter(position, secondCategoryAdapter);
updateChildCategory(secondCategoryAdapter, type, hierarchy, categoryName, position);
} else if (hierarchy == mPresenter.thirdCategoryTag && thirdCategoryAdapter != null) {
notifyAdapter(position, thirdCategoryAdapter);
updateChildCategory(thirdCategoryAdapter, type, hierarchy, categoryName, position);
}
}
@Override
public void loadCategoryFail() {
loadService.showCallback(EmptyCallback.class);
}
@Override
public void loadCategoryError() {
loadService.showCallback(ErrorCallback.class);
public void onError() {
// loadService.showCallback(ErrorCallback.class);
}
private void notifyAdapter(int position, SecondCategoryAdapter categoryAdapter) {
categoryAdapter.removeAt(position);
if (categoryAdapter.getItemCount() > 0) {
if (position - 1 < 1) {
position = 1;
/**
* 修改二級、三級分類
*
* @param adapter 適配器
* @param type 操作類型:刪除還是修改
* @param hierarchy 分類級別
* @param categoryName 分類名稱
* @param position 分類下標
*/
private void updateChildCategory(FoodCategoryAdapter adapter, int type, int hierarchy, String categoryName, int position) {
if (type == Constant.DELETE) {
adapter.removeAt(position);
if (hierarchy == mPresenter.secondCategoryTag) {
thirdCategoryAdapter.setNewInstance(null);
//如果是二級分類,還需要判斷如果分類數量為0時,就不顯示三級分類
if (secondCategoryAdapter.getItemCount() <= 1) {
thirdCategoryAdapter.setNewInstance(null);
addThirdCategory.setVisibility(View.GONE);
//切換選中一級
setCurrentInfo(mPresenter.primaryCategoryTag);
} else {
adapter.getOnItemClickListener().onItemClick(adapter, null, 1);
}
} else {
position -= 1;
//刪除的是三級,切換選中到二級
setCurrentInfo(mPresenter.secondCategoryTag);
}
categoryAdapter.setSelectIndex(position);
categoryAdapter.getOnItemClickListener().onItemClick(categoryAdapter, null, position);
} else if (type == Constant.UPDATE) {
//修改了分類名稱
OrderCategoryBean.FoodCategoryTrees item = adapter.getItem(position);
item.setName(categoryName);
adapter.notifyItemChanged(position);
}
}
@Override
public void onPause() {
super.onPause();
//獲取種類時,會連調幾次獲取下一級的接口,為了避免一直閃loading,不會關閉loading框,有時候會導致頁面關閉後還顯示loading
//所以在這裡處理一下
hideLoading();
}
@Override
public void onHiddenChanged(boolean hidden) {
super.onHiddenChanged(hidden);
if (hidden) {
//獲取種類時,會連調幾次獲取下一級的接口,為了避免一直閃loading,不會關閉loading框,有時候會導致頁面關閉後還顯示loading
//所以在這裡處理一下
hideLoading();
/**
* 添加新增按鈕
*/
private void addNewAddBtn(List<OrderCategoryBean.FoodCategoryTrees> data) {
if (data != null && data.size() > 0) {
if (data.get(0).getId() != -1) {
OrderCategoryBean.FoodCategoryTrees foodCategoryTrees = new OrderCategoryBean.FoodCategoryTrees();
foodCategoryTrees.setId(-1);
data.add(0, foodCategoryTrees);
}
} else {
data = new ArrayList<>();
OrderCategoryBean.FoodCategoryTrees foodCategoryTrees = new OrderCategoryBean.FoodCategoryTrees();
foodCategoryTrees.setId(-1);
data.add(0, foodCategoryTrees);
}
}
}
package com.gingersoft.supply_chain.mvp.ui.fragment.category;
import android.graphics.Color;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
......@@ -7,23 +8,19 @@ import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.ui.adapter.BaseRadioSectionAdapter;
import com.gingersoft.gsa.cloud.ui.bean.SectionCheckItem;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.R2;
import com.gingersoft.supply_chain.di.component.DaggerCategorySelectComponent;
import com.gingersoft.supply_chain.mvp.bean.OrderCategoryBean;
import com.gingersoft.supply_chain.mvp.contract.CategorySelectContract;
import com.gingersoft.supply_chain.mvp.presenter.CategorySelectPresenter;
import com.gingersoft.supply_chain.mvp.ui.adapter.SelectCategoryAdapter;
import com.gingersoft.supply_chain.mvp.ui.fragment.BaseSupplyChainFragment;
import com.jess.arms.di.component.AppComponent;
import com.qmuiteam.qmui.widget.QMUITopBar;
import com.qmuiteam.qmui.widget.section.QMUISection;
import com.qmuiteam.qmui.widget.section.QMUIStickySectionAdapter;
import com.qmuiteam.qmui.widget.section.QMUIStickySectionLayout;
import java.io.Serializable;
import java.util.ArrayList;
......@@ -32,8 +29,6 @@ import java.util.List;
import butterknife.BindView;
import butterknife.OnClick;
import static com.gingersoft.gsa.cloud.ui.adapter.BaseRadioSectionAdapter.SEPARATOR;
/**
* Description: 選擇食材類別
......@@ -52,21 +47,26 @@ public class CategorySelectFragment extends BaseSupplyChainFragment<CategorySele
@BindView(R2.id.food_ingredients_category_topbar)
QMUITopBar mTopBar;
@BindView(R2.id.food_ingredients_category_section_layout)
QMUIStickySectionLayout sectionLayout;
@BindView(R2.id.rv_food_select_category)
RecyclerView rvCategory;
private SelectCategoryAdapter selectCategoryAdapter;
private int[] categoryPosition;
/**
* 選中的分類數據key
*/
public final static String SELECT_CATEGORY_DATA_KEY = "categoryKey";
private final static String CATEGORY_NAME_KEY = "categoryNameKey";
/**
* 默認選中的分類
*/
private String categoryName;
public static CategorySelectFragment newInstance(List<String> categoryNames) {
public static CategorySelectFragment newInstance(String categoryName) {
CategorySelectFragment fragment = new CategorySelectFragment();
if (categoryNames != null && categoryNames.size() > 0) {
Bundle bundle = new Bundle();
bundle.putSerializable(CATEGORY_NAME_KEY, (Serializable) categoryNames);
fragment.setArguments(bundle);
}
Bundle bundle = new Bundle();
bundle.putString(CATEGORY_NAME_KEY, categoryName);
fragment.setArguments(bundle);
return fragment;
}
......@@ -92,7 +92,11 @@ public class CategorySelectFragment extends BaseSupplyChainFragment<CategorySele
@Override
public void initData(@Nullable Bundle savedInstanceState) {
initTopBar(mTopBar, "選擇分類");
mPresenter.getFoodCategoryList(null, 0, "0");
Bundle arguments = getArguments();
if (arguments != null) {
categoryName = arguments.getString(CATEGORY_NAME_KEY);
}
mPresenter.getCategoryTrees();
}
......@@ -104,131 +108,89 @@ public class CategorySelectFragment extends BaseSupplyChainFragment<CategorySele
killMyself();
} else if (viewId == R.id.btn_food_ingredients_confirm) {
//確認
if (baseRadioSectionAdapter != null) {
if (selectCategoryAdapter != null) {
Bundle bundle = new Bundle();
List<QMUISection<SectionCheckItem, SectionCheckItem>> currentData = baseRadioSectionAdapter.getCurrentData();
List<SectionCheckItem> putSectionCheckItems = new ArrayList<>();
for (int i = 0; i < currentData.size(); i++) {
if (currentData.get(i).getHeader().isChecked()) {
putSectionCheckItems.add(currentData.get(i).getHeader());
if (currentData.get(i).getItemList() != null) {
getCheckInfo(currentData.get(i).getItemList(), putSectionCheckItems);
}
break;
}
}
bundle.putSerializable(SELECT_CATEGORY_DATA_KEY, (Serializable) putSectionCheckItems);
List<OrderCategoryBean.FoodCategoryTrees> selectCategory = new ArrayList<>();
List<OrderCategoryBean.FoodCategoryTrees> foodCategoryTrees = selectCategoryAdapter.getData();
getSelectCate(selectCategory, foodCategoryTrees, 0);
bundle.putSerializable(SELECT_CATEGORY_DATA_KEY, (Serializable) selectCategory);
setFragmentResult(SELECT_FOOD_CATEGORY_RESULT_CODE, bundle);
killMyself();
}
}
}
private void getCheckInfo(List<SectionCheckItem> sectionCheckItems, List<SectionCheckItem> putSectionCheckItems) {
for (SectionCheckItem sectionCheckItem : sectionCheckItems) {
if (sectionCheckItem.isChecked()) {
putSectionCheckItems.add(sectionCheckItem);
if (sectionCheckItem.getSectionCheckItems() != null) {
getCheckInfo(sectionCheckItem.getSectionCheckItems(), putSectionCheckItems);
}
break;
/**
* 獲取選中的分類集合
*
* @param selectCategory 用於裝選中的分類數據集合
* @param foodCategoryTrees 分類樹
* @param level 當前是第幾級分類
*/
private void getSelectCate(List<OrderCategoryBean.FoodCategoryTrees> selectCategory, List<OrderCategoryBean.FoodCategoryTrees> foodCategoryTrees, int level) {
if (foodCategoryTrees == null) {
return;
}
if (level < categoryPosition.length) {
int position = categoryPosition[level];
if (position != -1 && position < foodCategoryTrees.size()) {
OrderCategoryBean.FoodCategoryTrees category = foodCategoryTrees.get(position);
selectCategory.add(category);
getSelectCate(selectCategory, category.getFoodCategoryTrees(), level + 1);
}
}
}
private BaseRadioSectionAdapter baseRadioSectionAdapter;
private String lastCheckPositions = "0";
@Override
public void loadFoodCategory(List<QMUISection<SectionCheckItem, SectionCheckItem>> sections) {
if (baseRadioSectionAdapter == null) {
baseRadioSectionAdapter = new BaseRadioSectionAdapter(mContext);
sections.get(0).getHeader().setChecked(true);
baseRadioSectionAdapter.setData(sections);
sectionLayout.setLayoutManager(new LinearLayoutManager(getContext()) {
@Override
public RecyclerView.LayoutParams generateDefaultLayoutParams() {
return new RecyclerView.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
}
});
sectionLayout.setAdapter(baseRadioSectionAdapter);
} else {
setCheckState(sections, lastCheckPositions, true);
baseRadioSectionAdapter.setData(sections);
private void getCategoryIndexByName(String name, List<OrderCategoryBean.FoodCategoryTrees> foodCategoryTrees) {
if (foodCategoryTrees == null) {
return;
}
//設置默認選中
baseRadioSectionAdapter.setOnCheckedChangeListener((positions, isChecked, section) -> {
//獲得上一次選中的數據
if (section != null) {
positions = section.getSort() + "";
}
if (TextUtil.isNotEmptyOrNullOrUndefined(positions)) {
//將上次的設為未選中
setCheckState(sections, lastCheckPositions, false);
setCheckState(sections, positions, isChecked);
refreshAdapter();
lastCheckPositions = positions;
} else if (TextUtil.isNotEmptyOrNullOrUndefined(lastCheckPositions) && isChecked) {
//將上次選中的設置為未選中
setCheckState(sections, lastCheckPositions, false);
}
});
baseRadioSectionAdapter.setOnRefreshListener(this::refreshAdapter);
baseRadioSectionAdapter.setCallback(new QMUIStickySectionAdapter.Callback<SectionCheckItem, SectionCheckItem>() {
@Override
public void loadMore(QMUISection<SectionCheckItem, SectionCheckItem> section, boolean loadMoreBefore) {
}
@Override
public void onItemClick(QMUIStickySectionAdapter.ViewHolder holder, int position) {
if (position < sections.size() && sections.get(position).getItemCount() <= 0) {
if (holder instanceof BaseRadioSectionAdapter.HeaderViewHolder) {
BaseRadioSectionAdapter.HeaderViewHolder viewHolder = (BaseRadioSectionAdapter.HeaderViewHolder) holder;
int index = viewHolder.getSectionCheckItemItem(position);
mPresenter.getFoodCategoryList(null, sections.get(index).getHeader().getId(), index + "");
for (int i = 0; i < foodCategoryTrees.size(); i++) {
OrderCategoryBean.FoodCategoryTrees firstCategory = foodCategoryTrees.get(i);
List<OrderCategoryBean.FoodCategoryTrees> secondCategoryTrees = firstCategory.getFoodCategoryTrees();
if (name.equals(firstCategory.getName())) {
//如果分類的名字一樣,說明是這個分類
categoryPosition = new int[]{i, -1, -1};
return;
} else if (secondCategoryTrees != null) {
//如果不是這個分類,遍歷這個分類下的分類
for (int j = 0; j < secondCategoryTrees.size(); j++) {
OrderCategoryBean.FoodCategoryTrees secondCategory = secondCategoryTrees.get(j);
List<OrderCategoryBean.FoodCategoryTrees> thirdCategoryTress = secondCategory.getFoodCategoryTrees();
if (name.equals(secondCategory.getName())) {
//如果分類的名字一樣,說明是這個分類
categoryPosition = new int[]{i, j, -1};
return;
} else if (thirdCategoryTress != null) {
//如果不是這個二級分類並且第三級分類不為空,找第三級分類
for (int k = 0; k < thirdCategoryTress.size(); k++) {
OrderCategoryBean.FoodCategoryTrees thirdCategory = thirdCategoryTress.get(k);
if (name.equals(thirdCategory.getName())) {
//如果分類的名字一樣,說明是這個分類
categoryPosition = new int[]{i, j, k};
return;
}
//沒有第四級分類
}
}
} else {
baseRadioSectionAdapter.toggleFold(position, false);
}
}
@Override
public boolean onItemLongClick(QMUIStickySectionAdapter.ViewHolder holder, int position) {
return false;
}
});
baseRadioSectionAdapter.setOnItemClickListener((id, position1, positions) -> mPresenter.getFoodCategoryList(null, id, position1 + SEPARATOR + positions));
}
private void setCheckState(List<QMUISection<SectionCheckItem, SectionCheckItem>> sections, String lastCheckPositions, boolean b) {
String[] lastSplit = lastCheckPositions.split(SEPARATOR);
if (Integer.parseInt(lastSplit[0]) != -1) {
sections.get(Integer.parseInt(lastSplit[0])).getHeader().setChecked(b);
getTheDeepest(sections.get(Integer.parseInt(lastSplit[0])).getItemList(), lastSplit, 1, b);
}
}
private void refreshAdapter() {
if (sectionLayout.getRecyclerView().isComputingLayout()) {
sectionLayout.getRecyclerView().post(() -> baseRadioSectionAdapter.notifyDataSetChanged());
} else {
baseRadioSectionAdapter.notifyDataSetChanged();
@Override
public void loadFoodCategory
(List<OrderCategoryBean.FoodCategoryTrees> foodCategoryTrees) {
if (TextUtil.isNotEmptyOrNullOrUndefined(categoryName)) {
getCategoryIndexByName(categoryName, foodCategoryTrees);
}
}
public void getTheDeepest(List<SectionCheckItem> sections, String[] split, int i, boolean isChecked) {
if (sections != null && i < split.length) {
if (sections.size() > 0) {
sections.get(Integer.parseInt(split[i])).setChecked(isChecked);
getTheDeepest(sections.get(Integer.parseInt(split[i])).getSectionCheckItems(), split, i + 1, isChecked);
}
} else if (sections != null) {
// for (int j = 0; j < sections.size(); j++) {
//
// }
if (categoryPosition == null) {
categoryPosition = new int[]{0, -1, -1};
}
selectCategoryAdapter = new SelectCategoryAdapter(foodCategoryTrees, Color.WHITE, 0, categoryPosition);
rvCategory.setAdapter(selectCategoryAdapter);
selectCategoryAdapter.setOnChildSelectListener((position, isChecked) -> {
selectCategoryAdapter.notifyDataSetChanged();
});
}
}
package com.gingersoft.supply_chain.mvp.ui.fragment.food;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
......@@ -18,7 +17,7 @@ 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.supply_chain.mvp.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;
......@@ -39,10 +38,7 @@ import com.kingja.loadsir.core.LoadSir;
import com.qmuiteam.qmui.alpha.QMUIAlphaButton;
import com.qmuiteam.qmui.alpha.QMUIAlphaLinearLayout;
import com.qmuiteam.qmui.widget.QMUITopBar;
import com.xuexiang.rxutil2.rxjava.RxJavaUtils;
import com.xuexiang.rxutil2.rxjava.task.RxIOTask;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
......@@ -86,6 +82,8 @@ public class FoodIngredientsFragment extends BaseSupplyChainFragment<FoodIngredi
QMUIAlphaLinearLayout layoutSwitchMethod;
@BindView(R2.id.layout_ingredients_left)
LinearLayout leftLayout;
@BindView(R2.id.tv_ingredients_food_num)
TextView tvShoppingNum;
/**
* 左側分類recyclerview的高度的一半,用來自動滾動到中間,避免每次計算
*/
......@@ -94,7 +92,8 @@ public class FoodIngredientsFragment extends BaseSupplyChainFragment<FoodIngredi
* 頁面類型
* FOOD_INGREDIENTS 為編輯食材頁面
* ADD_ORDER 為添加訂單頁面
* GET_FOOD_BY_SUPPLIER 跟進供應商顯示食品列表
* ORDER_TYPE 為購物車頁面
* GET_FOOD_BY_SUPPLIER 根据供應商顯示食品列表
*/
private int pageType = 1;
public final static int FOOD_INGREDIENTS = 1;
......@@ -112,12 +111,18 @@ public class FoodIngredientsFragment extends BaseSupplyChainFragment<FoodIngredi
/**
* 當前選中的一級分類、二級分類、三級分類名,新建食材時需要用到
*/
private List<String> categoryNames;
// private List<String> categoryNames;
/**
* 分類id,查詢此分類下的食品
*/
private int categoryId = -1;
/**
* 當前分類的名字
*/
private String currentCategoryName;
/**
* 供應商id,查詢此供應商下的食品
*/
private int supplierId = -1;
......@@ -184,8 +189,10 @@ public class FoodIngredientsFragment extends BaseSupplyChainFragment<FoodIngredi
loadService = LoadSir.getDefault().register(rvRightFoodIngredients, (Callback.OnReloadListener) v -> {
});
initTopBar();
//初始化購物車數據
SupplyShoppingCart.getInstance().getCartFoods();
int foodNum = SupplyShoppingCart.getInstance().getCartFoods().size();
setFoodNum(foodNum);
loadDataByType();
}
......@@ -279,7 +286,7 @@ public class FoodIngredientsFragment extends BaseSupplyChainFragment<FoodIngredi
* 新建食品
*/
private void toCreateFood() {
startForResult(NewFoodIngredientsFragment.newInstance(currentSupplierName, categoryNames), EDIT_FOOD_REQUEST_CODE);
startForResult(NewFoodIngredientsFragment.newInstance(currentSupplierName, currentCategoryName), EDIT_FOOD_REQUEST_CODE);
}
private void moveToCenter(LinearLayoutManager leftLayoutManager, int sectionPosition) {
......@@ -337,6 +344,10 @@ public class FoodIngredientsFragment extends BaseSupplyChainFragment<FoodIngredi
*/
@Override
public void loadLeftSupplierInfo(List<CategoryBean> categoryBeans) {
if (supplierId == -1 && categoryBeans.size() > 0) {
//設置默認第一個
supplierId = categoryBeans.get(0).getId();
}
if (listSelectAdapter == null) {
listSelectAdapter = new BaseCategoryAdapter(categoryBeans, mContext);
listSelectAdapter.setUnSelectColor(ContextCompat.getColor(mContext, R.color.color_3c))
......@@ -370,6 +381,11 @@ public class FoodIngredientsFragment extends BaseSupplyChainFragment<FoodIngredi
foodListAdapter.setList(purchaseFoodListVos);
} else {
foodListAdapter = new FoodListAdapter(mContext, purchaseFoodListVos, pageType);
//將之前購物車的食材,添加到食材列表
Map<Integer, PurchaseFoodBean> integerMap = foodListAdapter.getIntegerMap();
for (PurchaseFoodBean purchaseFoodBean : SupplyShoppingCart.getInstance().getCartFoods()) {
integerMap.put(purchaseFoodBean.getId(), purchaseFoodBean);
}
LinearLayoutManager rightLayoutManager = new LinearLayoutManager(mContext);
rvRightFoodIngredients.setLayoutManager(rightLayoutManager);
rvRightFoodIngredients.setAdapter(foodListAdapter);
......@@ -384,17 +400,52 @@ public class FoodIngredientsFragment extends BaseSupplyChainFragment<FoodIngredi
if (!isSupplier) {
purchaseFoodBean.setFoodCategoryName(getCurrentCategory());
}
mPresenter.deleteFood(purchaseFoodBean.getId(), position);
mPresenter.deleteFood(purchaseFoodBean.getId(), purchaseFoodBean.getSupplierId(), purchaseFoodBean.getFoodCategoryId(), position);
dialog.dismiss();
});
}
});
// foodListAdapter.setOnNumberChangeListener((beforeNumber, number, position) -> {
// if (TextUtil.isNotEmptyOrNullOrUndefined(tvShoppingNum.getText())) {
// int foodNum = Integer.parseInt(tvShoppingNum.getText().toString());
// if (beforeNumber == 0 && number > 0) {
// setFoodNum(foodNum + 1);
// } else if (beforeNumber > 0 && number <= 0) {
// setFoodNum(foodNum - 1);
// }
// } else {
// setFoodNum(1);
// }
// int size = foodListAdapter.getIntegerMap().size();
// if (beforeNumber == 0 && number > 0) {
// setFoodNum(size + 1);
// } else if (number <= 0) {
// setFoodNum(size - 1);
// }
// });
}
}
/**
* 修改食品數量顯示
*
* @param size
*/
private void setFoodNum(int size) {
// if (size > 0) {
// tvShoppingNum.setVisibility(View.VISIBLE);
// } else {
// tvShoppingNum.setVisibility(View.GONE);
// }
// tvShoppingNum.setText(String.valueOf(size));
}
@Override
public void onDeleteFoodSuccess(int position) {
foodListAdapter.removeAt(position);
if (foodListAdapter.getItemCount() <= 0) {
loadService.showCallback(EmptyCallback.class);
}
}
private OrderCategoryAdapter orderCategoryAdapter;
......@@ -430,39 +481,44 @@ public class FoodIngredientsFragment extends BaseSupplyChainFragment<FoodIngredi
currentSupplierName = name;
}
/**
* 設置當前分類信息
*/
private void setCurrentCategoryInfo(OrderCategoryBean.FoodCategoryTrees foodCategoryTrees, int level) {
RxJavaUtils.doInIOThread(new RxIOTask<Object>(0) {
@Override
public Void doInIOThread(Object o) {
categoryId = foodCategoryTrees.getId();
if (categoryNames == null) {
categoryNames = new ArrayList<>();
}
//將所選的一級。二級。三級分類都保存下來,新建食品時用到
if (level == OrderCategoryAdapter.PRIMARY_CATEGORY) {
//切换到一級分類
categoryNames.clear();
categoryNames.add(foodCategoryTrees.getName());
} else if (level == OrderCategoryAdapter.SECOND_CATEGORY) {
if (categoryNames.size() > 0) {
//有一級分類
String primaryCateName = categoryNames.get(0);
categoryNames.clear();
categoryNames.add(primaryCateName);
categoryNames.add(foodCategoryTrees.getName());
}
} else if (level == OrderCategoryAdapter.THIRD_CATEGORY) {
if (categoryNames.size() > 2) {
//有三級分類
categoryNames.set(2, foodCategoryTrees.getName());
} else if (categoryNames.size() == 2) {
//有二級分類
categoryNames.add(foodCategoryTrees.getName());
}
}
return null;
}
});
currentCategoryName = foodCategoryTrees.getName();
categoryId = foodCategoryTrees.getId();
// RxJavaUtils.doInIOThread(new RxIOTask<Object>(0) {
// @Override
// public Void doInIOThread(Object o) {
// categoryId = foodCategoryTrees.getId();
// if (categoryNames == null) {
// categoryNames = new ArrayList<>();
// }
// //將所選的一級。二級。三級分類都保存下來,新建食品時用到
// if (level == OrderCategoryAdapter.PRIMARY_CATEGORY) {
// //切换到一級分類
// categoryNames.clear();
// categoryNames.add(foodCategoryTrees.getName());
// } else if (level == OrderCategoryAdapter.SECOND_CATEGORY) {
// if (categoryNames.size() > 0) {
// //有一級分類
// String primaryCateName = categoryNames.get(0);
// categoryNames.clear();
// categoryNames.add(primaryCateName);
// categoryNames.add(foodCategoryTrees.getName());
// }
// } else if (level == OrderCategoryAdapter.THIRD_CATEGORY) {
// if (categoryNames.size() > 2) {
// //有三級分類
// categoryNames.set(2, foodCategoryTrees.getName());
// } else if (categoryNames.size() == 2) {
// //有二級分類
// categoryNames.add(foodCategoryTrees.getName());
// }
// }
// return null;
// }
// });
}
private void initSecondAdapter
......@@ -498,13 +554,24 @@ public class FoodIngredientsFragment extends BaseSupplyChainFragment<FoodIngredi
showPrimaryCategory(View.VISIBLE, View.GONE);
}
/**
* 切換一級分類和二級分類顯示
*
* @param secondVisible 二級分類顯示狀態
* @param visible 一級分類顯示狀態
*/
private void showPrimaryCategory(int secondVisible, int visible) {
rvSecondCategory.setVisibility(secondVisible);
rvLeftCategory.setVisibility(visible);
}
/**
* 初始化一級分類
*
* @param foodCategoryTrees 分類數據
*/
private void initPrimaryAdapter
(List<OrderCategoryBean.FoodCategoryTrees> foodCategoryTrees) {
(List<OrderCategoryBean.FoodCategoryTrees> foodCategoryTrees) {
loadService.showSuccess();
if (orderCategoryAdapter == null) {
orderCategoryAdapter = new OrderCategoryAdapter(mContext, foodCategoryTrees);
......@@ -533,12 +600,7 @@ public class FoodIngredientsFragment extends BaseSupplyChainFragment<FoodIngredi
* @return 當前選中的分類名
*/
public String getCurrentCategory() {
if (categoryNames != null) {
if (categoryNames.size() > 0) {
return categoryNames.get(categoryNames.size() - 1);
}
}
return null;
return currentCategoryName;
}
@Override
......@@ -553,21 +615,23 @@ public class FoodIngredientsFragment extends BaseSupplyChainFragment<FoodIngredi
String categoryName = data.getString(NewFoodIngredientsFragment.CATEGORY_NAME_KEY);
//從供應商的數據中將緩存移除掉,並拿到這個食材所屬的供應商
int removeSupplierId = mPresenter.removeSupplierCache(supplierName);
//當前頁面顯示的供應商緩存也要移除掉,重新查詢,避免用戶修改了供應商或者分類
mPresenter.removeSupplierCacheById(supplierId);
//從分類的數據中將緩存移除掉
mPresenter.removeCacheByCategoryName(categoryName);
//如果所屬供應商是當前選中的供應商,則調用接口重新獲取數據
if (isSupplier) {
//根據供應商獲取食材
if (supplierId == removeSupplierId) {
getFoodsBySupplierId();
}
// if (supplierId == removeSupplierId) {
getFoodsBySupplierId();
// }
} else if (TextUtil.isNotEmptyOrNullOrUndefined(getCurrentCategory())) {
//當前分類不為空
//新建食材的分類不為空,並且新建食材的分類和當前選中的分類一致,那麼就刷新數據
if (TextUtil.isNotEmptyOrNullOrUndefined(categoryName) && categoryName.equals(getCurrentCategory())) {
//如果當前選中的是分類,並且是當前分類。重新獲取該分類下的數據
getFoodsByCategoryId();
}
// if (TextUtil.isNotEmptyOrNullOrUndefined(categoryName) && categoryName.equals(getCurrentCategory())) {
//重新獲取當前分類下的數據
getFoodsByCategoryId();
// }
}
}
}
......
......@@ -78,18 +78,21 @@ public class FoodUnitPageFragment extends BaseSupplyChainFragment<FoodUnitPagePr
* 食品id
*/
public final static String FOOD_ID_KEY = "foodIdKey";
/**
* @param basicUnit 基本單位
* @param deputyUnitBeans 副單位集合
* @return
*/
public static FoodUnitPageFragment newInstance(String basicUnit, List<DeputyUnitBean> deputyUnitBeans, boolean isUpdateUnit, int foodId) {
public static FoodUnitPageFragment newInstance(String basicUnit, List<DeputyUnitBean> deputyUnitBeans, boolean isUpdateUnit, Integer foodId) {
FoodUnitPageFragment fragment = new FoodUnitPageFragment();
Bundle bundle = new Bundle();
bundle.putSerializable(DEPUTY_UNIT_KEY, (Serializable) deputyUnitBeans);
bundle.putString(BASIC_UNIT_KEY, basicUnit);
bundle.putBoolean(UPDATE_UNIT_KEY, isUpdateUnit);
bundle.putInt(FOOD_ID_KEY, foodId);
if (foodId != null) {
bundle.putInt(FOOD_ID_KEY, foodId);
}
fragment.setArguments(bundle);
return fragment;
}
......@@ -130,25 +133,11 @@ public class FoodUnitPageFragment extends BaseSupplyChainFragment<FoodUnitPagePr
edBasicUnit.setError("請輸入基本單位");
return;
}
if (deputyUnitAdapter != null) {
if (deputyUnitAdapter != null && deputyUnitAdapter.getItemCount() > 0) {
mPresenter.addDeputyUnit(deputyUnitAdapter.getData());
} else {
mPresenter.addDeputyUnit(null);
}
// Bundle result = new Bundle();
// result.putString(BASIC_UNIT_KEY, basicUnit);
// if (deputyUnitAdapter != null) {
// //拿到副單位集合
// List<DeputyUnitBean> data = deputyUnitAdapter.getData();
// Iterator<DeputyUnitBean> iterator = data.iterator();
// while (iterator.hasNext()) {
// if (TextUtil.isEmptyOrNullOrUndefined(iterator.next().getDeputyUnit())) {
// //單位為空,移除掉
// iterator.remove();
// }
// }
// result.putSerializable(DEPUTY_UNIT_KEY, (Serializable) data);
// }
// setFragmentResult(RESULT_OK, result);
// killMyself();
}
}
......@@ -227,7 +216,9 @@ public class FoodUnitPageFragment extends BaseSupplyChainFragment<FoodUnitPagePr
Bundle result = new Bundle();
result.putString(BASIC_UNIT_KEY, basicUnit);
result.putSerializable(DEPUTY_UNIT_KEY, (Serializable) deputyUnitBeans);
if (deputyUnitBeans != null) {
result.putSerializable(DEPUTY_UNIT_KEY, (Serializable) deputyUnitBeans);
}
setFragmentResult(RESULT_OK, result);
killMyself();
}
......
......@@ -35,6 +35,7 @@ import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.R2;
import com.gingersoft.supply_chain.di.component.DaggerNewFoodIngredientsComponent;
import com.gingersoft.supply_chain.mvp.bean.DeputyUnitBean;
import com.gingersoft.supply_chain.mvp.bean.OrderCategoryBean;
import com.gingersoft.supply_chain.mvp.bean.PurchaseFoodBean;
import com.gingersoft.supply_chain.mvp.bean.SupplierInfoBean;
import com.gingersoft.supply_chain.mvp.contract.NewFoodIngredientsContract;
......@@ -55,6 +56,8 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
......@@ -112,11 +115,11 @@ public class NewFoodIngredientsFragment extends BaseSupplyChainFragment<NewFoodI
return fragment;
}
public static NewFoodIngredientsFragment newInstance(String supplierName, List<String> categoryNames) {
public static NewFoodIngredientsFragment newInstance(String supplierName, String categoryName) {
NewFoodIngredientsFragment fragment = new NewFoodIngredientsFragment();
Bundle bundle = new Bundle();
bundle.putString(SUPPLIER_NAME_KEY, supplierName);
bundle.putSerializable(CATEGORY_NAME_KEY, (Serializable) categoryNames);
bundle.putString(CATEGORY_NAME_KEY, categoryName);
fragment.setArguments(bundle);
return fragment;
}
......@@ -158,16 +161,13 @@ public class NewFoodIngredientsFragment extends BaseSupplyChainFragment<NewFoodI
initTopBar(topbarNewFoodIngredients, "新增食材");
purchaseFoodBean = new PurchaseFoodBean();
//拿到分類集合
List<String> categoryNames = (List<String>) arguments.getSerializable(CATEGORY_NAME_KEY);
if (categoryNames != null && categoryNames.size() > 0) {
String categoryName = arguments.getString(CATEGORY_NAME_KEY);
if (TextUtil.isNotEmptyOrNullOrUndefined(categoryName)) {
//分類不為空,設置分類信息
List<String> categoryNames= new ArrayList<>();
categoryNames.add(categoryName);
mPresenter.setCategoryNames(categoryNames);
StringBuilder category = new StringBuilder();
for (String categoryName : categoryNames) {
category.append(categoryName).append(PurchaseFoodBean.CATEGORY_DIVIDER);
}
category.deleteCharAt(category.lastIndexOf(PurchaseFoodBean.CATEGORY_DIVIDER));
purchaseFoodBean.setFoodCategoryName(category.toString());
purchaseFoodBean.setFoodCategoryName(categoryName);
}
//供應商名稱
purchaseFoodBean.setSupplierName(arguments.getString(SUPPLIER_NAME_KEY));
......@@ -197,7 +197,7 @@ public class NewFoodIngredientsFragment extends BaseSupplyChainFragment<NewFoodI
startForResult(SupplierListFragment.newInstance(true, multiBean.getShowValue()), multiBean.getRequestCode());
} else if (infoMultiBean.getFragment() == CategorySelectFragment.class) {
//選擇分類
startForResult(CategorySelectFragment.newInstance(), multiBean.getRequestCode());
startForResult(CategorySelectFragment.newInstance(mPresenter.getCategoryName()), multiBean.getRequestCode());
} else if (infoMultiBean.getFragment() == FoodUnitPageFragment.class) {
//食品單位
startForResult(FoodUnitPageFragment.newInstance(mPresenter.getBasicUnit(data), mPresenter.getDeputyUnitBeans(), isUpdate, mPresenter.getFoodId()), multiBean.getRequestCode());
......@@ -248,7 +248,7 @@ public class NewFoodIngredientsFragment extends BaseSupplyChainFragment<NewFoodI
mPresenter.setPackingInfo(basicUnitName, deputyUnitBeans, infoMultiAdapter.getData());
} else if (requestCode == SELECT_FOOD_CATEGORY_REQUEST_CODE) {
//選擇食材類別
List<SectionCheckItem> sectionCheckItems = (List<SectionCheckItem>) data.get(SELECT_CATEGORY_DATA_KEY);
List<OrderCategoryBean.FoodCategoryTrees> sectionCheckItems = (List<OrderCategoryBean.FoodCategoryTrees>) data.get(SELECT_CATEGORY_DATA_KEY);
if (sectionCheckItems != null) {
mPresenter.setCategoryInfo(sectionCheckItems, infoMultiAdapter.getData());
}
......
......@@ -5,6 +5,7 @@ import android.content.Intent;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.text.InputFilter;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
......@@ -27,6 +28,7 @@ import com.chad.library.adapter.base.listener.OnItemChildClickListener;
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;
import com.gingersoft.gsa.cloud.common.utils.toast.ToastUtils;
......@@ -42,6 +44,7 @@ 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.fragment.BaseSupplyChainFragment;
import com.gingersoft.supply_chain.mvp.ui.widget.ChooseUnitPopup;
import com.gingersoft.supply_chain.mvp.ui.widget.PurchaseListMorePopup;
import com.gingersoft.supply_chain.mvp.utils.SelectPicture;
import com.google.android.material.checkbox.MaterialCheckBox;
......@@ -73,7 +76,6 @@ import static com.yalantis.ucrop.UCrop.REQUEST_CROP;
*/
public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPresenter> implements OrderDetailsContract.View, View.OnClickListener {
@BindView(R2.id.supply_top_bar)
QMUITopBar supplyTopBar;
@BindView(R2.id.tv_order_details_supplier_name)
......@@ -110,6 +112,8 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr
LinearLayout layoutEdRemark;
private OrderDetailsFoodAdapter orderDetailsFoodAdapter;
ImageAdapter imageAdapter;
private int typesOfFood = 0;
private double totalAmount = 0;
......@@ -147,6 +151,7 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr
initTopBar(supplyTopBar, "入庫單");
supplyTopBar.addRightImageButton(R.drawable.ic_white_more, R.id.id_more).setOnClickListener(this);
supplyTopBar.addRightImageButton(R.drawable.ic_take_pictures, R.id.id_take_pictures).setOnClickListener(this);
edRemark.setFilters(new InputFilter[]{InputFilterUtils.getLengthFilter(requireContext(), 50)});
Bundle arguments = getArguments();
if (arguments != null) {
int orderId = arguments.getInt(ORDER_DETAILS_ORDER_ID, 0);
......@@ -186,7 +191,7 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr
.hasShadowBg(false)
.popupPosition(PopupPosition.Left)
.asCustom(new PurchaseListMorePopup(mContext)
.setStringData(functions, new int[]{R.drawable.ic_purchase_delete, R.drawable.ic_partial_receipt, R.drawable.ic_receipt})
.setStringData(functions, new int[]{R.drawable.ic_purchase_delete, R.drawable.ic_small_partial_receipt, R.drawable.ic_receipt})
.setOnSelectListener(mOnSelectListener))
.show();
} else if (viewId == R.id.tv_order_details_partial_receipt) {
......@@ -199,9 +204,7 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr
// setFragmentResult(RESULT_OK, null);
} else if (viewId == R.id.layout_remarks) {
//備註,顯示備註輸入框
v.setVisibility(View.GONE);
layoutEdRemark.setVisibility(View.VISIBLE);
layoutRemarks.setVisibility(View.GONE);
layoutEdRemark.setVisibility(layoutEdRemark.getVisibility() == View.VISIBLE ? View.GONE : View.VISIBLE);
}
}
......@@ -228,28 +231,40 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr
@Override
public void loadOrderDetails(PurchaseOrderDetailsBean orderDetailsBean) {
if (TextUtil.isNotEmptyOrNullOrUndefined(orderDetailsBean.getWarehousingRemarks())) {
edRemark.setText(orderDetailsBean.getWarehousingRemarks());
}
tvOrderDetailsSupplierName.setText(orderDetailsBean.getSupplierName());
tvOrderDetailsOrderNo.setText(String.format(getString(R.string.str_format_purchase_no), orderDetailsBean.getOrderNo()));
if (TextUtil.isNotEmptyOrNullOrUndefined(orderDetailsBean.getWarehousingOrderNo())) {
tvWarehouseOrderNo.setText(String.format(getString(R.string.str_format_warehouse_no), orderDetailsBean.getWarehousingOrderNo()));
tvWarehouseOrderNo.setVisibility(View.VISIBLE);
} else {
tvWarehouseOrderNo.setVisibility(View.GONE);
}
tvOrderDetailsCreateTime.setText(TimeUtils.getStringByFormat(orderDetailsBean.getCreateTime(), TimeUtils.DEFAULT_DATE_FORMAT_YMDHM));
// switch (orderDetailsBean.getStatus()) {
// case PurchaseOrderDetailsBean.WAIT_RECEIVED:
// ivOrderState.setImageResource();
switch (orderDetailsBean.getStatus()) {
case PurchaseOrderDetailsBean.WAIT_RECEIVED:
ivOrderState.setVisibility(View.INVISIBLE);
// tvOrderDetailsOrderState.setText("待收貨");
// break;
// case PurchaseOrderDetailsBean.PART_RECEIVED:
break;
case PurchaseOrderDetailsBean.PART_RECEIVED:
ivOrderState.setVisibility(View.VISIBLE);
// tvOrderDetailsOrderState.setText("部分收貨");
// ivOrderState.setImageResource();
// break;
// case PurchaseOrderDetailsBean.COMPLETE_RECEIVED:
ivOrderState.setImageResource(R.drawable.ic_partial_receipt);
break;
case PurchaseOrderDetailsBean.COMPLETE_RECEIVED:
// tvOrderDetailsOrderState.setText("已完成");
ivOrderState.setImageResource(R.drawable.ic_all_receipt);
break;
case PurchaseOrderDetailsBean.REFUSE_RECEIVED:
//拒收
ivOrderState.setImageResource(R.drawable.ic_refuse_accept);
// ivOrderState.setImageResource();
// break;
// case PurchaseOrderDetailsBean.REFUSE_RECEIVED:
// ivOrderState.setImageResource();
// break;
// default:
// break;
// }
break;
default:
break;
}
setTypesOfFood();
initRecyclerView(orderDetailsBean);
//全選按鈕狀態切換
......@@ -258,11 +273,12 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr
//重新計算總價
totalAmount = 0;
typesOfFood = isChecked ? orderDetailsFoodAdapter.getData().size() : 0;
//修改所有食品的選中狀態
//修改所有食品的選中狀態,計算所有實付金額
for (PurchaseOrderDetailsBean.PurchaseOrderDetailsInfoVosBean datum : orderDetailsFoodAdapter.getData()) {
datum.setChecked(isChecked);
if (isChecked) {
totalAmount = MoneyUtil.sum(totalAmount, datum.getWarehousingAmount());
DeputyUnitBean unit = datum.getShowUnit();
totalAmount = MoneyUtil.sum(totalAmount, MoneyUtil.priceCalculation(unit.getDeputyValue(), unit.getUnitPrice()));
}
}
orderDetailsFoodAdapter.notifyDataSetChanged();
......@@ -272,12 +288,10 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr
});
}
ImageAdapter imageAdapter;
@Override
public void uploadPicSuccess(String imgUrl) {
if (imageAdapter == null) {
imageAdapter = new ImageAdapter();
imageAdapter = new ImageAdapter(mPresenter.orderState == PurchaseOrderDetailsBean.ALL);
rvOrderDetailsPictures.setAdapter(imageAdapter);
rvOrderDetailsPictures.setLayoutManager(new GridLayoutManager(requireContext(), 4));
imageAdapter.setOnItemChildClickListener((adapter, view, position) -> {
......@@ -328,20 +342,25 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr
private void initRecyclerView(PurchaseOrderDetailsBean orderDetailsBean) {
orderDetailsFoodAdapter = new OrderDetailsFoodAdapter(mContext, orderDetailsBean.getPurchaseOrderDetailsInfoVOS());
rvOrderDetailsFoodList.setAdapter(orderDetailsFoodAdapter);
orderDetailsFoodAdapter.setOnValueChangeListener((position, value) -> {
orderDetailsFoodAdapter.setOnAmountChangeListener((position, value) -> {
totalAmount = MoneyUtil.sum(totalAmount, value);
setTotalAmount();
});
orderDetailsFoodAdapter.setOnItemClickListener((adapter, view, position) -> {
PurchaseOrderDetailsBean.PurchaseOrderDetailsInfoVosBean infoVosBean = orderDetailsFoodAdapter.getData().get(position);
// if(infoVosBean.getStatus() == PurchaseOrderDetailsBean.COMPLETE_RECEIVED){
// //已經全部收貨的,不讓選中
// return;
// }
infoVosBean.setChecked(!infoVosBean.isChecked());
adapter.notifyItemChanged(position);
//修改選中狀態後,重新計算入庫總價
DeputyUnitBean showUnit = infoVosBean.getShowUnit();
if (infoVosBean.isChecked()) {
totalAmount = MoneyUtil.sum(totalAmount, infoVosBean.getWarehousingAmount());
totalAmount = MoneyUtil.sum(totalAmount, MoneyUtil.priceCalculation(showUnit.getDeputyValue(), showUnit.getUnitPrice()));
typesOfFood += 1;
} else {
totalAmount = MoneyUtil.sub(totalAmount, infoVosBean.getWarehousingAmount());
totalAmount = MoneyUtil.sub(totalAmount, MoneyUtil.priceCalculation(showUnit.getDeputyValue(), showUnit.getUnitPrice()));
typesOfFood -= 1;
}
//全選
......@@ -355,23 +374,33 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr
//切換單位
PurchaseOrderDetailsBean.PurchaseOrderDetailsInfoVosBean purchaseOrderDetailsInfoVosBean = orderDetailsFoodAdapter.getData().get(position);
List<DeputyUnitBean> foodUnits = purchaseOrderDetailsInfoVosBean.getFoodUnits();
String[] units = new String[0];
// String[] units = new String[0];
List<String> units = new ArrayList<>();
if (foodUnits != null) {
units = new String[foodUnits.size()];
// units = new String[foodUnits.size()];
for (int i = 0; i < foodUnits.size(); i++) {
units[i] = foodUnits.get(i).getDeputyUnit();
// units[i] = foodUnits.get(i).getDeputyUnit();
units.add(foodUnits.get(i).getDeputyUnit());
}
}
if (units.length > 1) {
if (units.size() > 1) {
ChooseUnitPopup popup = new ChooseUnitPopup(requireContext()).setStringData(units).setOnSelectListener(new OnSelectListener() {
@Override
public void onSelect(int position, String text) {
//將用戶之前輸入的值,修改到新選擇的單位匯中
DeputyUnitBean showUnit = purchaseOrderDetailsInfoVosBean.getShowUnit();
DeputyUnitBean deputyUnitBean = foodUnits.get(position);
deputyUnitBean.setDeputyValue(showUnit.getDeputyValue());
deputyUnitBean.setUnitPrice(showUnit.getUnitPrice());
purchaseOrderDetailsInfoVosBean.setShowUnit(deputyUnitBean);
orderDetailsFoodAdapter.notifyItemChanged(position);
}
});
new XPopup.Builder(getContext())
.hasShadowBg(false)
.atView(view) // 依附于所点击的View,内部会自动判断在上方或者下方显示
.asAttachList(units,
null,
(position1, text) -> {
purchaseOrderDetailsInfoVosBean.setShowUnit(foodUnits.get(position1));
orderDetailsFoodAdapter.notifyItemChanged(position);
}).show();
.asCustom(popup)
.show();
}
}
});
......
......@@ -81,8 +81,8 @@ public class PurchaseListFragment extends BaseSupplyChainFragment<PurchaseListPr
ScreenView screenView;
@BindView(R2.id.view_load_bg)
View loadBg;
@BindView(R2.id.ed_food_ingredients_search)
EditText edSearch;
// @BindView(R2.id.ed_food_ingredients_search)
// EditText edSearch;
@BindView(R2.id.srl_purchase_list)
SmartRefreshLayout refreshPurchaseList;
......@@ -124,7 +124,7 @@ public class PurchaseListFragment extends BaseSupplyChainFragment<PurchaseListPr
public void initData(@Nullable Bundle savedInstanceState) {
refreshPurchaseList.setPrimaryColorsId(R.color.trans, R.color.black);
btnNewOrder.setText("+新增訂單");
edSearch.setFilters(new InputFilter[]{InputFilterUtils.getChAndEnAndNumInputFilter(mContext), InputFilterUtils.getLengthFilter(mContext, 20)});
// edSearch.setFilters(new InputFilter[]{InputFilterUtils.getChAndEnAndNumInputFilter(mContext), InputFilterUtils.getLengthFilter(mContext, 20)});
btnNewOrder.setOnClickListener(v -> {
//跳轉到下單頁面
startForResult(FoodIngredientsFragment.newInstance(ADD_ORDER), REQUEST_ORDER_DETAILS_CODE);
......@@ -144,7 +144,7 @@ public class PurchaseListFragment extends BaseSupplyChainFragment<PurchaseListPr
}
private void getOrderList() {
mPresenter.getOrderList(edSearch.getText() + "", orderState[orderStateIndex], pageIndex);
mPresenter.getOrderList("", orderState[orderStateIndex], pageIndex);
}
@Override
......@@ -190,7 +190,18 @@ public class PurchaseListFragment extends BaseSupplyChainFragment<PurchaseListPr
.asCustom(new PurchaseListMorePopup(mContext)
//, "再次购买" , R.drawable.ic_purchase_buy_again
.setStringData(new String[]{"删除", "发送"}, new int[]{R.drawable.ic_purchase_delete, R.drawable.ic_purchase_send})
.setOnSelectListener(mOnSelectListener))
.setOnSelectListener((popupPosition, text) -> {
if (popupPosition == 0) {
//刪除
AppDialog.getInstance().showWaringDialog(mContext, "是否刪除訂單", (view1, dialog) -> {
dialog.dismiss();
mPresenter.deleteOrder(position, purchaseOrderAdapter.getData().get(position).getId());
});
} else if (popupPosition == 1) {
//發送採購單
sendPurchase(position);
}
}))
.show();
}
});
......@@ -228,22 +239,6 @@ public class PurchaseListFragment extends BaseSupplyChainFragment<PurchaseListPr
});
}
private OnSelectListener mOnSelectListener = new OnSelectListener() {
@Override
public void onSelect(int position, String text) {
if (position == 0) {
//刪除
AppDialog.getInstance().showWaringDialog(mContext, "是否刪除訂單", (view1, dialog) -> {
dialog.dismiss();
mPresenter.deleteOrder(position, purchaseOrderAdapter.getData().get(position).getId());
});
} else if (position == 1) {
//發送採購單
sendPurchase(position);
}
}
};
private void sendPurchase(int position) {
List<OrderBean> data = purchaseOrderAdapter.getData();
OrderBean orderBean = data.get(position);
......
......@@ -100,10 +100,10 @@ public class ShoppingCatFragment extends BaseSupplyChainFragment<ShoppingCatPres
@Override
public void initData(@Nullable Bundle savedInstanceState) {
initTopBar(topBar, "採購單");
mPresenter.organizeShopCartData();
canClick = ContextCompat.getDrawable(requireContext(), R.drawable.shape_app_btn);
notCanClick = ContextCompat.getDrawable(requireContext(), R.drawable.shape_btn_unclick);
initTopBar(topBar, "採購單");
mPresenter.organizeShopCartData();
cbOrderContentAllSelect.setOnCheckedChangeListener((buttonView, isChecked) -> {
//全選
......@@ -214,7 +214,7 @@ public class ShoppingCatFragment extends BaseSupplyChainFragment<ShoppingCatPres
@Override
public void setCreateBtnState(boolean checkable) {
// tvConfirm.setBackground(checkable ? canClick : notCanClick);
// tvConfirm.setClickable(checkable);
tvConfirm.setBackground(checkable ? canClick : notCanClick);
tvConfirm.setClickable(checkable);
}
}
......@@ -186,6 +186,8 @@ public class SupplierListFragment extends BaseSupplyChainFragment<SupplierListPr
bundle.putSerializable(SELECT_SUPPLIER_DATA, supplierInfoBean);
setFragmentResult(SELECT_SUPPLIER_RESULTCODE, bundle);
killMyself();
} else {
showMessage("請選擇供應商");
}
}
}
......@@ -196,6 +198,7 @@ public class SupplierListFragment extends BaseSupplyChainFragment<SupplierListPr
super.onFragmentResult(requestCode, resultCode, data);
if (requestCode == SUPPLIER_LIST && resultCode == RESULT_OK) {
//新增或編輯了供應商,重新獲取所有供應商數據
pageIndex = 0;
getSupplierList();
}
}
......
......@@ -80,7 +80,10 @@ public class WareHouseListFragment extends BaseSupplyChainFragment<WareHouseList
*/
private boolean isAscending = false;
private int pageIndex = 0;
/**
* 調整到其他頁面,用於回來是否刷新數據
*/
private final int UPDATE_KEY = 1001;
private WarehousingQueryAdapter warehousingQueryAdapter;
public static WareHouseListFragment newInstance() {
......@@ -185,18 +188,27 @@ public class WareHouseListFragment extends BaseSupplyChainFragment<WareHouseList
warehousingQueryAdapter = new WarehousingQueryAdapter(mContext, purchaseWarehousingOrderDetailsVos);
rvWarehouseList.setLayoutManager(new LinearLayoutManager(mContext));
rvWarehouseList.setAdapter(warehousingQueryAdapter);
warehousingQueryAdapter.setOnItemChildClickListener((adapter, view, position) -> {
if(view.getId() == R.id.tv_warehouse_item_inventory_quantity){
//點擊庫存數量,進入庫存盤點
start(WarehousingInventoryFragment.newInstance(warehousingQueryAdapter.getItem(position)));
startForResult(WarehousingInventoryFragment.newInstance(warehousingQueryAdapter.getItem(position)), UPDATE_KEY);
}
});
warehousingQueryAdapter.setOnItemClickListener((adapter, view, position) -> {
//進入庫存詳情
start(WarehouseDetailsFragment.newInstance(warehousingQueryAdapter.getItem(position)));
startForResult(WarehouseDetailsFragment.newInstance(warehousingQueryAdapter.getItem(position)), UPDATE_KEY);
});
} else {
warehousingQueryAdapter.setList(purchaseWarehousingOrderDetailsVos);
}
}
@Override
public void onFragmentResult(int requestCode, int resultCode, Bundle data) {
super.onFragmentResult(requestCode, resultCode, data);
if(requestCode == UPDATE_KEY && resultCode == RESULT_OK){
getWarehousing();
}
}
}
package com.gingersoft.supply_chain.mvp.ui.fragment.warehouse;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
......@@ -13,11 +15,16 @@ import androidx.core.content.ContextCompat;
import androidx.viewpager.widget.ViewPager;
import androidx.viewpager2.widget.ViewPager2;
import com.gingersoft.gsa.cloud.common.loadsir.EmptyCallback;
import com.gingersoft.gsa.cloud.common.utils.glide.GlideUtils;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.R2;
import com.gingersoft.supply_chain.di.component.DaggerWarehouseDetailsComponent;
import com.gingersoft.supply_chain.mvp.bean.ConsumeReasonBean;
import com.gingersoft.supply_chain.mvp.bean.WareHouseListBean;
import com.gingersoft.supply_chain.mvp.bean.WarehouseDetailsBean;
import com.gingersoft.supply_chain.mvp.content.Constant;
import com.gingersoft.supply_chain.mvp.contract.WarehouseDetailsContract;
import com.gingersoft.supply_chain.mvp.presenter.WarehouseDetailsPresenter;
import com.gingersoft.supply_chain.mvp.ui.adapter.PurchasePageAdapter;
......@@ -25,23 +32,30 @@ import com.gingersoft.supply_chain.mvp.ui.adapter.WareHousingDetailsAdapter;
import com.gingersoft.supply_chain.mvp.ui.fragment.BaseSupplyChainFragment;
import com.gingersoft.supply_chain.mvp.ui.widget.InventoryConsumptionPopup;
import com.jess.arms.di.component.AppComponent;
import com.kingja.loadsir.core.LoadSir;
import com.lxj.xpopup.XPopup;
import com.qmuiteam.qmui.widget.QMUITopBar;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import butterknife.BindView;
import butterknife.OnClick;
/**
* Description: 入庫詳情
*/
public class WarehouseDetailsFragment extends BaseSupplyChainFragment<WarehouseDetailsPresenter> implements WarehouseDetailsContract.View {
public class WarehouseDetailsFragment extends BaseSupplyChainFragment<WarehouseDetailsPresenter> implements WarehouseDetailsContract.View, View.OnClickListener {
@BindView(R2.id.supply_top_bar)
QMUITopBar supplyTopBar;
@BindView(R2.id.iv_warehouse_img)
ImageView ivFoodImg;
@BindView(R2.id.tv_warehouse_inventory_number)
TextView tvWarehouseInventoryNumber;
@BindView(R2.id.tv_warehouse_specifications)
......@@ -58,19 +72,44 @@ public class WarehouseDetailsFragment extends BaseSupplyChainFragment<WarehouseD
ViewPager2 vpWarehouseViewpager;
@BindView(R2.id.srl_warehouse_details_list)
SmartRefreshLayout smartRefreshLayout;
@BindView(R2.id.tv_food_unit)
TextView tvUnit;
private final static String FOOD_NAME_KEY = "foodNameKey";
private final static String FOOD_ID_KEY = "foodIdKey";
private final static String FOOD_UNIT_KEY = "foodUnitKey";
private final static String FOOD_NUM_KEY = "foodNumKey";
private WareHousingDetailsAdapter wareHousingDetailsAdapter;
private PurchasePageAdapter adapter;
private int foodId;
private String foodNo;
private String foodName;
private String foodUnit;
private int wareHousingNum;
public final static String FOOD_NAME_KEY = "foodNameKey";
public final static String FOOD_ID_KEY = "foodIdKey";
public final static String FOOD_NO_KEY = "foodNoKey";
public final static String FOOD_UNIT_KEY = "foodUnitKey";
public final static String FOOD_NUM_KEY = "foodNumKey";
public final static String FOOD_UNIT_PRICE_KEY = "foodUnitPriceKey";
public final static String FOOD_TOTAL_AMOUNT_KEY = "foodTotalAmountKey";
public final static String FOOD_IMAGE_KEY = "foodImageKey";
/**
* 入庫
*/
public final static int WAREHOUSE_TYPE = 0;
/**
* 出庫
*/
public final static int OUT_STOCK_TYPE = 1;
public static WarehouseDetailsFragment newInstance(WareHouseListBean.WareHousingDataBean.PurchaseWarehousingOrderDetailsVOSBean purchaseWarehousingOrderDetailsVosBean) {
WarehouseDetailsFragment fragment = new WarehouseDetailsFragment();
Bundle bundle = new Bundle();
bundle.putString(FOOD_NAME_KEY, purchaseWarehousingOrderDetailsVosBean.getName());
bundle.putInt(FOOD_ID_KEY, purchaseWarehousingOrderDetailsVosBean.getId());
bundle.putString(FOOD_UNIT_KEY, purchaseWarehousingOrderDetailsVosBean.getBasicUnitName());
bundle.putString(FOOD_UNIT_KEY, purchaseWarehousingOrderDetailsVosBean.getUnitName());
bundle.putInt(FOOD_NUM_KEY, purchaseWarehousingOrderDetailsVosBean.getFoodNum());
bundle.putDouble(FOOD_UNIT_PRICE_KEY, purchaseWarehousingOrderDetailsVosBean.getFoodPrice());
bundle.putDouble(FOOD_TOTAL_AMOUNT_KEY, purchaseWarehousingOrderDetailsVosBean.getFoodAmount());
bundle.putString(FOOD_NO_KEY, purchaseWarehousingOrderDetailsVosBean.getFoodNo());
bundle.putString(FOOD_IMAGE_KEY, purchaseWarehousingOrderDetailsVosBean.getImages());
fragment.setArguments(bundle);
return fragment;
}
......@@ -93,30 +132,56 @@ public class WarehouseDetailsFragment extends BaseSupplyChainFragment<WarehouseD
@Override
public void initData(@Nullable Bundle savedInstanceState) {
Bundle arguments = getArguments();
smartRefreshLayout.setEnableHeaderTranslationContent(false).
setEnableFooterTranslationContent(false);
smartRefreshLayout.setPrimaryColorsId(R.color.trans, R.color.black);
loadService = LoadSir.getDefault().register(smartRefreshLayout);
// smartRefreshLayout.setEnableHeaderTranslationContent(false).
// setEnableFooterTranslationContent(false);
smartRefreshLayout.setOnRefreshListener(refreshLayout -> getPageInfo());
if (arguments != null) {
initTopBar(supplyTopBar, arguments.getString(FOOD_NAME_KEY));
int foodId = arguments.getInt(FOOD_ID_KEY);
String foodUnit = arguments.getString(FOOD_UNIT_KEY);
int foodNum = arguments.getInt(FOOD_NUM_KEY);
mPresenter.getWarehousingOrderDetails(foodId, foodUnit);
if (foodNum > 0) {
foodName = arguments.getString(FOOD_NAME_KEY);
initTopBar(supplyTopBar, foodName);
foodId = arguments.getInt(FOOD_ID_KEY);
foodNo = arguments.getString(FOOD_NO_KEY);
foodUnit = arguments.getString(FOOD_UNIT_KEY);
wareHousingNum = arguments.getInt(FOOD_NUM_KEY);
if (TextUtil.isNotEmptyOrNullOrUndefined(foodUnit)) {
tvUnit.setText(foodUnit);
}
String foodImageUrl = arguments.getString(FOOD_IMAGE_KEY);
if (TextUtil.isNotEmptyOrNullOrUndefined(foodImageUrl)) {
GlideUtils.display(requireContext(), ivFoodImg, foodImageUrl);
} else {
ivFoodImg.setImageResource(R.drawable.img_small_default);
}
double unitPrice = arguments.getDouble(FOOD_UNIT_PRICE_KEY);
double totalAmount = arguments.getDouble(FOOD_TOTAL_AMOUNT_KEY);
tvWarehouseInventoryNumber.setText(String.valueOf(wareHousingNum));
tvWarehouseUnitPrice.setText(String.format(getString(R.string.str_latest_unit_price_colon), unitPrice));
tvWarehouseTotalAmount.setText(String.format(getString(R.string.str_total_amount_colon), totalAmount));
tvWarehouseSpecifications.setText(foodUnit);
getWarehouseDetails();
if (wareHousingNum > 0) {
//獲取庫存消耗的原因列表
mPresenter.getWarehouseInventoryReason();
Button button = supplyTopBar.addRightTextButton(R.string.str_inventory_consumption, R.id.id_inventory_consumption);
button.setTextColor(ContextCompat.getColor(requireContext(), R.color.white));
button.setOnClickListener(v -> {
//庫存消耗
new XPopup.Builder(requireContext())
.asCustom(new InventoryConsumptionPopup(requireContext(), Arrays.asList("正常消耗", "退貨消耗", "過期消耗", "其他消耗"), 10, (consumptionNum, reasonIndex, remarks) -> {
})).show();
});
}
initViewPager();
}
}
/**
* 獲取入庫詳情
*/
private void getWarehouseDetails() {
mPresenter.getWarehousingOrderDetails(foodNo);
}
/**
* 獲取出庫詳情
*/
private void getOutStockDetails() {
mPresenter.getOutStockDetails(foodNo);
}
private void initViewPager() {
vpWarehouseViewpager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
@Override
......@@ -127,16 +192,13 @@ public class WarehouseDetailsFragment extends BaseSupplyChainFragment<WarehouseD
@Override
public void onPageSelected(int position) {
super.onPageSelected(position);
if (position == 0) {
tvWarehousingRecord.setTextColor(ContextCompat.getColor(requireContext(), R.color.white));
tvWarehousingRecord.setBackground(ContextCompat.getDrawable(requireContext(), R.drawable.shape_left_themecolor_radius_btn));
tvOutboundRecord.setTextColor(ContextCompat.getColor(requireContext(), R.color.color_3c));
tvOutboundRecord.setBackground(ContextCompat.getDrawable(requireContext(), R.drawable.shape_right_white_radius_btn));
setBtnSelectState(position);
if (position == WAREHOUSE_TYPE) {
//查詢入庫
getWarehouseDetails();
} else {
tvOutboundRecord.setTextColor(ContextCompat.getColor(requireContext(), R.color.white));
tvOutboundRecord.setBackground(ContextCompat.getDrawable(requireContext(), R.drawable.shape_left_themecolor_radius_btn));
tvWarehousingRecord.setTextColor(ContextCompat.getColor(requireContext(), R.color.color_3c));
tvWarehousingRecord.setBackground(ContextCompat.getDrawable(requireContext(), R.drawable.shape_right_white_radius_btn));
//查詢出庫
getOutStockDetails();
}
}
......@@ -147,21 +209,92 @@ public class WarehouseDetailsFragment extends BaseSupplyChainFragment<WarehouseD
});
}
private WareHousingDetailsAdapter wareHousingDetailsAdapter;
private void setBtnSelectState(int position) {
if (wareHousingDetailsAdapter != null) {
wareHousingDetailsAdapter.setList(new ArrayList<>());
}
if (position == WAREHOUSE_TYPE) {
tvWarehousingRecord.setTextColor(ContextCompat.getColor(requireContext(), R.color.white));
tvWarehousingRecord.setBackground(ContextCompat.getDrawable(requireContext(), R.drawable.shape_left_themecolor_radius_btn));
tvOutboundRecord.setTextColor(ContextCompat.getColor(requireContext(), R.color.color_3c));
tvOutboundRecord.setBackground(ContextCompat.getDrawable(requireContext(), R.drawable.shape_right_white_radius_btn));
} else {
tvOutboundRecord.setTextColor(ContextCompat.getColor(requireContext(), R.color.white));
tvOutboundRecord.setBackground(ContextCompat.getDrawable(requireContext(), R.drawable.shape_right_themecolor_radius_btn));
tvWarehousingRecord.setTextColor(ContextCompat.getColor(requireContext(), R.color.color_3c));
tvWarehousingRecord.setBackground(ContextCompat.getDrawable(requireContext(), R.drawable.shape_left_white_radius_btn));
}
}
@Override
public void loadAdapter(List<WarehouseDetailsBean> warehouseDetailsBeans) {
smartRefreshLayout.finishRefresh();
smartRefreshLayout.finishLoadMore();
if (warehouseDetailsBeans.size() <= 0) {
loadService.showCallback(EmptyCallback.class);
} else {
loadService.showSuccess();
if (wareHousingDetailsAdapter == null) {
wareHousingDetailsAdapter = new WareHousingDetailsAdapter(requireContext(), warehouseDetailsBeans, vpWarehouseViewpager.getCurrentItem());
if (adapter == null) {
adapter = new PurchasePageAdapter(wareHousingDetailsAdapter, 2);
vpWarehouseViewpager.setAdapter(adapter);
}
} else {
wareHousingDetailsAdapter.setType(vpWarehouseViewpager.getCurrentItem());
wareHousingDetailsAdapter.setList(warehouseDetailsBeans);
}
}
}
@Override
public void loadWarehousing(WarehouseDetailsBean warehouseDetailsBean) {
loadAdapter(warehouseDetailsBean.getPurchaseWarehousingOrderDetailsContents());
PurchasePageAdapter adapter = new PurchasePageAdapter(wareHousingDetailsAdapter, 2);
vpWarehouseViewpager.setAdapter(adapter);
public void loadConsumeReason(List<ConsumeReasonBean> consumeReasonBeans) {
Button button = supplyTopBar.addRightTextButton(R.string.str_inventory_consumption, R.id.id_inventory_consumption);
button.setTextColor(ContextCompat.getColor(requireContext(), R.color.white));
button.setOnClickListener(v -> {
//庫存消耗
InventoryConsumptionPopup inventoryConsumptionPopup = new InventoryConsumptionPopup(requireContext(), consumeReasonBeans, wareHousingNum);
inventoryConsumptionPopup.setOnConfirmClickListener((consumptionNum, reasonIndex, remarks) -> {
inventoryConsumptionPopup.dismiss();
mPresenter.consumeWareHousing(foodNo, consumptionNum, consumeReasonBeans.get(reasonIndex).getId(), remarks);
setFragmentResult(RESULT_OK, null);
});
inventoryConsumptionPopup.setTitleContent(getString(R.string.str_consumption_inventory), getString(R.string.str_remark_colon), getString(R.string.str_manual_input));
new XPopup.Builder(requireContext())
.asCustom(inventoryConsumptionPopup).show();
});
}
@Override
public void loadAdapter(List<WarehouseDetailsBean.PurchaseWarehousingOrderDetailsContentsBean> purchaseWarehousingOrderDetailsContents) {
if (wareHousingDetailsAdapter == null) {
wareHousingDetailsAdapter = new WareHousingDetailsAdapter(purchaseWarehousingOrderDetailsContents);
public void getPageInfo() {
if (vpWarehouseViewpager.getCurrentItem() == WAREHOUSE_TYPE) {
//獲取入庫流水
getWarehouseDetails();
} else {
wareHousingDetailsAdapter.setList(purchaseWarehousingOrderDetailsContents);
//獲取出庫流水
getOutStockDetails();
}
}
@Override
public void setWarehousingNum(int num) {
tvWarehouseInventoryNumber.setText(String.valueOf(num));
}
@OnClick({R2.id.tv_warehousing_record, R2.id.tv_outbound_record})
@Override
public void onClick(View v) {
if (v.getId() == R.id.tv_warehousing_record) {
//入庫流水
vpWarehouseViewpager.setCurrentItem(WAREHOUSE_TYPE);
//查詢入庫
getWarehouseDetails();
} else if (v.getId() == R.id.tv_outbound_record) {
//出庫流水
vpWarehouseViewpager.setCurrentItem(OUT_STOCK_TYPE);
//查詢出庫
getOutStockDetails();
}
}
}
package com.gingersoft.supply_chain.mvp.ui.fragment.warehouse;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import com.gingersoft.gsa.cloud.common.utils.glide.GlideUtils;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.R2;
import com.gingersoft.supply_chain.di.component.DaggerWarehousingInventoryComponent;
......@@ -19,7 +25,11 @@ import com.gingersoft.supply_chain.mvp.contract.WarehousingInventoryContract;
import com.gingersoft.supply_chain.mvp.presenter.WarehousingInventoryPresenter;
import com.gingersoft.supply_chain.mvp.ui.fragment.BaseSupplyChainFragment;
import com.jess.arms.di.component.AppComponent;
import com.qmuiteam.qmui.util.QMUIDisplayHelper;
import com.qmuiteam.qmui.widget.QMUITopBar;
import com.zhy.autolayout.utils.ScreenUtils;
import org.w3c.dom.Text;
import butterknife.BindView;
......@@ -39,17 +49,20 @@ public class WarehousingInventoryFragment extends BaseSupplyChainFragment<Wareho
TextView tvWarehouseDifference;
@BindView(R2.id.ed_warehouse_loss)
EditText edWarehouseLoss;
private final static String FOOD_NAME_KEY = "foodNameKey";
private final static String FOOD_ID_KEY = "foodIdKey";
private final static String FOOD_NUM_KEY = "foodNumKey";
/**
* 食品總庫存
*/
private int foodNum;
private String foodNo;
public static WarehousingInventoryFragment newInstance(WareHouseListBean.WareHousingDataBean.PurchaseWarehousingOrderDetailsVOSBean purchaseWarehousingOrderDetailsVosBean) {
WarehousingInventoryFragment fragment = new WarehousingInventoryFragment();
Bundle bundle = new Bundle();
bundle.putString(FOOD_NAME_KEY, purchaseWarehousingOrderDetailsVosBean.getName());
bundle.putInt(FOOD_ID_KEY, purchaseWarehousingOrderDetailsVosBean.getId());
bundle.putInt(FOOD_NUM_KEY, purchaseWarehousingOrderDetailsVosBean.getFoodNum());
bundle.putString(WarehouseDetailsFragment.FOOD_NAME_KEY, purchaseWarehousingOrderDetailsVosBean.getName());
bundle.putInt(WarehouseDetailsFragment.FOOD_ID_KEY, purchaseWarehousingOrderDetailsVosBean.getId());
bundle.putInt(WarehouseDetailsFragment.FOOD_NUM_KEY, purchaseWarehousingOrderDetailsVosBean.getFoodNum());
bundle.putString(WarehouseDetailsFragment.FOOD_NO_KEY, purchaseWarehousingOrderDetailsVosBean.getFoodNo());
bundle.putString(WarehouseDetailsFragment.FOOD_IMAGE_KEY, purchaseWarehousingOrderDetailsVosBean.getImages());
fragment.setArguments(bundle);
return fragment;
}
......@@ -73,15 +86,63 @@ public class WarehousingInventoryFragment extends BaseSupplyChainFragment<Wareho
public void initData(@Nullable Bundle savedInstanceState) {
Bundle arguments = getArguments();
if (arguments != null) {
int foodId = arguments.getInt(FOOD_ID_KEY);
String foodName = arguments.getString(FOOD_NAME_KEY);
int foodNum = arguments.getInt(FOOD_NUM_KEY);
int foodId = arguments.getInt(WarehouseDetailsFragment.FOOD_ID_KEY);
foodNo = arguments.getString(WarehouseDetailsFragment.FOOD_NO_KEY);
String foodName = arguments.getString(WarehouseDetailsFragment.FOOD_NAME_KEY);
foodNum = arguments.getInt(WarehouseDetailsFragment.FOOD_NUM_KEY);
ivWarehouseImg.post(() -> {
ViewGroup.LayoutParams layoutParams = ivWarehouseImg.getLayoutParams();
layoutParams.height = ivWarehouseImg.getWidth();
layoutParams.width = ivWarehouseImg.getWidth();
ivWarehouseImg.setLayoutParams(layoutParams);
String foodImageUrl = arguments.getString(WarehouseDetailsFragment.FOOD_IMAGE_KEY);
if (TextUtil.isNotEmptyOrNullOrUndefined(foodImageUrl)) {
GlideUtils.display(requireContext(), ivWarehouseImg, foodImageUrl);
} else {
ivWarehouseImg.setImageResource(R.drawable.img_small_default);
}
});
//初始化標題
initTopBar(supplyTopBar, foodName);
supplyTopBar.addRightTextButton(R.string.str_save, R.id.id_save).setOnClickListener(mOnClickListener);
Button btnSave = supplyTopBar.addRightTextButton(R.string.str_save, R.id.id_save);
btnSave.setTextColor(getColor(R.color.white));
btnSave.setOnClickListener(mOnClickListener);
//庫存數量
tvWarehouseTotal.setText(String.valueOf(foodNum));
tvWarehouseDifference.setText(String.valueOf(foodNum));
edWarehouseLoss.setOnFocusChangeListener((v, hasFocus) -> {
if (hasFocus && edWarehouseLoss.getText().toString().equals("0")) {
edWarehouseLoss.setText("");
}
});
edWarehouseLoss.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
if (TextUtil.isNotEmptyOrNullOrUndefined(s + "")) {
//用戶輸入的盤點數量
int inventoryNum = Integer.parseInt(s + "");
// if (inventoryNum > foodNum) {
// inventoryNum = foodNum;
// showMessage("不能大於庫存數");
// edWarehouseLoss.setText(String.valueOf(foodNum));
// edWarehouseLoss.setSelection(edWarehouseLoss.getText().length());
// }
tvWarehouseDifference.setText(String.valueOf(Math.abs(foodNum - inventoryNum)));
} else {
tvWarehouseDifference.setText(String.valueOf(foodNum));
}
}
});
} else {
showMessage("獲取食材信息失敗,請稍候重試");
killMyself();
......@@ -90,9 +151,27 @@ public class WarehousingInventoryFragment extends BaseSupplyChainFragment<Wareho
private View.OnClickListener mOnClickListener = v -> {
if(v.getId() == R.id.id_save){
//保存
// edWarehouseLoss.getText()
if (v.getId() == R.id.id_save) {
//保存,調用庫存損耗
if (TextUtil.isEmptyOrNullOrUndefined(edWarehouseLoss)) {
showMessage("請輸入盤點庫存數量");
edWarehouseLoss.requestFocus();
} else {
//盤點數量
int inventoryNum = Integer.parseInt(edWarehouseLoss.getText().toString());
if (inventoryNum <= 0) {
showMessage("請輸入盤點庫存數量");
edWarehouseLoss.requestFocus();
} else {
int remainingAmount = foodNum - inventoryNum;
mPresenter.consumeWareHousing(foodNo, remainingAmount);
}
}
}
};
@Override
public void updateSuccess() {
setFragmentResult(RESULT_OK, null);
}
}
......@@ -28,6 +28,7 @@ public class CategoryPopup extends ConfirmPopupView {
private EditText et_input;
private OnClickListener onDeleteListener;
private String inputText;
private final int nameMaxLength = 4;
public CategoryPopup(@NonNull Context context, CharSequence title, CharSequence content, CharSequence hint, String inputText, boolean showDelete) {
super(context, R.layout.dialog_new_category);
......@@ -44,11 +45,15 @@ public class CategoryPopup extends ConfirmPopupView {
tvDelete.setVisibility(showDelete ? View.VISIBLE : GONE);
tvDelete.setOnClickListener(onDeleteListener);
et_input = findViewById(R.id.et_input);
et_input.setFilters(new InputFilter[]{InputFilterUtils.getLengthFilter(getContext(), 4), InputFilterUtils.getChAndEnAndNumInputFilter(getContext())});
if (TextUtil.isNotEmptyOrNullOrUndefined(inputText)) {
et_input.setText(inputText);
et_input.setSelection(inputText.length());
if (inputText.length() > nameMaxLength) {
et_input.setText(inputText.substring(0, 4));
} else {
et_input.setText(inputText);
}
et_input.setSelection(et_input.length());
}
et_input.setFilters(new InputFilter[]{InputFilterUtils.getLengthFilter(getContext(), 4), InputFilterUtils.getChAndEnAndNumInputFilter(getContext())});
}
public EditText getEditText() {
......
package com.gingersoft.supply_chain.mvp.ui.widget;
import android.content.Context;
import android.widget.LinearLayout;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.gingersoft.supply_chain.R;
import com.lxj.xpopup.animator.PopupAnimator;
import com.lxj.xpopup.animator.ScrollScaleAnimator;
import com.lxj.xpopup.enums.PopupAnimation;
import com.lxj.xpopup.impl.AttachListPopupView;
import com.lxj.xpopup.interfaces.OnSelectListener;
import com.lxj.xpopup.widget.VerticalRecyclerView;
import org.jetbrains.annotations.NotNull;
import java.util.List;
/**
* @author 宇航.
* User: admin
* Date: 2021/1/29
* Time: 16:45
* Use:
*/
public class ChooseUnitPopup extends AttachListPopupView {
private OnSelectListener selectListener;
private RecyclerView recyclerView;
private int width;
/**
* @param context
*/
public ChooseUnitPopup(@NonNull Context context) {
super(context, 0, R.layout.popup_choose_unit);
}
@Override
protected void onCreate() {
recyclerView = findViewById(R.id.recyclerView);
width = popupInfo.atView.getMeasuredWidth();
recyclerView.setHasFixedSize(false);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
ChooseUnitAdapter adapter = new ChooseUnitAdapter();
adapter.setOnItemClickListener((a, view, position) -> {
if (selectListener != null) {
selectListener.onSelect(position, adapter.getItem(position));
}
if (popupInfo.autoDismiss) {
dismiss();
}
});
recyclerView.setAdapter(adapter);
applyTheme();
}
private List<String> data;
public ChooseUnitPopup setStringData(List<String> data) {
this.data = data;
return this;
}
@Override
protected PopupAnimator getPopupAnimator() {
PopupAnimator animator;
if (isShowUpToTarget()) {
// 在上方展示
animator = new ScrollScaleAnimator(getPopupContentView(), PopupAnimation.ScrollAlphaFromBottom);
} else {
// 在下方展示
animator = new ScrollScaleAnimator(getPopupContentView(), PopupAnimation.ScrollAlphaFromTop);
}
return animator;
}
@Override
protected void applyDarkTheme() {
((VerticalRecyclerView)recyclerView).setupDivider(true);
}
@Override
protected void applyLightTheme() {
((VerticalRecyclerView)recyclerView).setupDivider(false);
}
@Override
public ChooseUnitPopup setOnSelectListener(OnSelectListener selectListener) {
this.selectListener = selectListener;
return this;
}
public class ChooseUnitAdapter extends BaseQuickAdapter<String, BaseViewHolder> {
public ChooseUnitAdapter() {
super(R.layout.popup_choose_unit, data);
}
@Override
protected void convert(@NotNull BaseViewHolder viewHolder, String s) {
viewHolder.setText(R.id.tv_text, s);
LinearLayout layout = viewHolder.getView(R.id.layout_choose_unit);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(width, LinearLayout.LayoutParams.WRAP_CONTENT);
layout.setLayoutParams(layoutParams);
}
}
}
......@@ -16,6 +16,8 @@ import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.gingersoft.gsa.cloud.common.utils.toast.ToastUtils;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.mvp.bean.ConsumeReasonBean;
import com.lxj.xpopup.impl.ConfirmPopupView;
import com.lxj.xpopup.impl.InputConfirmPopupView;
import org.jetbrains.annotations.NotNull;
......@@ -29,61 +31,65 @@ import java.util.List;
* Time: 10:47
* Use: 庫存消耗彈窗
*/
public class InventoryConsumptionPopup extends InputConfirmPopupView {
public class InventoryConsumptionPopup extends ConfirmPopupView {
/**
* 庫存損耗原因
*/
private List<String> consumptionReasons;
private List<ConsumeReasonBean> consumptionReasons;
private EditText edRemarks;
private EditText edInput;
private RecyclerView rvConsumptionReason;
private OnConfirmClickListener onConfirmClickListener;
private int maxConsumption;
/**
* @param context
* @param consumptionReasons 庫存消耗原因
* @param maxConsumption 最大消耗數
* @param onConfirmClickListener 確認按鈕回調
* @param consumeReasonBeans 庫存消耗原因
* @param maxConsumption 最大消耗數
*/
public InventoryConsumptionPopup(@NonNull Context context, List<String> consumptionReasons, int maxConsumption, OnConfirmClickListener onConfirmClickListener) {
public InventoryConsumptionPopup(@NonNull Context context, List<ConsumeReasonBean> consumeReasonBeans, int maxConsumption) {
super(context, R.layout.popup_inventory_consumption);
this.consumptionReasons = consumptionReasons;
this.onConfirmClickListener = onConfirmClickListener;
this.consumptionReasons = consumeReasonBeans;
this.maxConsumption = maxConsumption;
}
public void setOnConfirmClickListener(OnConfirmClickListener onConfirmClickListener) {
this.onConfirmClickListener = onConfirmClickListener;
}
@Override
protected void onCreate() {
super.onCreate();
edRemarks = findViewById(R.id.ed_inventory_consumption_remark);
edInput = findViewById(R.id.et_input);
rvConsumptionReason = findViewById(R.id.rv_inventory_consumption_reason);
ConsumptionReasonAdapter consumptionReasonAdapter = new ConsumptionReasonAdapter();
consumptionReasonAdapter.setOnItemClickListener((adapter, view, position) -> consumptionReasonAdapter.setSelectIndex(position));
consumptionReasonAdapter.setOnItemChildClickListener((adapter, view, position) -> consumptionReasonAdapter.setSelectIndex(position));
rvConsumptionReason.setLayoutManager(new GridLayoutManager(getContext(), 2));
rvConsumptionReason.setAdapter(consumptionReasonAdapter);
findViewById(R.id.tv_confirm).setOnClickListener(v -> {
if (onConfirmClickListener != null) {
String s = getEditText().getText().toString();
String s = edInput.getText().toString();
try {
int i = Integer.parseInt(s);
if (i > 0) {
if (i > maxConsumption) {
getEditText().setError("不能超過當前庫存數量:" + maxConsumption);
edInput.setError("不能超過當前庫存數量:" + maxConsumption);
} else {
onConfirmClickListener.onConfirm(i, consumptionReasonAdapter.getSelectIndex(), edRemarks.getText().toString());
}
} else {
ToastUtils.show(getContext(), "請輸入消耗庫存數");
getEditText().setError("請輸入消耗庫存數");
edInput.setError("請輸入消耗庫存數");
}
} catch (NumberFormatException e) {
e.printStackTrace();
ToastUtils.show(getContext(), "請輸入消耗庫存數");
getEditText().setError("請輸入消耗庫存數");
edInput.setError("請輸入消耗庫存數");
}
}
});
getEditText().addTextChangedListener(new TextWatcher() {
edInput.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
......@@ -99,7 +105,7 @@ public class InventoryConsumptionPopup extends InputConfirmPopupView {
try {
int i = Integer.parseInt(s.toString());
if (i > maxConsumption) {
getEditText().setError("不能超過當前庫存數量:" + maxConsumption);
edInput.setError("不能超過當前庫存數量:" + maxConsumption);
}
} catch (NumberFormatException e) {
e.printStackTrace();
......@@ -111,6 +117,7 @@ public class InventoryConsumptionPopup extends InputConfirmPopupView {
public interface OnConfirmClickListener {
/**
* 確認時,將消耗的庫存,原因,備註傳遞回去
*
* @param consumptionNum 消耗的庫存數量
* @param reasonIndex 原因下標
* @param remarks 備註
......@@ -118,17 +125,18 @@ public class InventoryConsumptionPopup extends InputConfirmPopupView {
void onConfirm(int consumptionNum, int reasonIndex, String remarks);
}
private class ConsumptionReasonAdapter extends BaseQuickAdapter<String, BaseViewHolder> {
private class ConsumptionReasonAdapter extends BaseQuickAdapter<ConsumeReasonBean, BaseViewHolder> {
private int selectIndex = 0;
public ConsumptionReasonAdapter() {
super(R.layout.item_consumption_reason, consumptionReasons);
addChildClickViewIds(R.id.cb_consumption_reason);
}
@Override
protected void convert(@NotNull BaseViewHolder viewHolder, String s) {
protected void convert(@NotNull BaseViewHolder viewHolder, ConsumeReasonBean consumeReasonBean) {
AppCompatCheckBox compatCheckBox = viewHolder.getView(R.id.cb_consumption_reason);
compatCheckBox.setText(s);
compatCheckBox.setText(consumeReasonBean.getDescription());
compatCheckBox.setChecked(viewHolder.getAdapterPosition() == selectIndex);
}
......@@ -137,10 +145,11 @@ public class InventoryConsumptionPopup extends InputConfirmPopupView {
}
public void setSelectIndex(int selectIndex) {
if (this.selectIndex < getData().size()) {
notifyItemChanged(this.selectIndex);
}
int lastSelect = this.selectIndex;
this.selectIndex = selectIndex;
if (lastSelect < getData().size()) {
notifyItemChanged(lastSelect);
}
if (this.selectIndex < getData().size()) {
notifyItemChanged(this.selectIndex);
}
......
......@@ -137,6 +137,7 @@
style="@style/Second_Category_Style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
android:layout_marginLeft="@dimen/dp_15"
android:layout_marginTop="@dimen/dp_8"
android:background="@drawable/shape_border_white_bg"
......@@ -167,6 +168,7 @@
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_13"
android:layout_marginTop="@dimen/dp_8"
android:visibility="gone"
android:background="@drawable/shape_color_da_stoke_fifteen_corners"
android:gravity="center"
android:text="+新增類別"
......
......@@ -10,24 +10,25 @@
android:id="@+id/food_ingredients_category_topbar"
android:layout_width="match_parent"
android:layout_height="@dimen/head_height"
android:fitsSystemWindows="true"
android:background="@color/theme_color"
android:fitsSystemWindows="true"
app:qmui_topbar_title_color="@color/theme_white_color" />
<com.qmuiteam.qmui.widget.section.QMUIStickySectionLayout
android:id="@+id/food_ingredients_category_section_layout"
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_food_select_category"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
android:layout_weight="1"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_marginBottom="@dimen/dp_20"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_20"
android:layout_marginRight="@dimen/dp_20"
android:layout_marginTop="@dimen/dp_10"
android:layout_height="wrap_content">
android:layout_marginRight="@dimen/dp_20"
android:layout_marginBottom="@dimen/dp_20"
android:orientation="horizontal">
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id="@+id/btn_food_ingredients_confirm"
......@@ -44,9 +45,9 @@
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_20"
android:layout_weight="1"
android:textColor="@color/color_3c"
android:background="@drawable/shape_black_border_small_radius"
android:text="取消" />
android:text="取消"
android:textColor="@color/color_3c" />
</LinearLayout>
</LinearLayout>
\ No newline at end of file
......@@ -23,9 +23,9 @@
android:layout_width="match_parent"
android:layout_height="@dimen/dp_40"
android:layout_margin="@dimen/dp_10"
android:visibility="gone"
android:background="@drawable/shape_white_eight_corners_bg"
android:orientation="horizontal">
android:orientation="horizontal"
android:visibility="gone">
<ImageView
android:layout_width="@dimen/dp_20"
......@@ -156,14 +156,39 @@
android:textSize="@dimen/dp_16"
android:visibility="gone" />
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id="@+id/btn_food_ingredients_confirm"
style="@style/Save_Btn_Style"
<FrameLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="確定"
android:visibility="visible" />
android:layout_weight="1">
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id="@+id/btn_food_ingredients_confirm"
style="@style/Save_Btn_Style"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5"
android:layout_marginRight="@dimen/dp_5"
android:layout_marginBottom="@dimen/dp_5"
android:text="確定"
android:visibility="visible" />
<TextView
android:id="@+id/tv_ingredients_food_num"
android:layout_width="@dimen/dp_20"
android:layout_height="@dimen/dp_20"
android:layout_gravity="right"
android:autoSizeMaxTextSize="@dimen/dp_8"
android:autoSizeMinTextSize="@dimen/dp_4"
android:background="@drawable/ui_shape_red_oval"
android:gravity="center"
android:text="3"
android:textColor="@color/white"
android:textSize="@dimen/dp_12"
android:visibility="gone"
app:layout_constraintRight_toRightOf="@id/iv_shopping_cart"
app:layout_constraintTop_toTopOf="@id/iv_shopping_cart" />
</FrameLayout>
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id="@+id/btn_food_ingredients_cancel"
......@@ -171,6 +196,8 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_20"
android:layout_marginTop="@dimen/dp_5"
android:layout_marginBottom="@dimen/dp_5"
android:layout_weight="1"
android:text="取消"
android:visibility="visible" />
......
......@@ -62,7 +62,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_9"
android:text="採購單號:"
tools:text="採購單號:"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_14" />
......@@ -71,8 +71,9 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:text="入庫單號:"
tools:text="入庫單號:"
android:textColor="@color/color_3c"
android:visibility="gone"
android:textSize="@dimen/dp_14" />
<LinearLayout
......@@ -136,8 +137,7 @@
android:layout_width="@dimen/dp_52"
android:layout_height="@dimen/dp_46"
android:layout_gravity="bottom"
android:layout_marginLeft="@dimen/dp_32"
android:src="@drawable/img_partial_receipt" />
android:layout_marginLeft="@dimen/dp_25" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
......
......@@ -19,6 +19,7 @@
android:paddingBottom="@dimen/dp_10">
<ImageView
android:id="@+id/iv_warehouse_img"
android:layout_width="@dimen/dp_77"
android:layout_height="@dimen/dp_77"
android:layout_marginLeft="@dimen/dp_13" />
......@@ -50,10 +51,11 @@
tools:text="100" />
<TextView
android:id="@+id/tv_food_unit"
style="@style/WareHouse_Details_TextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="盒" />
tools:text="盒" />
<View
android:layout_width="0dp"
......@@ -81,7 +83,7 @@
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_vertical"
tools:text="單價:$10.00" />
tools:text="最新單價:$10.00" />
<TextView
android:id="@+id/tv_warehouse_total_amount"
......
......@@ -12,12 +12,14 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_36"
android:layout_marginRight="@dimen/dp_36"
android:scaleType="fitXY" />
android:layout_marginRight="@dimen/dp_36" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_20"
android:layout_marginTop="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_20"
android:orientation="horizontal">
<TextView
......@@ -37,6 +39,11 @@
android:textStyle="bold"
tools:text="100" />
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
......@@ -54,11 +61,12 @@
tools:text="+100" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_20"
android:layout_marginTop="@dimen/dp_15"
android:layout_marginRight="@dimen/dp_20"
android:orientation="horizontal">
<TextView
......@@ -73,9 +81,16 @@
android:layout_width="@dimen/dp_86"
android:layout_height="wrap_content"
android:background="@drawable/shape_square_edit_border_3c"
android:text="2"
android:gravity="center"
android:hint="請輸入"
android:inputType="number"
android:paddingTop="@dimen/dp_9"
android:paddingBottom="@dimen/dp_9"
android:text="0"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_14" />
android:textCursorDrawable="@drawable/cursor_theme"
android:textSize="@dimen/dp_14"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatCheckBox
......@@ -9,7 +9,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:layout_marginTop="@dimen/dp_15"
android:layout_marginTop="@dimen/dp_10"
android:text="正常消耗" />
......
<?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_purchase_category"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_5"
android:layout_marginTop="@dimen/dp_10"
app:elevation="@dimen/dp_10">
<com.qmuiteam.qmui.alpha.QMUIAlphaTextView
android:id="@+id/tv_second_category_title"
style="@style/Second_Category_Style"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="@color/s_3c_to_white"
android:textSize="@dimen/dp_14"
tools:text="瓜果類" />
<com.qmuiteam.qmui.alpha.QMUIAlphaImageButton
android:id="@+id/iv_category_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:src="@drawable/ic_red_circular_delete"
android:visibility="gone" />
</androidx.cardview.widget.CardView>
\ No newline at end of file
......@@ -58,8 +58,8 @@
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:visibility="gone"
android:textSize="@dimen/dp_12"
android:visibility="gone"
tools:text="SP001" />
<TextView
......@@ -155,20 +155,24 @@
android:layout_height="@dimen/dp_24"
android:background="@drawable/ic_circle_gray_sub" />
<EditText
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/ed_food_ingredient_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_10"
android:layout_marginLeft="@dimen/dp_4"
android:layout_marginRight="@dimen/dp_4"
android:background="@null"
android:focusable="true"
android:focusableInTouchMode="true"
android:gravity="center"
android:inputType="number"
android:maxLength="4"
android:paddingLeft="@dimen/dp_4"
android:paddingRight="@dimen/dp_4"
android:text="0"
android:maxLines="1"
android:minWidth="@dimen/dp_30"
android:textColor="@color/black"
android:textSize="@dimen/dp_22" />
android:textCursorDrawable="@drawable/cursor_theme"
android:textSize="@dimen/dp_22"
tools:text="10" />
<com.qmuiteam.qmui.layout.QMUIButton
android:id="@+id/btn_food_operation_add"
......
......@@ -13,9 +13,9 @@
<ImageView
android:id="@+id/iv_img_delete"
android:layout_width="@dimen/dp_20"
android:layout_height="@dimen/dp_20"
android:layout_width="@dimen/dp_17"
android:layout_height="@dimen/dp_17"
android:layout_gravity="right"
android:src="@drawable/icon_dialog_close" />
android:src="@drawable/ic_red_delete_pic" />
</FrameLayout>
\ No newline at end of file
......@@ -128,11 +128,11 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/dp_5"
android:layout_marginRight="@dimen/dp_5"
android:background="@null"
android:gravity="end|center_vertical"
android:inputType="numberDecimal"
android:maxLines="1"
android:paddingRight="@dimen/dp_10"
android:textColor="@color/color_3c"
android:textColorHighlight="@color/theme_color"
android:textCursorDrawable="@drawable/cursor_theme"
......@@ -163,13 +163,13 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/dp_5"
android:layout_marginRight="@dimen/dp_5"
android:background="@null"
android:textCursorDrawable="@drawable/cursor_theme"
android:paddingRight="@dimen/dp_10"
android:gravity="end|center_vertical"
android:inputType="numberDecimal"
android:maxLines="1"
android:textColor="@color/color_3c"
android:textCursorDrawable="@drawable/cursor_theme"
android:textSize="@dimen/dp_15"
android:textStyle="bold"
tools:text="2" />
......
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/card_purchase_category"
android:layout_width="match_parent"
android:layout_marginLeft="@dimen/dp_3"
android:layout_marginTop="@dimen/dp_8"
android:layout_marginRight="@dimen/dp_4"
android:layout_height="wrap_content">
<com.qmuiteam.qmui.alpha.QMUIAlphaTextView
android:id="@+id/tv_second_category_title"
style="@style/Second_Category_Style"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_3"
android:layout_marginTop="@dimen/dp_8"
android:layout_marginRight="@dimen/dp_4"
android:background="@drawable/s_app_color_to_bf"
android:gravity="center"
android:textColor="@color/s_3c_to_white"
android:textSize="@dimen/dp_14"
......@@ -23,6 +22,7 @@
android:id="@+id/iv_category_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
android:layout_gravity="right"
android:src="@drawable/ic_red_circular_delete" />
</FrameLayout>
\ No newline at end of file
</androidx.cardview.widget.CardView>
\ No newline at end of file
......@@ -11,9 +11,9 @@
android:layout_width="match_parent"
android:layout_height="@dimen/dp_55"
android:gravity="center_vertical"
android:layout_marginBottom="@dimen/dp_1"
android:orientation="horizontal"
android:paddingLeft="@dimen/dp_18"
android:paddingRight="@dimen/dp_18">
android:paddingLeft="@dimen/dp_18">
<TextView
android:id="@+id/tv_radio_section_title"
......@@ -26,8 +26,10 @@
<CheckBox
android:id="@+id/cb_radio_section"
android:layout_width="@dimen/dp_24"
android:layout_height="@dimen/dp_24"
android:layout_width="wrap_content"
android:paddingRight="@dimen/dp_18"
android:gravity="center"
android:layout_height="match_parent"
android:button="@drawable/selector_radio_circle_bg" />
</LinearLayout>
......
......@@ -189,7 +189,7 @@
android:layout_height="@dimen/dp_24"
android:background="@drawable/ic_circle_gray_sub" />
<EditText
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/ed_food_ingredient_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
......
......@@ -4,11 +4,11 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_10"
android:layout_marginTop="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_10"
android:background="@drawable/shape_white_eight_corners_bg"
android:elevation="@dimen/dp_10"
android:orientation="vertical">
android:orientation="vertical"
android:paddingBottom="@dimen/dp_4">
<LinearLayout
android:layout_width="match_parent"
......@@ -51,17 +51,18 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/dp_9"
android:orientation="horizontal"
android:paddingLeft="@dimen/dp_9"
android:paddingRight="@dimen/dp_9"
android:orientation="horizontal">
android:paddingTop="@dimen/dp_9"
android:paddingRight="@dimen/dp_9">
<TextView
android:id="@+id/tv_warehouse_order_time_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="下單日期:"
android:textColor="@color/color_3c"
android:textSize="@dimen/sp_16"
tools:text="下單日期:" />
android:textSize="@dimen/sp_16" />
<TextView
android:id="@+id/tv_warehouse_details_order_time"
......@@ -86,18 +87,19 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/dp_9"
android:orientation="horizontal"
android:paddingLeft="@dimen/dp_9"
android:paddingRight="@dimen/dp_9"
android:paddingBottom="@dimen/dp_10"
android:orientation="horizontal">
android:paddingTop="@dimen/dp_9"
android:layout_marginBottom="@dimen/dp_6"
android:paddingRight="@dimen/dp_9">
<TextView
android:id="@+id/tv_warehouse_time_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="入庫日期:"
android:textColor="@color/color_3c"
android:textSize="@dimen/sp_16"
tools:text="入庫日期:" />
android:textSize="@dimen/sp_16" />
<TextView
android:id="@+id/tv_warehouse_details_time"
......@@ -118,4 +120,21 @@
android:textSize="@dimen/sp_14"
tools:text="採購入庫" />
</LinearLayout>
<TextView
android:id="@+id/tv_warehouse_state"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginRight="@dimen/dp_4"
android:paddingLeft="@dimen/dp_10"
android:paddingRight="@dimen/dp_10"
android:paddingTop="@dimen/dp_4"
android:paddingBottom="@dimen/dp_4"
android:privateImeOptions="@dimen/dp_10"
android:textColor="@color/white"
android:textSize="@dimen/dp_14"
android:visibility="gone"
tools:text="即將過期:3日" />
</LinearLayout>
\ No newline at end of file
......@@ -51,7 +51,8 @@
<TextView
android:id="@+id/tv_warehouse_item_total_amount"
style="@style/WareHouse_item_TextStyle"
android:layout_width="@dimen/dp_55"
android:layout_width="wrap_content"
android:minWidth="@dimen/dp_55"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/dp_0"
android:text="總價" />
......
......@@ -53,7 +53,8 @@
<TextView
android:id="@+id/tv_warehouse_item_total_amount"
style="@style/WareHouse_item_TextStyle"
android:layout_width="@dimen/dp_55"
android:layout_width="wrap_content"
android:minWidth="@dimen/dp_55"
android:drawableRight="@drawable/ic_sort"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/dp_0"
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_choose_unit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:paddingTop="@dimen/dp_7"
android:paddingBottom="@dimen/dp_7">
<ImageView
android:id="@+id/iv_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/tv_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="但"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_15" />
</LinearLayout>
\ No newline at end of file
......@@ -25,15 +25,18 @@
<EditText
android:id="@+id/et_input"
android:layout_width="@dimen/dp_70"
android:layout_height="@dimen/dp_21"
android:layout_height="wrap_content"
android:maxLines="1"
android:background="@drawable/shape_login_edit_border"
android:drawablePadding="@dimen/dp_3"
android:paddingTop="@dimen/dp_2"
android:paddingBottom="@dimen/dp_2"
android:textCursorDrawable="@drawable/cursor_theme"
android:paddingLeft="@dimen/dp_5"
android:paddingRight="@dimen/dp_5"
android:background="@drawable/selector_edit_48_aaa_bg"
android:inputType="number"
android:text=""
android:textColor="@color/color_3c"
android:textSize="@dimen/sp_16" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
......@@ -79,7 +82,7 @@
android:gravity="center"
android:paddingTop="@dimen/dp_12"
android:paddingBottom="@dimen/dp_12"
android:text="確定" />
android:text="@string/str_determine" />
<com.qmuiteam.qmui.alpha.QMUIAlphaTextView
android:id="@+id/tv_cancel"
......@@ -91,7 +94,7 @@
android:gravity="center"
android:paddingTop="@dimen/dp_12"
android:paddingBottom="@dimen/dp_12"
android:text="確定" />
android:text="@string/str_cancel" />
</LinearLayout>
</LinearLayout>
\ No newline at end of file
......@@ -11,6 +11,10 @@
<string name="str_supplier">供應商</string>
<string name="str_species">種類</string>
<string name="str_inventory_consumption">庫存消耗</string>
<string name="str_consumption_inventory">消耗庫存:</string>
<string name="str_manual_input">手動輸入</string>
<string name="str_remark">備註</string>
<string name="str_remark_colon">備註:</string>
<string name="str_save">保存</string>
......@@ -18,5 +22,14 @@
<string name="str_format_purchase_no">採購單號:%1$s</string>
<string name="str_format_warehouse_no">入庫單號:%1$s</string>
<string name="str_format_remark">備註:%1$d</string>
<string name="str_format_positive">+%1$d</string>
<string name="str_format_positive">+%1$s</string>
<string name="str_format_less">-%1$s</string>
<string name="str_unit_price_colon">單價:$%1$.2f</string>
<string name="str_latest_unit_price_colon">最新單價:$%1$.2f</string>
<string name="str_total_amount_colon">總價:$%1$.2f</string>
<string name="str_cancel">取消</string>
<string name="str_determine">確定</string>
<string name="str_delete_category_tip">是否確認刪除該類別【%1$s】,子類和食材將一同刪除?</string>
</resources>
\ No newline at end of file
......@@ -35,6 +35,7 @@ ext {
//support
"appcompat-v7" : 'androidx.appcompat:appcompat:1.0.2',//不要超過1.0.2,不然android5.1.1用webview會有問題
"design" : 'com.google.android.material:material:1.0.0',
"support-design" : 'com.android.support:design:28.0.0',
"support-v4" : 'androidx.legacy:legacy-support-v4:1.0.0',
"cardview-v7" : 'androidx.cardview:cardview:1.0.0',
"annotations" : 'androidx.annotation:annotation:1.0.0',
......
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (malloc) failed to allocate 131088 bytes for Chunk::new
# Possible reasons:
# The system is out of physical RAM or swap space
# The process is running with CompressedOops enabled, and the Java Heap may be blocking the growth of the native heap
# Possible solutions:
# Reduce memory load on the system
# Increase physical memory or swap space
# Check if swap backing store is full
# Decrease Java heap size (-Xmx/-Xms)
# Decrease number of Java threads
# Decrease Java thread stack sizes (-Xss)
# Set larger code cache with -XX:ReservedCodeCacheSize=
# JVM is running with Unscaled Compressed Oops mode in which the Java heap is
# placed in the first 4GB address space. The Java Heap base address is the
# maximum limit for the native heap growth. Please use -XX:HeapBaseMinAddress
# to set the Java Heap base and to place the Java Heap above 4GB virtual address.
# This output file may be truncated or incomplete.
#
# Out of Memory Error (allocation.cpp:389), pid=16600, tid=0x0000000000001358
#
# JRE version: Java(TM) SE Runtime Environment (8.0_241-b07) (build 1.8.0_241-b07)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.241-b07 mixed mode windows-amd64 compressed oops)
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
--------------- T H R E A D ---------------
Current thread (0x000000001687c000): JavaThread "C2 CompilerThread2" daemon [_thread_in_native, id=4952, stack(0x0000000019050000,0x0000000019150000)]
Stack: [0x0000000019050000,0x0000000019150000]
[error occurred during error reporting (printing stack bounds), id 0xc0000005]
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
Current CompileTask:
C2:2504540 66059 % 4 com.android.tools.r8.ir.regalloc.a::a @ 855 (1761 bytes)
--------------- P R O C E S S ---------------
Java Threads: ( => current thread )
0x000000002aa13800 JavaThread "WorkerExecutor Queue Thread 10" [_thread_in_Java, id=20500, stack(0x000000001c5a0000,0x000000001c6a0000)]
0x000000002aa0a800 JavaThread "ForkJoinPool.commonPool-worker-2" daemon [_thread_blocked, id=13588, stack(0x0000000039fe0000,0x000000003a0e0000)]
0x000000002aa0b800 JavaThread "ForkJoinPool.commonPool-worker-7" daemon [_thread_blocked, id=5768, stack(0x0000000039de0000,0x0000000039ee0000)]
0x000000002efad800 JavaThread "Cache worker for Java compile cache (D:\GSA-Cloud\.gradle\6.1.1\javaCompile)" [_thread_blocked, id=4920, stack(0x0000000036ff0000,0x00000000370f0000)]
0x0000000026904000 JavaThread "WorkerExecutor Queue Thread 9" [_thread_in_Java, id=22728, stack(0x00000000366f0000,0x00000000367f0000)]
0x00000000286bc800 JavaThread "stdout" [_thread_in_native, id=23200, stack(0x00000000365f0000,0x00000000366f0000)]
0x00000000286af800 JavaThread "stderr" [_thread_in_native, id=16032, stack(0x00000000364f0000,0x00000000365f0000)]
0x00000000286b6800 JavaThread "stdout" [_thread_in_native, id=6532, stack(0x0000000034de0000,0x0000000034ee0000)]
0x00000000286b5800 JavaThread "stderr" [_thread_in_native, id=12004, stack(0x00000000342e0000,0x00000000343e0000)]
0x0000000023f61800 JavaThread "stdout" [_thread_in_native, id=3924, stack(0x0000000033d30000,0x0000000033e30000)]
0x0000000023f5f000 JavaThread "stderr" [_thread_in_native, id=2380, stack(0x0000000033c30000,0x0000000033d30000)]
0x0000000023f5d000 JavaThread "stdout" [_thread_in_native, id=15580, stack(0x0000000033b30000,0x0000000033c30000)]
0x0000000023f60800 JavaThread "stderr" [_thread_in_native, id=20008, stack(0x0000000033a30000,0x0000000033b30000)]
0x0000000023f5e800 JavaThread "stdout" [_thread_in_native, id=17732, stack(0x0000000033930000,0x0000000033a30000)]
0x0000000023f54000 JavaThread "stderr" [_thread_in_native, id=22800, stack(0x0000000033830000,0x0000000033930000)]
0x0000000023f5a000 JavaThread "stdout" [_thread_in_native, id=23692, stack(0x0000000033730000,0x0000000033830000)]
0x000000001d048800 JavaThread "stderr" [_thread_in_native, id=11164, stack(0x0000000033630000,0x0000000033730000)]
0x000000001d04c000 JavaThread "stdout" [_thread_in_native, id=21708, stack(0x0000000033530000,0x0000000033630000)]
0x000000001d047800 JavaThread "stderr" [_thread_in_native, id=16516, stack(0x0000000033430000,0x0000000033530000)]
0x000000001d04b800 JavaThread "stdout" [_thread_in_native, id=20796, stack(0x0000000033330000,0x0000000033430000)]
0x000000001d04a000 JavaThread "stderr" [_thread_in_native, id=19484, stack(0x0000000033230000,0x0000000033330000)]
0x000000001d049000 JavaThread "pool-58-thread-1" [_thread_blocked, id=6456, stack(0x0000000032f20000,0x0000000033020000)]
0x000000001d03f000 JavaThread "WorkerExecutor Queue Thread 7" [_thread_in_vm, id=8608, stack(0x000000002e9c0000,0x000000002eac0000)]
0x000000001d045800 JavaThread "WorkerExecutor Queue Thread 6" [_thread_in_Java, id=10884, stack(0x0000000033130000,0x0000000033230000)]
0x000000001d042000 JavaThread "WorkerExecutor Queue Thread 5" [_thread_in_Java, id=22816, stack(0x0000000033030000,0x0000000033130000)]
0x000000001d044800 JavaThread "WorkerExecutor Queue Thread 4" [_thread_in_Java, id=23332, stack(0x0000000032e20000,0x0000000032f20000)]
0x00000000195a8000 JavaThread "WorkerExecutor Queue Thread 3" [_thread_blocked, id=22856, stack(0x0000000032d20000,0x0000000032e20000)]
0x00000000195a4800 JavaThread "WorkerExecutor Queue Thread 2" [_thread_in_Java, id=15416, stack(0x0000000030d60000,0x0000000030e60000)]
0x00000000195a6800 JavaThread "WorkerExecutor Queue" [_thread_in_Java, id=14444, stack(0x000000002e6c0000,0x000000002e7c0000)]
0x000000001959a800 JavaThread "Cache worker for execution history cache (D:\GSA-Cloud\.gradle\6.1.1\executionHistory)" [_thread_blocked, id=22152, stack(0x000000002e5c0000,0x000000002e6c0000)]
0x000000001959a000 JavaThread "Execution worker for ':' Thread 7" [_thread_blocked, id=14852, stack(0x000000002d880000,0x000000002d980000)]
0x00000000195a0800 JavaThread "Execution worker for ':' Thread 6" [_thread_blocked, id=18548, stack(0x000000002d580000,0x000000002d680000)]
0x00000000195a0000 JavaThread "Execution worker for ':' Thread 5" [_thread_blocked, id=23848, stack(0x000000002c7c0000,0x000000002c8c0000)]
0x000000001959f000 JavaThread "Execution worker for ':' Thread 4" [_thread_blocked, id=13868, stack(0x000000002bd50000,0x000000002be50000)]
0x000000001959d800 JavaThread "Execution worker for ':' Thread 3" [_thread_blocked, id=24220, stack(0x000000002b630000,0x000000002b730000)]
0x000000001a476000 JavaThread "Execution worker for ':' Thread 2" [_thread_blocked, id=3776, stack(0x000000002b250000,0x000000002b350000)]
0x000000001a47c000 JavaThread "Execution worker for ':'" [_thread_blocked, id=19656, stack(0x000000002b150000,0x000000002b250000)]
0x000000001a477000 JavaThread "Cache worker for file content cache (D:\GSA-Cloud\.gradle\6.1.1\fileContent)" [_thread_blocked, id=3152, stack(0x0000000028a90000,0x0000000028b90000)]
0x000000001a479000 JavaThread "Cache worker for Build Output Cleanup Cache (D:\GSA-Cloud\.gradle\buildOutputCleanup)" [_thread_blocked, id=24100, stack(0x0000000025870000,0x0000000025970000)]
0x000000001a475800 JavaThread "pool-57-thread-1" [_thread_blocked, id=8732, stack(0x0000000024a70000,0x0000000024b70000)]
0x000000001a474800 JavaThread "Build operations Thread 8" [_thread_blocked, id=22712, stack(0x0000000024770000,0x0000000024870000)]
0x000000001a46d000 JavaThread "Build operations Thread 7" [_thread_blocked, id=11384, stack(0x0000000024270000,0x0000000024370000)]
0x000000001a474000 JavaThread "Build operations Thread 6" [_thread_blocked, id=6164, stack(0x0000000024170000,0x0000000024270000)]
0x000000001a473000 JavaThread "Build operations Thread 5" [_thread_blocked, id=15544, stack(0x0000000024070000,0x0000000024170000)]
0x000000001a472800 JavaThread "Build operations Thread 4" [_thread_blocked, id=10664, stack(0x0000000022f70000,0x0000000023070000)]
0x000000001a470000 JavaThread "Build operations Thread 3" [_thread_blocked, id=20348, stack(0x0000000022e70000,0x0000000022f70000)]
0x000000001a46f800 JavaThread "Build operations Thread 2" [_thread_blocked, id=13124, stack(0x0000000022d70000,0x0000000022e70000)]
0x000000001a471000 JavaThread "Build operations" [_thread_blocked, id=23488, stack(0x00000000225a0000,0x00000000226a0000)]
0x000000001a46e000 JavaThread "Cache worker for cache directory md-rule (D:\gradle\caches\6.1.1\md-rule)" [_thread_blocked, id=23140, stack(0x0000000020ad0000,0x0000000020bd0000)]
0x0000000026911800 JavaThread "Cache worker for cache directory md-supplier (D:\gradle\caches\6.1.1\md-supplier)" [_thread_blocked, id=23192, stack(0x000000001f9d0000,0x000000001fad0000)]
0x0000000026910000 JavaThread "Cache worker for file hash cache (D:\GSA-Cloud\.gradle\6.1.1\fileHashes)" [_thread_blocked, id=12956, stack(0x000000001f340000,0x000000001f440000)]
0x000000002690e800 JavaThread "Cache worker for checksums cache (D:\GSA-Cloud\.gradle\checksums)" [_thread_blocked, id=17424, stack(0x000000001c9a0000,0x000000001caa0000)]
0x000000002690c000 JavaThread "Thread-144" [_thread_blocked, id=18300, stack(0x000000001c6a0000,0x000000001c7a0000)]
0x000000002690d800 JavaThread "Asynchronous log dispatcher for DefaultDaemonConnection: socket connection from /127.0.0.1:52594 to /127.0.0.1:57151" [_thread_blocked, id=21184, stack(0x000000001c2a0000,0x000000001c3a0000)]
0x000000002690d000 JavaThread "Cancel handler" [_thread_blocked, id=23088, stack(0x0000000000b50000,0x0000000000c50000)]
0x000000002690f000 JavaThread "Handler for socket connection from /127.0.0.1:52594 to /127.0.0.1:57151" [_thread_in_native, id=6388, stack(0x0000000000a50000,0x0000000000b50000)]
0x00000000286bd000 JavaThread "Daemon worker Thread 3" [_thread_blocked, id=22184, stack(0x000000001c1a0000,0x000000001c2a0000)]
0x00000000286b5000 JavaThread "Daemon Thread 3" [_thread_blocked, id=8308, stack(0x0000000000950000,0x0000000000a50000)]
0x0000000023f55800 JavaThread "RMI Reaper" [_thread_blocked, id=15660, stack(0x000000002e0e0000,0x000000002e1e0000)]
0x0000000023f5c000 JavaThread "RMI TCP Accept-0" daemon [_thread_in_native, id=15640, stack(0x000000002dfe0000,0x000000002e0e0000)]
0x0000000023f54800 JavaThread "GC Daemon" daemon [_thread_blocked, id=11740, stack(0x000000002dee0000,0x000000002dfe0000)]
0x0000000023f5b800 JavaThread "RMI Scheduler(0)" daemon [_thread_blocked, id=23724, stack(0x000000002bf20000,0x000000002c020000)]
0x0000000023f57000 JavaThread "Java2D Disposer" daemon [_thread_blocked, id=14904, stack(0x000000002d980000,0x000000002da80000)]
0x000000001a478800 JavaThread "Cache worker for Java compile cache (D:\gradle\caches\6.1.1\javaCompile)" [_thread_blocked, id=24244, stack(0x000000002c6c0000,0x000000002c7c0000)]
0x00000000186f0800 JavaThread "Cache worker for file content cache (D:\gradle\caches\6.1.1\fileContent)" [_thread_blocked, id=9508, stack(0x0000000026530000,0x0000000026630000)]
0x00000000195a6000 JavaThread "Memory manager" [_thread_blocked, id=21136, stack(0x0000000025570000,0x0000000025670000)]
0x00000000186f6000 JavaThread "Cache worker for execution history cache (D:\gradle\caches\6.1.1\executionHistory)" [_thread_blocked, id=16796, stack(0x000000001f6d0000,0x000000001f7d0000)]
0x00000000186f0000 JavaThread "Cache worker for file hash cache (D:\gradle\caches\6.1.1\fileHashes)" [_thread_blocked, id=20696, stack(0x000000001cea0000,0x000000001cfa0000)]
0x00000000186f4800 JavaThread "File lock request listener" [_thread_in_native, id=19784, stack(0x000000001cda0000,0x000000001cea0000)]
0x00000000186f3000 JavaThread "Cache worker for journal cache (D:\gradle\caches\journal-1)" [_thread_blocked, id=968, stack(0x000000001cca0000,0x000000001cda0000)]
0x000000001af71800 JavaThread "Daemon periodic checks" [_thread_blocked, id=8228, stack(0x000000001c0a0000,0x000000001c1a0000)]
0x000000001aee1800 JavaThread "Incoming local TCP Connector on port 52594" [_thread_in_native, id=12016, stack(0x000000001bef0000,0x000000001bff0000)]
0x0000000019508000 JavaThread "Daemon health stats" [_thread_blocked, id=2136, stack(0x000000001bbf0000,0x000000001bcf0000)]
0x000000001687e800 JavaThread "Service Thread" daemon [_thread_blocked, id=10496, stack(0x0000000019250000,0x0000000019350000)]
0x00000000186ef000 JavaThread "C1 CompilerThread3" daemon [_thread_blocked, id=16296, stack(0x0000000019150000,0x0000000019250000)]
=>0x000000001687c000 JavaThread "C2 CompilerThread2" daemon [_thread_in_native, id=4952, stack(0x0000000019050000,0x0000000019150000)]
0x0000000018691000 JavaThread "C2 CompilerThread1" daemon [_thread_in_native, id=22424, stack(0x0000000018f50000,0x0000000019050000)]
0x000000001868d000 JavaThread "C2 CompilerThread0" daemon [_thread_in_native, id=3312, stack(0x0000000018e50000,0x0000000018f50000)]
0x000000001868a800 JavaThread "Attach Listener" daemon [_thread_blocked, id=11144, stack(0x0000000018d50000,0x0000000018e50000)]
0x0000000018689800 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=13608, stack(0x0000000018c50000,0x0000000018d50000)]
0x0000000018670800 JavaThread "Finalizer" daemon [_thread_blocked, id=13780, stack(0x0000000018b50000,0x0000000018c50000)]
0x000000001686d000 JavaThread "Reference Handler" daemon [_thread_blocked, id=18976, stack(0x0000000018a50000,0x0000000018b50000)]
0x00000000029ae000 JavaThread "main" [_thread_blocked, id=7716, stack(0x0000000002860000,0x0000000002960000)]
Other Threads:
0x0000000016868800 VMThread [stack: 0x0000000018550000,0x0000000018650000] [id=19828]
0x000000001870a000 WatcherThread [stack: 0x0000000019350000,0x0000000019450000] [id=13028]
VM state:not at safepoint (normal execution)
VM Mutex/Monitor currently owned by a thread: None
heap address: 0x00000000a0000000, size: 1536 MB, Compressed Oops mode: 32-bit
Narrow klass base: 0x0000000000000000, Narrow klass shift: 3
Compressed class space size: 1073741824 Address: 0x0000000100000000
Heap:
PSYoungGen total 465920K, used 204380K [0x00000000e0000000, 0x0000000100000000, 0x0000000100000000)
eden space 407552K, 40% used [0x00000000e0000000,0x00000000ea17ea48,0x00000000f8e00000)
from space 58368K, 66% used [0x00000000fc700000,0x00000000fed18658,0x0000000100000000)
to space 58368K, 0% used [0x00000000f8e00000,0x00000000f8e00000,0x00000000fc700000)
ParOldGen total 797184K, used 409291K [0x00000000a0000000, 0x00000000d0a80000, 0x00000000e0000000)
object space 797184K, 51% used [0x00000000a0000000,0x00000000b8fb2f28,0x00000000d0a80000)
Metaspace used 256372K, capacity 274433K, committed 274560K, reserved 1288192K
class space used 32836K, capacity 36653K, committed 36736K, reserved 1048576K
Card table byte_map: [0x0000000011e70000,0x0000000012180000] byte_map_base: 0x0000000011970000
Marking Bits: (ParMarkBitMap*) 0x000000006c4abe30
Begin Bits: [0x0000000012b80000, 0x0000000014380000)
End Bits: [0x0000000014380000, 0x0000000015b80000)
Polling page: 0x0000000000750000
CodeCache: size=245760Kb used=176140Kb max_used=177482Kb free=69619Kb
bounds [0x0000000002ab0000, 0x000000000d900000, 0x0000000011ab0000]
total_blobs=45851 nmethods=44742 adapters=1016
compilation: enabled
Compilation events (10 events):
Event: 2504.110 Thread 0x00000000186ef000 66222 2 com.android.tools.r8.code.N::a (1 bytes)
Event: 2504.110 Thread 0x00000000186ef000 nmethod 66222 0x000000000c37ae90 code [0x000000000c37afe0, 0x000000000c37b130]
Event: 2504.128 Thread 0x00000000186ef000 66223 2 com.android.tools.r8.code.A1::a (17 bytes)
Event: 2504.128 Thread 0x00000000186ef000 nmethod 66223 0x000000000c37aad0 code [0x000000000c37ac40, 0x000000000c37ade8]
Event: 2504.138 Thread 0x00000000186ef000 66224 % 3 com.android.tools.r8.q.a.a.b.l2::<init> @ 79 (271 bytes)
Event: 2504.141 Thread 0x00000000186ef000 nmethod 66224% 0x000000000c684a10 code [0x000000000c684d40, 0x000000000c686b18]
Event: 2504.141 Thread 0x00000000186ef000 66225 3 com.android.tools.r8.q.a.a.b.l2::<init> (271 bytes)
Event: 2504.143 Thread 0x00000000186ef000 nmethod 66225 0x000000000d7ad4d0 code [0x000000000d7ad800, 0x000000000d7af438]
Event: 2504.212 Thread 0x00000000186ef000 66226 2 com.android.tools.r8.ir.regalloc.i::equals (106 bytes)
Event: 2504.213 Thread 0x00000000186ef000 nmethod 66226 0x000000000d7acf90 code [0x000000000d7ad100, 0x000000000d7ad370]
GC Heap History (10 events):
Event: 2501.703 GC heap before
{Heap before GC invocations=283 (full 17):
PSYoungGen total 459776K, used 432780K [0x00000000e0000000, 0x00000000fff00000, 0x0000000100000000)
eden space 400896K, 100% used [0x00000000e0000000,0x00000000f8780000,0x00000000f8780000)
from space 58880K, 54% used [0x00000000f8780000,0x00000000fa6a30b0,0x00000000fc100000)
to space 57344K, 0% used [0x00000000fc700000,0x00000000fc700000,0x00000000fff00000)
ParOldGen total 797184K, used 408063K [0x00000000a0000000, 0x00000000d0a80000, 0x00000000e0000000)
object space 797184K, 51% used [0x00000000a0000000,0x00000000b8e7fec8,0x00000000d0a80000)
Metaspace used 256315K, capacity 274409K, committed 274560K, reserved 1288192K
class space used 32834K, capacity 36649K, committed 36736K, reserved 1048576K
Event: 2501.738 GC heap after
Heap after GC invocations=283 (full 17):
PSYoungGen total 461824K, used 33596K [0x00000000e0000000, 0x00000000ffb80000, 0x0000000100000000)
eden space 408064K, 0% used [0x00000000e0000000,0x00000000e0000000,0x00000000f8e80000)
from space 53760K, 62% used [0x00000000fc700000,0x00000000fe7cf2c0,0x00000000ffb80000)
to space 55808K, 0% used [0x00000000f8e80000,0x00000000f8e80000,0x00000000fc500000)
ParOldGen total 797184K, used 408095K [0x00000000a0000000, 0x00000000d0a80000, 0x00000000e0000000)
object space 797184K, 51% used [0x00000000a0000000,0x00000000b8e87ec8,0x00000000d0a80000)
Metaspace used 256315K, capacity 274409K, committed 274560K, reserved 1288192K
class space used 32834K, capacity 36649K, committed 36736K, reserved 1048576K
}
Event: 2502.411 GC heap before
{Heap before GC invocations=284 (full 17):
PSYoungGen total 461824K, used 441660K [0x00000000e0000000, 0x00000000ffb80000, 0x0000000100000000)
eden space 408064K, 100% used [0x00000000e0000000,0x00000000f8e80000,0x00000000f8e80000)
from space 53760K, 62% used [0x00000000fc700000,0x00000000fe7cf2c0,0x00000000ffb80000)
to space 55808K, 0% used [0x00000000f8e80000,0x00000000f8e80000,0x00000000fc500000)
ParOldGen total 797184K, used 408095K [0x00000000a0000000, 0x00000000d0a80000, 0x00000000e0000000)
object space 797184K, 51% used [0x00000000a0000000,0x00000000b8e87ec8,0x00000000d0a80000)
Metaspace used 256325K, capacity 274409K, committed 274560K, reserved 1288192K
class space used 32834K, capacity 36649K, committed 36736K, reserved 1048576K
Event: 2502.435 GC heap after
Heap after GC invocations=284 (full 17):
PSYoungGen total 463872K, used 17210K [0x00000000e0000000, 0x0000000100000000, 0x0000000100000000)
eden space 408064K, 0% used [0x00000000e0000000,0x00000000e0000000,0x00000000f8e80000)
from space 55808K, 30% used [0x00000000f8e80000,0x00000000f9f4e940,0x00000000fc500000)
to space 55296K, 0% used [0x00000000fca00000,0x00000000fca00000,0x0000000100000000)
ParOldGen total 797184K, used 408143K [0x00000000a0000000, 0x00000000d0a80000, 0x00000000e0000000)
object space 797184K, 51% used [0x00000000a0000000,0x00000000b8e93ec8,0x00000000d0a80000)
Metaspace used 256325K, capacity 274409K, committed 274560K, reserved 1288192K
class space used 32834K, capacity 36649K, committed 36736K, reserved 1048576K
}
Event: 2503.198 GC heap before
{Heap before GC invocations=285 (full 17):
PSYoungGen total 463872K, used 425274K [0x00000000e0000000, 0x0000000100000000, 0x0000000100000000)
eden space 408064K, 100% used [0x00000000e0000000,0x00000000f8e80000,0x00000000f8e80000)
from space 55808K, 30% used [0x00000000f8e80000,0x00000000f9f4e940,0x00000000fc500000)
to space 55296K, 0% used [0x00000000fca00000,0x00000000fca00000,0x0000000100000000)
ParOldGen total 797184K, used 408143K [0x00000000a0000000, 0x00000000d0a80000, 0x00000000e0000000)
object space 797184K, 51% used [0x00000000a0000000,0x00000000b8e93ec8,0x00000000d0a80000)
Metaspace used 256353K, capacity 274409K, committed 274560K, reserved 1288192K
class space used 32834K, capacity 36649K, committed 36736K, reserved 1048576K
Event: 2503.265 GC heap after
Heap after GC invocations=285 (full 17):
PSYoungGen total 465920K, used 39083K [0x00000000e0000000, 0x0000000100000000, 0x0000000100000000)
eden space 410624K, 0% used [0x00000000e0000000,0x00000000e0000000,0x00000000f9100000)
from space 55296K, 70% used [0x00000000fca00000,0x00000000ff02af60,0x0000000100000000)
to space 56832K, 0% used [0x00000000f9100000,0x00000000f9100000,0x00000000fc880000)
ParOldGen total 797184K, used 408247K [0x00000000a0000000, 0x00000000d0a80000, 0x00000000e0000000)
object space 797184K, 51% used [0x00000000a0000000,0x00000000b8eadec8,0x00000000d0a80000)
Metaspace used 256353K, capacity 274409K, committed 274560K, reserved 1288192K
class space used 32834K, capacity 36649K, committed 36736K, reserved 1048576K
}
Event: 2503.766 GC heap before
{Heap before GC invocations=286 (full 17):
PSYoungGen total 465920K, used 449707K [0x00000000e0000000, 0x0000000100000000, 0x0000000100000000)
eden space 410624K, 100% used [0x00000000e0000000,0x00000000f9100000,0x00000000f9100000)
from space 55296K, 70% used [0x00000000fca00000,0x00000000ff02af60,0x0000000100000000)
to space 56832K, 0% used [0x00000000f9100000,0x00000000f9100000,0x00000000fc880000)
ParOldGen total 797184K, used 408247K [0x00000000a0000000, 0x00000000d0a80000, 0x00000000e0000000)
object space 797184K, 51% used [0x00000000a0000000,0x00000000b8eadec8,0x00000000d0a80000)
Metaspace used 256355K, capacity 274409K, committed 274560K, reserved 1288192K
class space used 32834K, capacity 36649K, committed 36736K, reserved 1048576K
Event: 2503.819 GC heap after
Heap after GC invocations=286 (full 17):
PSYoungGen total 451584K, used 40621K [0x00000000e0000000, 0x0000000100000000, 0x0000000100000000)
eden space 410624K, 0% used [0x00000000e0000000,0x00000000e0000000,0x00000000f9100000)
from space 40960K, 99% used [0x00000000f9100000,0x00000000fb8ab470,0x00000000fb900000)
to space 58368K, 0% used [0x00000000fc700000,0x00000000fc700000,0x0000000100000000)
ParOldGen total 797184K, used 408423K [0x00000000a0000000, 0x00000000d0a80000, 0x00000000e0000000)
object space 797184K, 51% used [0x00000000a0000000,0x00000000b8ed9ef8,0x00000000d0a80000)
Metaspace used 256355K, capacity 274409K, committed 274560K, reserved 1288192K
class space used 32834K, capacity 36649K, committed 36736K, reserved 1048576K
}
Event: 2504.304 GC heap before
{Heap before GC invocations=287 (full 17):
PSYoungGen total 451584K, used 451245K [0x00000000e0000000, 0x0000000100000000, 0x0000000100000000)
eden space 410624K, 100% used [0x00000000e0000000,0x00000000f9100000,0x00000000f9100000)
from space 40960K, 99% used [0x00000000f9100000,0x00000000fb8ab470,0x00000000fb900000)
to space 58368K, 0% used [0x00000000fc700000,0x00000000fc700000,0x0000000100000000)
ParOldGen total 797184K, used 408423K [0x00000000a0000000, 0x00000000d0a80000, 0x00000000e0000000)
object space 797184K, 51% used [0x00000000a0000000,0x00000000b8ed9ef8,0x00000000d0a80000)
Metaspace used 256372K, capacity 274433K, committed 274560K, reserved 1288192K
class space used 32836K, capacity 36653K, committed 36736K, reserved 1048576K
Event: 2504.342 GC heap after
Heap after GC invocations=287 (full 17):
PSYoungGen total 465920K, used 39009K [0x00000000e0000000, 0x0000000100000000, 0x0000000100000000)
eden space 407552K, 0% used [0x00000000e0000000,0x00000000e0000000,0x00000000f8e00000)
from space 58368K, 66% used [0x00000000fc700000,0x00000000fed18658,0x0000000100000000)
to space 58368K, 0% used [0x00000000f8e00000,0x00000000f8e00000,0x00000000fc700000)
ParOldGen total 797184K, used 409291K [0x00000000a0000000, 0x00000000d0a80000, 0x00000000e0000000)
object space 797184K, 51% used [0x00000000a0000000,0x00000000b8fb2f28,0x00000000d0a80000)
Metaspace used 256372K, capacity 274433K, committed 274560K, reserved 1288192K
class space used 32836K, capacity 36653K, committed 36736K, reserved 1048576K
}
Deoptimization events (10 events):
Event: 2493.890 Thread 0x00000000195a8000 Uncommon trap: reason=unstable_if action=reinterpret pc=0x000000000ca9b7e0 method=com.android.tools.r8.ir.conversion.N.a(Lcom/android/tools/r8/s/b/p0$a;Lcom/android/tools/r8/graph/Y;Lcom/android/tools/r8/graph/g0;Ljava/util/List;Z)V @ 152
Event: 2495.038 Thread 0x000000001d042000 Uncommon trap: reason=unstable_if action=reinterpret pc=0x000000000d217b24 method=com.android.tools.r8.ir.optimize.l.a(Lcom/android/tools/r8/s/b/k0;)Z @ 29
Event: 2495.408 Thread 0x0000000026904000 Uncommon trap: reason=class_check action=maybe_recompile pc=0x000000000c713d64 method=com.android.tools.r8.s.a.h.e.b(Lcom/android/tools/r8/s/b/k0;)V @ 379
Event: 2497.252 Thread 0x000000001d03f000 Uncommon trap: reason=unstable_if action=reinterpret pc=0x000000000d484754 method=com.android.tools.r8.s.b.k0.a(Lcom/android/tools/r8/s/b/k0;Lcom/android/tools/r8/ir/regalloc/e;)Z @ 311
Event: 2499.706 Thread 0x00000000195a8000 Uncommon trap: reason=unstable_if action=reinterpret pc=0x000000000d3496fc method=com.android.tools.r8.utils.T.a(C)Z @ 39
Event: 2501.133 Thread 0x00000000195a8000 Uncommon trap: reason=unstable_if action=reinterpret pc=0x000000000d8dcc20 method=com.android.tools.r8.ir.optimize.a0.a(Lcom/android/tools/r8/s/b/o;Lcom/android/tools/r8/ir/regalloc/e;Ljava/util/Set;Lcom/android/tools/r8/ir/optimize/E;)V @ 202
Event: 2501.542 Thread 0x00000000195a6800 Uncommon trap: reason=unstable_if action=reinterpret pc=0x000000000c609474 method=com.android.tools.r8.ir.regalloc.g.b()V @ 829
Event: 2502.323 Thread 0x000000002aa13800 Uncommon trap: reason=unstable_if action=reinterpret pc=0x000000000cc1cde0 method=com.android.tools.r8.ir.regalloc.j.a(I)Z @ 33
Event: 2502.932 Thread 0x000000001d042000 Uncommon trap: reason=unstable_if action=reinterpret pc=0x000000000cb52410 method=com.android.tools.r8.graph.Z$D.a(Lcom/android/tools/r8/graph/d0;)Lcom/android/tools/r8/graph/d0; @ 18
Event: 2503.875 Thread 0x0000000026904000 Uncommon trap: reason=unstable_if action=reinterpret pc=0x000000000d80b0fc method=com.android.tools.r8.s.b.o.O()Z @ 75
Classes redefined (0 events):
No events
Internal exceptions (10 events):
Event: 2476.786 Thread 0x00000000195a4800 Exception <a 'sun/nio/fs/WindowsException'> (0x00000000f185b0b0) thrown at [C:\ade\jenkins\workspace\8-2-build-windows-amd64-cygwin\jdk8u241\331\hotspot\src\share\vm\prims\jni.cpp, line 710]
Event: 2476.788 Thread 0x00000000195a4800 Exception <a 'sun/nio/fs/WindowsException'> (0x00000000f1dc4ae8) thrown at [C:\ade\jenkins\workspace\8-2-build-windows-amd64-cygwin\jdk8u241\331\hotspot\src\share\vm\prims\jni.cpp, line 710]
Event: 2476.790 Thread 0x00000000195a4800 Exception <a 'sun/nio/fs/WindowsException'> (0x00000000f1dca860) thrown at [C:\ade\jenkins\workspace\8-2-build-windows-amd64-cygwin\jdk8u241\331\hotspot\src\share\vm\prims\jni.cpp, line 710]
Event: 2476.792 Thread 0x00000000195a4800 Exception <a 'sun/nio/fs/WindowsException'> (0x00000000f1dd3c48) thrown at [C:\ade\jenkins\workspace\8-2-build-windows-amd64-cygwin\jdk8u241\331\hotspot\src\share\vm\prims\jni.cpp, line 710]
Event: 2477.033 Thread 0x00000000195a4800 Exception <a 'sun/nio/fs/WindowsException'> (0x00000000e22bc1d8) thrown at [C:\ade\jenkins\workspace\8-2-build-windows-amd64-cygwin\jdk8u241\331\hotspot\src\share\vm\prims\jni.cpp, line 710]
Event: 2477.035 Thread 0x00000000195a4800 Exception <a 'sun/nio/fs/WindowsException'> (0x00000000e2302ea0) thrown at [C:\ade\jenkins\workspace\8-2-build-windows-amd64-cygwin\jdk8u241\331\hotspot\src\share\vm\prims\jni.cpp, line 710]
Event: 2477.037 Thread 0x00000000195a4800 Exception <a 'sun/nio/fs/WindowsException'> (0x00000000e23085d8) thrown at [C:\ade\jenkins\workspace\8-2-build-windows-amd64-cygwin\jdk8u241\331\hotspot\src\share\vm\prims\jni.cpp, line 710]
Event: 2477.046 Thread 0x00000000195a4800 Exception <a 'sun/nio/fs/WindowsException'> (0x00000000e230e298) thrown at [C:\ade\jenkins\workspace\8-2-build-windows-amd64-cygwin\jdk8u241\331\hotspot\src\share\vm\prims\jni.cpp, line 710]
Event: 2478.573 Thread 0x00000000195a4800 Implicit null exception at 0x000000000d3f8bb8 to 0x000000000d3fdd2d
Event: 2491.023 Thread 0x000000001d03f000 Implicit null exception at 0x000000000d799dc4 to 0x000000000d7a09e5
Events (10 events):
Event: 2504.458 Thread 0x000000001d03f000 DEOPT PACKING pc=0x000000000d17a8c7 sp=0x000000002eabcfb0
Event: 2504.458 Thread 0x000000001d03f000 DEOPT UNPACKING pc=0x0000000002af7890 sp=0x000000002eabcea0 mode 0
Event: 2504.478 Thread 0x00000000195a4800 DEOPT PACKING pc=0x000000000cb06615 sp=0x0000000030e5c6f0
Event: 2504.478 Thread 0x00000000195a4800 DEOPT UNPACKING pc=0x0000000002af7890 sp=0x0000000030e5c728 mode 0
Event: 2504.500 Thread 0x000000001d03f000 DEOPT PACKING pc=0x000000000d17a2b7 sp=0x000000002eabcf50
Event: 2504.500 Thread 0x000000001d03f000 DEOPT UNPACKING pc=0x0000000002af7890 sp=0x000000002eabce38 mode 0
Event: 2504.523 Thread 0x00000000195a6800 DEOPT PACKING pc=0x000000000cb06615 sp=0x000000002e7bc690
Event: 2504.523 Thread 0x00000000195a6800 DEOPT UNPACKING pc=0x0000000002af7890 sp=0x000000002e7bc6c8 mode 0
Event: 2504.533 Thread 0x000000001d042000 DEOPT PACKING pc=0x000000000cb06615 sp=0x000000003312c830
Event: 2504.533 Thread 0x000000001d042000 DEOPT UNPACKING pc=0x0000000002af7890 sp=0x000000003312c868 mode 0
Dynamic libraries:
0x00007ff7f3410000 - 0x00007ff7f3447000 D:\Program Files\Java\jdk1.8.0_241\bin\java.exe
0x00007ffb16460000 - 0x00007ffb16650000 C:\Windows\SYSTEM32\ntdll.dll
0x00007ffb15030000 - 0x00007ffb150e2000 C:\Windows\System32\KERNEL32.DLL
0x00007ffb13900000 - 0x00007ffb13ba5000 C:\Windows\System32\KERNELBASE.dll
0x00007ffb15b00000 - 0x00007ffb15ba3000 C:\Windows\System32\ADVAPI32.dll
0x00007ffb15ee0000 - 0x00007ffb15f7e000 C:\Windows\System32\msvcrt.dll
0x00007ffb15160000 - 0x00007ffb151f7000 C:\Windows\System32\sechost.dll
0x00007ffb15db0000 - 0x00007ffb15ed0000 C:\Windows\System32\RPCRT4.dll
0x00007ffb15bb0000 - 0x00007ffb15d44000 C:\Windows\System32\USER32.dll
0x00007ffb13500000 - 0x00007ffb13521000 C:\Windows\System32\win32u.dll
0x00007ffb14b60000 - 0x00007ffb14b86000 C:\Windows\System32\GDI32.dll
0x00007ffb136c0000 - 0x00007ffb13856000 C:\Windows\System32\gdi32full.dll
0x00007ffb13860000 - 0x00007ffb138fe000 C:\Windows\System32\msvcp_win.dll
0x00007ffb13400000 - 0x00007ffb134fa000 C:\Windows\System32\ucrtbase.dll
0x00007ffaff070000 - 0x00007ffaff2f4000 C:\Windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.18362.1256_none_9e7e379be45e40e2\COMCTL32.dll
0x00007ffb14670000 - 0x00007ffb149a6000 C:\Windows\System32\combase.dll
0x00007ffb13530000 - 0x00007ffb135b1000 C:\Windows\System32\bcryptPrimitives.dll
0x00007ffb14b90000 - 0x00007ffb14bbe000 C:\Windows\System32\IMM32.DLL
0x000000006d5d0000 - 0x000000006d6a2000 D:\Program Files\Java\jdk1.8.0_241\jre\bin\msvcr100.dll
0x000000006bc80000 - 0x000000006c52c000 D:\Program Files\Java\jdk1.8.0_241\jre\bin\server\jvm.dll
0x00007ffb15ed0000 - 0x00007ffb15ed8000 C:\Windows\System32\PSAPI.DLL
0x00007ffb0ada0000 - 0x00007ffb0ada9000 C:\Windows\SYSTEM32\WSOCK32.dll
0x00007ffb11010000 - 0x00007ffb1101a000 C:\Windows\SYSTEM32\VERSION.dll
0x00007ffb159e0000 - 0x00007ffb15a4f000 C:\Windows\System32\WS2_32.dll
0x00007ffb0cc50000 - 0x00007ffb0cc74000 C:\Windows\SYSTEM32\WINMM.dll
0x00007ffb0cc20000 - 0x00007ffb0cc4d000 C:\Windows\SYSTEM32\WINMMBASE.dll
0x00007ffb13670000 - 0x00007ffb136ba000 C:\Windows\System32\cfgmgr32.dll
0x00007ffb0b010000 - 0x00007ffb0b01f000 D:\Program Files\Java\jdk1.8.0_241\jre\bin\verify.dll
0x00007ffb06190000 - 0x00007ffb061b9000 D:\Program Files\Java\jdk1.8.0_241\jre\bin\java.dll
0x00007ffb066d0000 - 0x00007ffb066e6000 D:\Program Files\Java\jdk1.8.0_241\jre\bin\zip.dll
0x00007ffb15200000 - 0x00007ffb158e7000 C:\Windows\System32\SHELL32.dll
0x00007ffb15a50000 - 0x00007ffb15af9000 C:\Windows\System32\shcore.dll
0x00007ffb13bb0000 - 0x00007ffb14331000 C:\Windows\System32\windows.storage.dll
0x00007ffb133a0000 - 0x00007ffb133c3000 C:\Windows\System32\profapi.dll
0x00007ffb13330000 - 0x00007ffb1337a000 C:\Windows\System32\powrprof.dll
0x00007ffb13300000 - 0x00007ffb13310000 C:\Windows\System32\UMPDC.dll
0x00007ffb15100000 - 0x00007ffb15152000 C:\Windows\System32\shlwapi.dll
0x00007ffb13310000 - 0x00007ffb13321000 C:\Windows\System32\kernel.appcore.dll
0x00007ffb144f0000 - 0x00007ffb14507000 C:\Windows\System32\cryptsp.dll
0x00007ffb06170000 - 0x00007ffb0618a000 D:\Program Files\Java\jdk1.8.0_241\jre\bin\net.dll
0x00007ffb12b50000 - 0x00007ffb12bb7000 C:\Windows\system32\mswsock.dll
0x00007ffb03810000 - 0x00007ffb03822000 D:\Program Files\Java\jdk1.8.0_241\jre\bin\nio.dll
0x00007ffb03830000 - 0x00007ffb03856000 D:\gradle\native\31\windows-amd64\native-platform.dll
0x00007ffb09130000 - 0x00007ffb0913d000 D:\Program Files\Java\jdk1.8.0_241\jre\bin\management.dll
0x00007ffb126c0000 - 0x00007ffb126f3000 C:\Windows\system32\rsaenh.dll
0x00007ffb133d0000 - 0x00007ffb133f6000 C:\Windows\System32\bcrypt.dll
0x00007ffb13220000 - 0x00007ffb13245000 C:\Windows\SYSTEM32\USERENV.dll
0x00007ffb12d20000 - 0x00007ffb12d2c000 C:\Windows\SYSTEM32\CRYPTBASE.dll
0x00007ffb12860000 - 0x00007ffb1289a000 C:\Windows\SYSTEM32\IPHLPAPI.DLL
0x00007ffb150f0000 - 0x00007ffb150f8000 C:\Windows\System32\NSI.dll
0x00007ffb01d20000 - 0x00007ffb01d36000 C:\Windows\SYSTEM32\dhcpcsvc6.DLL
0x00007ffb01d00000 - 0x00007ffb01d1c000 C:\Windows\SYSTEM32\dhcpcsvc.DLL
0x00007ffb128a0000 - 0x00007ffb1296b000 C:\Windows\SYSTEM32\DNSAPI.dll
0x00007ffb12340000 - 0x00007ffb12371000 C:\Windows\SYSTEM32\ntmarta.dll
0x00007ffad78e0000 - 0x00007ffad7a7a000 D:\Program Files\Java\jdk1.8.0_241\jre\bin\awt.dll
0x00007ffb16070000 - 0x00007ffb16135000 C:\Windows\System32\OLEAUT32.dll
0x00007ffb0cd50000 - 0x00007ffb0cddf000 C:\Windows\SYSTEM32\apphelp.dll
0x00007ffb117f0000 - 0x00007ffb1181d000 C:\Windows\system32\DWMAPI.DLL
0x00007ffb0ce90000 - 0x00007ffb0cf29000 C:\Windows\system32\uxtheme.dll
0x00007ffb03530000 - 0x00007ffb0355a000 D:\Program Files\Java\jdk1.8.0_241\jre\bin\dcpr.dll
0x00007ffb06250000 - 0x00007ffb0626e000 C:\Users\admin\AppData\Local\Temp\native-platform3618524537930667608dir\native-platform.dll
VM Arguments:
jvm_args: -Xmx1536m -Dfile.encoding=UTF-8 -Duser.country=CN -Duser.language=zh -Duser.variant
java_command: org.gradle.launcher.daemon.bootstrap.GradleDaemon 6.1.1
java_class_path (initial): D:\gradle\wrapper\dists\gradle-6.1.1-all\cfmwm155h49vnt3hynmlrsdst\gradle-6.1.1\lib\gradle-launcher-6.1.1.jar
Launcher Type: SUN_STANDARD
Environment Variables:
JAVA_HOME=D:\Program Files\Java\jdk1.8.0_241
CLASSPATH=.;D:\Program Files\Java\jdk1.8.0_241\lib;D:\Program Files\Java\jdk1.8.0_241\lib\tools.jar
PATH=C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;%JAVA_HOME\bin;%JAVA_HOME\jre\bin;D:\Android_SDK\platform-tools;D:\Program Files\Git\cmd;C:\Users\admin\AppData\Local\Microsoft\WindowsApps;
USERNAME=admin
OS=Windows_NT
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 142 Stepping 12, GenuineIntel
--------------- S Y S T E M ---------------
OS: Windows 10.0 , 64 bit Build 18362 (10.0.18362.1110)
CPU:total 8 (initial active 8) (4 cores per cpu, 2 threads per core) family 6 model 142 stepping 12, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, sse4.1, sse4.2, popcnt, avx, avx2, aes, clmul, erms, 3dnowpref, lzcnt, ht, tsc, tscinvbit, bmi1, bmi2, adx
Memory: 4k page, physical 8197876k(438584k free), swap 21305072k(3112k free)
vm_info: Java HotSpot(TM) 64-Bit Server VM (25.241-b07) for windows-amd64 JRE (1.8.0_241-b07), built on Dec 11 2019 10:21:40 by "rejava" with MS VC++ 10.0 (VS2010)
time: Thu Dec 31 14:15:36 2020
timezone: й׼ʱ
elapsed time: 2504 seconds (0d 0h 41m 44s)
......@@ -58,6 +58,7 @@ dependencies {
exclude module: 'appcompat-v7'
exclude module: 'support-v4'
}
api rootProject.ext.dependencies["support-design"]
api rootProject.ext.dependencies["annotations"]
//view
api(rootProject.ext.dependencies["autolayout"]) {
......
......@@ -39,6 +39,7 @@ import javax.inject.Inject;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
......@@ -85,6 +86,9 @@ public abstract class BaseFragment<P extends IPresenter> extends Fragment implem
return mCache;
}
public int getColor(int colorId){
return ContextCompat.getColor(requireContext(), colorId);
}
@NonNull
@Override
......
......@@ -128,7 +128,7 @@ dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
// implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.gcssloop.recyclerview:pagerlayoutmanager:2.3.8'
//陰影背景
api 'com.github.lihangleo2:ShadowLayout:2.1.6'
......
......@@ -6,6 +6,7 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.JsonSyntaxException;
import com.google.gson.reflect.TypeToken;
import java.util.ArrayList;
......@@ -63,7 +64,7 @@ public class GsonUtils {
if (gson != null) {
t = gson.fromJson(gsonString, cls);
}
} catch (JSONException e) {
} catch (JSONException | JsonSyntaxException | IllegalStateException e) {
e.printStackTrace();
}
return t;
......
......@@ -3,8 +3,10 @@ package com.gingersoft.gsa.cloud.common.utils.inputFilter;
import android.content.Context;
import android.text.InputFilter;
import android.util.Log;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.common.utils.toast.ToastUtils;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
......@@ -94,15 +96,15 @@ public class InputFilterUtils {
public static InputFilter getMaxLengthFilterDisChAndEn(int maxLength) {
return (source, start, end, dest, dstart, dend) -> {
if (dest != null) {
int beforeLength = TextUtil.getStringLength(dest.toString());
int sourceLength = TextUtil.getStringLength(source.toString());
int beforeLength = dest.length();
int sourceLength = source.length();
int keep = maxLength - beforeLength;
if (keep <= 0) {
return "";
} else if (keep >= sourceLength) {
return null; // keep original
} else {
keep += sourceLength;
keep += start;
if (Character.isHighSurrogate(source.charAt(keep - 1))) {
--keep;
if (keep == sourceLength) {
......
......@@ -33,6 +33,11 @@ public class TextUtil {
!str.equals("null") && !str.equals("undefined");
}
public static boolean isNotEmptyOrNullOrUndefined(CharSequence str) {
return str != null && str.length() != 0 &&
!str.equals("null") && !str.equals("undefined");
}
public static boolean isNotEmptyOrNullOrUndefined(EditText editText) {
if (editText != null && editText.getText() != null) {
String str = editText.getText().toString();
......
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/shape_edit_border_48" android:state_checked="true" />
<item android:drawable="@drawable/shape_edit_border_48" android:state_focused="true" />
<item android:drawable="@drawable/shape_login_edit_border" />
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke
android:width="@dimen/dp_1"
android:color="@color/color_48" />
<corners android:radius="@dimen/dp_4" />
</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_13" />
<solid android:color="@color/color_48" />
</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_13" />
<solid android:color="@color/bright_orange" />
</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_13" />
<solid android:color="@color/required_color" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
style="@style/Multi_Layout_Style"
android:layout_width="match_parent"
android:layout_height="@dimen/multi_height"
android:gravity="center_vertical">
<include layout="@layout/item_multi_title_layout" />
<EditText
android:id="@+id/ed_multi_value"
style="@style/Multi_Input_editStyle"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/dp_5"
android:layout_weight="1"
android:background="@null"
tools:hint="請輸入食品組名稱" />
<ImageView
android:id="@+id/iv_clear_multi_content"
android:layout_width="@dimen/dp_30"
android:layout_height="@dimen/dp_30"
android:layout_marginLeft="@dimen/dp_5"
android:padding="@dimen/dp_5"
android:src="@drawable/ic_clear_text"
android:visibility="gone" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
style="@style/Multi_Layout_Style"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="@dimen/dp_75">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/dp_5"
android:layout_weight="1">
<EditText
android:id="@+id/ed_multi_value"
style="@style/Multi_Input_editStyle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toLeftOf="@id/iv_clear_multi_content"
android:background="@null"
android:gravity="left"
android:paddingTop="@dimen/dp_10"
android:scrollbars="vertical"
tools:hint="請輸入食品組名稱" />
<ImageView
android:id="@+id/iv_clear_multi_content"
android:layout_width="@dimen/dp_30"
android:layout_height="@dimen/dp_30"
android:layout_alignParentRight="true"
android:layout_marginLeft="@dimen/dp_5"
android:padding="@dimen/dp_8"
android:src="@drawable/ic_clear_text"
android:visibility="gone" />
<TextView
android:id="@+id/tv_edit_text_length"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/hint_color"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_margin="@dimen/dp_5"
android:textSize="@dimen/dp_12"
tools:text="0/50" />
</RelativeLayout>
</LinearLayout>
\ 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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
style="@style/Multi_Layout_Style"
android:layout_width="match_parent"
android:gravity="center_vertical"
android:orientation="horizontal">
<include
layout="@layout/item_multi_title_layout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<CheckBox
android:id="@+id/rb_multi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="@color/trans"
android:drawableLeft="@drawable/selector_radio_hook_bg"
android:drawablePadding="@dimen/dp_5"
android:text="選擇"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_16" />
</LinearLayout>
<include layout="@layout/include_horizontal_color_eee_dividing_line" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_radio_multi"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" style="@style/Multi_Layout_Style"
>
<include layout="@layout/item_multi_title_layout" />
<TextView
android:id="@+id/tv_provider_select_text"
style="@style/Multi_Input_editStyle"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/dp_5"
android:layout_weight="1"
android:background="@null"
android:hint="請選擇" />
<ImageView
android:id="@+id/iv_provider_select"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@drawable/arrow_down_black" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_38"
xmlns:tools="http://schemas.android.com/tools"
android:gravity="center_vertical">
<TextView
android:id="@+id/tv_multi_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_18"
tools:text="基本信息"
android:textColor="@color/black"
android:textSize="@dimen/multi_marginLeft"
android:textStyle="bold" />
</LinearLayout>
\ No newline at end of file
......@@ -476,6 +476,7 @@
<color name="color_ee">#eee</color>
<color name="color_222">#222222</color>
<color name="color_53">#535353</color>
<color name="color_48">#484848</color>
<color name="tran_twenty_send_order_btn_bg_color">#331196DB</color>
<color name="tran_fifty_order_state0_color">#7F009788</color>
......@@ -536,4 +537,5 @@
<color name="brick_red">#EC6941</color>
<color name="add_deputy_unit_bg">#F19149</color>
<color name="dk_color_999999">#999</color>
<color name="bright_orange">#FF7A0E</color>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer name="remark_max_length">50</integer>
</resources>
\ No newline at end of file
package com.gingersoft.gsa.cloud.ui.adapter;
import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.gingersoft.gsa.cloud.common.R2;
import com.gingersoft.gsa.cloud.ui.R;
import com.gingersoft.gsa.cloud.ui.bean.SectionCheckItem;
import com.qmuiteam.qmui.widget.section.QMUIDefaultStickySectionAdapter;
import com.qmuiteam.qmui.widget.section.QMUISection;
import com.qmuiteam.qmui.widget.section.QMUIStickySectionAdapter;
import com.qmuiteam.qmui.widget.section.QMUIStickySectionLayout;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
* 创建日期:2020-02-09
* 修订历史:2020-02-09
* 描述:
*/
public class BaseRadioSectionAdapter extends QMUIDefaultStickySectionAdapter<SectionCheckItem, SectionCheckItem> {
private Context context;
public final static String SEPARATOR = ",";
private String tab = "";
public BaseRadioSectionAdapter(Context context) {
this.context = context;
}
public BaseRadioSectionAdapter(Context context, int backgroundColor) {
this.context = context;
this.backgroundColor = backgroundColor;
}
private int backgroundColor = Color.WHITE;
private onRefreshListener onRefreshListener;
@NonNull
@Override
protected QMUIStickySectionAdapter.ViewHolder onCreateSectionHeaderViewHolder(@NonNull ViewGroup viewGroup) {
return new HeaderViewHolder(View.inflate(viewGroup.getContext(), R.layout.item_radio_section_header, null));
}
@NonNull
@Override
protected ViewHolder onCreateSectionItemViewHolder(@NonNull ViewGroup viewGroup) {
return new ItemViewHolder(View.inflate(viewGroup.getContext(), R.layout.item_radio_section_item, null));
}
@Override
protected void onBindSectionHeader(QMUIStickySectionAdapter.ViewHolder holder, int position, QMUISection<SectionCheckItem, SectionCheckItem> section) {
super.onBindSectionHeader(holder, position, section);
HeaderViewHolder headerViewHolder = (HeaderViewHolder) holder;
headerViewHolder.tvTitle.setText(tab + section.getHeader().getText());
headerViewHolder.cbSection.setChecked(section.getHeader().isChecked());
headerViewHolder.cbSection.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (buttonView.isPressed()) {
if (isChecked) {
onCheckedChangeListener.onChange("", isChecked, section.getHeader());
} else {
//當前item取消選中,下面的子類全部設置為取消
section.getHeader().setChecked(false);
downTraversal(section.getItemList());
if (onRefreshListener != null) {
onRefreshListener.onRefresh();
}
}
}
});
headerViewHolder.itemView.setBackgroundColor(backgroundColor);
}
public void downTraversal(List<SectionCheckItem> itemList) {
if (itemList != null) {
for (int i = 0; i < itemList.size(); i++) {
itemList.get(i).setChecked(false);
if (itemList.get(i) != null) {
downTraversal(itemList.get(i).getSectionCheckItems());
}
}
}
}
@Override
protected void onBindSectionItem(ViewHolder holder, int position, QMUISection<SectionCheckItem, SectionCheckItem> section, int itemIndex) {
super.onBindSectionItem(holder, position, section, itemIndex);
ItemViewHolder viewHolder = (ItemViewHolder) holder;
int itemCount = section.getItemCount();
if (itemCount > 0) {
int alpha = Color.alpha(backgroundColor) - 20;
int red = Color.red(backgroundColor) - 20;
int green = Color.green(backgroundColor) - 20;
int blue = Color.blue(backgroundColor) - 20;
if (alpha < 0 || alpha > 255) {
alpha = 0;
}
if (red < 0 || red > 255) {
red = 0;
}
if (green < 0 || green > 255) {
green = 0;
}
if (blue < 0 || blue > 255) {
blue = 0;
}
BaseRadioSectionAdapter baseRadioSectionAdapter = new BaseRadioSectionAdapter(context, Color.argb(alpha, red, green, blue));
baseRadioSectionAdapter.setTab(tab + "\u3000");
List<QMUISection<SectionCheckItem, SectionCheckItem>> sections = new ArrayList<>();
SectionCheckItem itemHeader = section.getItemAt(itemIndex);
sections.add(new QMUISection<>(itemHeader, section.getItemAt(itemIndex).getSectionCheckItems(), false));
baseRadioSectionAdapter.setData(sections);
viewHolder.sectionLayout.setAdapter(baseRadioSectionAdapter);
viewHolder.sectionLayout.setLayoutManager(new LinearLayoutManager(context) {
@Override
public RecyclerView.LayoutParams generateDefaultLayoutParams() {
return new RecyclerView.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
}
});
baseRadioSectionAdapter.setOnRefreshListener(onRefreshListener);
baseRadioSectionAdapter.setCallback(new Callback<SectionCheckItem, SectionCheckItem>() {
@Override
public void loadMore(QMUISection<SectionCheckItem, SectionCheckItem> section, boolean loadMoreBefore) {
if (callback != null) {
callback.loadMore(section, loadMoreBefore);
}
}
@Override
public void onItemClick(ViewHolder holder, int position) {
if (sections.get(position).getItemCount() > 0) {
baseRadioSectionAdapter.toggleFold(position, false);
} else {
onItemClickListener.onClick(sections.get(position).getHeader().getId(), sections.get(position).getHeader().getSort(), itemIndex + "");
}
}
@Override
public boolean onItemLongClick(ViewHolder holder, int position) {
if (callback != null) {
callback.onItemLongClick(holder, position);
}
return false;
}
});
baseRadioSectionAdapter.setOnItemClickListener((id, position1, positions) -> {
onItemClickListener.onClick(id, sections.get(0).getHeader().getSort(), position1 + SEPARATOR + positions);
});
baseRadioSectionAdapter.setOnCheckedChangeListener((positions, isChecked, section1) -> {
if (section1 != null) {
onCheckedChangeListener.onChange(sections.get(0).getHeader().getSort() + SEPARATOR + section.getItemList().indexOf(section1), isChecked, null);
} else {
onCheckedChangeListener.onChange(sections.get(0).getHeader().getSort() + SEPARATOR + positions, isChecked, null);
}
});
viewHolder.sectionLayout.setVisibility(View.VISIBLE);
} else {
viewHolder.sectionLayout.setVisibility(View.GONE);
}
}
private OnCheckedChangeListener onCheckedChangeListener;
private OnItemClickListener onItemClickListener;
public interface OnCheckedChangeListener {
void onChange(String positions, boolean isChecked, SectionCheckItem section);
}
private Callback<SectionCheckItem, SectionCheckItem> callback;
@Override
public void setCallback(Callback<SectionCheckItem, SectionCheckItem> callback) {
super.setCallback(callback);
this.callback = callback;
}
public interface OnItemClickListener {
/**
* 遞歸傳遞上來點擊的下標
*
* @param id 點擊的item的id
* @param positions 下標集合
*/
void onClick(int id, int position, String positions);
}
public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
this.onItemClickListener = onItemClickListener;
}
public void setOnCheckedChangeListener(OnCheckedChangeListener onCheckedChangeListener) {
this.onCheckedChangeListener = onCheckedChangeListener;
}
public void setOnRefreshListener(BaseRadioSectionAdapter.onRefreshListener onRefreshListener) {
this.onRefreshListener = onRefreshListener;
}
/**
* 刷新adapter,複選框選中之後不能刷新adapter,需要判斷recyclerview的狀態進行刷新
*/
public interface onRefreshListener {
void onRefresh();
}
public void setTab(String tab) {
this.tab = tab;
}
public class HeaderViewHolder extends QMUIStickySectionAdapter.ViewHolder {
// @BindView(R2.id.tv_radio_section_title)
TextView tvTitle;//功能名
// @BindView(R2.id.cb_radio_section)
CheckBox cbSection;
public HeaderViewHolder(View itemView) {
super(itemView);
tvTitle = itemView.findViewById(R.id.tv_radio_section_title);
cbSection = itemView.findViewById(R.id.cb_radio_section);
// ButterKnife.bind(this, itemView);
}
public int getSectionCheckItemItem(int position) {
return getSectionIndex(position);
}
}
public class ItemViewHolder extends QMUIStickySectionAdapter.ViewHolder {
// @BindView(R2.id.item_radio_section_layout)
QMUIStickySectionLayout sectionLayout;
public ItemViewHolder(View itemView) {
super(itemView);
sectionLayout = itemView.findViewById(R.id.item_radio_section_layout);
// ButterKnife.bind(this, itemView);
}
}
}
......@@ -3,6 +3,7 @@ package com.gingersoft.gsa.cloud.ui.adapter.bean;
import android.text.InputFilter;
import android.text.TextWatcher;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import lombok.Data;
import me.yokeyword.fragmentation.ISupportFragment;
......@@ -17,10 +18,9 @@ import me.yokeyword.fragmentation.ISupportFragment;
@Data
public class MultiInputBean extends InfoMultiBean {
private InputFilter[] inputFilters;
private int inputType = -1;
private InputFilter[] inputFilters = new InputFilter[0];
private int inputType = EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE;
private int maxLength = 0;
private TextWatcher textWatcher;
/**
* 是否可以編輯
*/
......
......@@ -3,6 +3,7 @@ package com.gingersoft.gsa.cloud.ui.adapter.multi;
import androidx.appcompat.widget.SwitchCompat;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.gingersoft.gsa.cloud.ui.R;
import com.gingersoft.gsa.cloud.ui.adapter.bean.InfoMultiBean;
import org.jetbrains.annotations.NotNull;
......@@ -22,16 +23,14 @@ public class BooleanItemProvider<T extends InfoMultiBean> extends MyBaseItemProv
@Override
public int getLayoutId() {
return com.gingersoft.gsa.cloud.common.R.layout.multi_item_boolean;
return R.layout.multi_item_boolean;
}
@Override
public void convert(@NotNull BaseViewHolder baseViewHolder, InfoMultiBean infoMultiBean) {
public void convert(@NotNull BaseViewHolder baseViewHolder, T infoMultiBean) {
super.convert(baseViewHolder, infoMultiBean);
SwitchCompat sw = baseViewHolder.getView(com.gingersoft.gsa.cloud.common.R.id.switch_multi_boolean_state);
SwitchCompat sw = baseViewHolder.getView(R.id.switch_multi_boolean_state);
sw.setChecked(infoMultiBean.isChecked());
sw.setOnCheckedChangeListener((buttonView, isChecked) -> {
infoMultiBean.setChecked(isChecked);
});
sw.setOnCheckedChangeListener((buttonView, isChecked) -> infoMultiBean.setChecked(isChecked));
}
}
......@@ -3,6 +3,7 @@ package com.gingersoft.gsa.cloud.ui.adapter.multi;
import android.content.Context;
import com.chad.library.adapter.base.BaseProviderMultiAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.gingersoft.gsa.cloud.ui.R;
import com.gingersoft.gsa.cloud.ui.adapter.bean.InfoMultiBean;
......@@ -18,6 +19,13 @@ import java.util.List;
* Use:
*/
public class InfoMultiAdapter extends BaseProviderMultiAdapter<InfoMultiBean> {
public final static Object NOT_HIDE_KEYBOARD = 1001;
// @Override
// public void onBindViewHolder(@NotNull BaseViewHolder holder, int position) {
// super.onBindViewHolder(holder, position);
// holder.setIsRecyclable(false);
// }
@Override
protected int getItemType(@NotNull List<? extends InfoMultiBean> list, int i) {
......@@ -34,7 +42,6 @@ public class InfoMultiAdapter extends BaseProviderMultiAdapter<InfoMultiBean> {
addItemProvider(new SelectDialogProvider<>(context));
addItemProvider(new MultiUploadPicProvider<>(context));
addItemProvider(new SelectItemProvider<>(context));
// addItemProvider(new MultipleInputProvider<>(context));
addItemProvider(new MultiCheckProvider<>(context));
addItemProvider(new BooleanItemProvider<>());
addChildClickViewIds(R.id.iv_multi_upload_pic, R.id.cb_multi_check);
......
package com.gingersoft.gsa.cloud.ui.adapter.multi;
import android.text.Editable;
import android.text.InputFilter;
import android.text.InputType;
import android.text.TextWatcher;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
import android.widget.ImageView;
import androidx.core.content.ContextCompat;
......@@ -15,12 +20,10 @@ import com.gingersoft.gsa.cloud.ui.R;
import com.gingersoft.gsa.cloud.ui.adapter.bean.InfoMultiBean;
import com.gingersoft.gsa.cloud.ui.adapter.bean.MultiInputBean;
import com.google.android.material.textfield.TextInputEditText;
import com.qmuiteam.qmui.util.QMUIKeyboardHelper;
import com.xuexiang.rxutil2.rxjava.RxJavaUtils;
import org.jetbrains.annotations.NotNull;
import java.util.concurrent.TimeUnit;
import butterknife.ButterKnife;
/**
* @author 宇航.
......@@ -29,7 +32,7 @@ import java.util.concurrent.TimeUnit;
* Time: 15:58
* Use:
*/
public class InputProvider<T extends InfoMultiBean> extends BaseItemProvider<T> {
public class InputProvider<T extends InfoMultiBean> extends MyBaseItemProvider<T> {
@Override
public int getItemViewType() {
......@@ -42,53 +45,27 @@ public class InputProvider<T extends InfoMultiBean> extends BaseItemProvider<T>
}
@Override
public @NotNull InputViewHolder onCreateViewHolder(@NotNull ViewGroup parent, int viewType) {
return new InputViewHolder(LayoutInflater.from(context).inflate(getLayoutId(), parent, false));
}
@Override
public void convert(@NotNull BaseViewHolder baseViewHolder, T t) {
super.convert(baseViewHolder, t);
InputViewHolder viewHolder = (InputViewHolder) baseViewHolder;
MultiInputBean infoMultiBean = (MultiInputBean) t;
//是否顯示必選
baseViewHolder.setGone(R.id.multi_required, !infoMultiBean.isRequired());
//設置標題
if (TextUtil.isNotEmptyOrNullOrUndefined(infoMultiBean.getShowTitle())) {
baseViewHolder.setText(R.id.tv_multi_title, infoMultiBean.getShowTitle());
} else {
baseViewHolder.setText(R.id.tv_multi_title, "");
}
TextInputEditText editText = baseViewHolder.getView(R.id.ed_multi_value);
editText.setError(null);
initEditFocusable(infoMultiBean, editText);
//設置輸入限制
setFilters(editText, infoMultiBean);
//刷新數據
viewHolder.updateView(infoMultiBean);
//設置輸入框的值
initEditText(editText, infoMultiBean.getShowValue(), infoMultiBean.getHintText());
TextWatcher textWatcher = new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
infoMultiBean.setShowValue(editText.getText() + "");
if (s == null || TextUtil.isEmptyOrNullOrUndefined(s.toString())) {
editText.setHint(infoMultiBean.getHintText());
baseViewHolder.setGone(R.id.iv_clear_multi_content, true);
} else {
baseViewHolder.setGone(R.id.iv_clear_multi_content, false);
}
}
};
//添加焦點監聽
editText.setOnFocusChangeListener((v, hasFocus) -> {
if (hasFocus) {
editText.addTextChangedListener(textWatcher);
RxJavaUtils.delay(500,
TimeUnit.MILLISECONDS, aLong -> baseViewHolder.setGone(R.id.iv_clear_multi_content, TextUtil.isEmptyOrNullOrUndefined(editText)), throwable -> { });
} else {
editText.removeTextChangedListener(textWatcher);
RxJavaUtils.delay(500,
TimeUnit.MILLISECONDS, aLong -> baseViewHolder.setGone(R.id.iv_clear_multi_content, true), throwable -> { });
}
if (getAdapter() != null) {
T infoBean = getAdapter().getData().get(baseViewHolder.getAdapterPosition());
if (infoBean instanceof MultiInputBean) {
......@@ -99,16 +76,12 @@ public class InputProvider<T extends InfoMultiBean> extends BaseItemProvider<T>
}
}
});
ImageView ivClear = baseViewHolder.getView(R.id.iv_clear_multi_content);
ivClear.setOnClickListener(v -> {
editText.setText("");
editText.requestFocus();
QMUIKeyboardHelper.showKeyboard(editText, false);
ivClear.setVisibility(View.GONE);
});
editText.setFocusable(infoMultiBean.isEdit());
}
private void initEditFocusable(MultiInputBean infoMultiBean, TextInputEditText editText) {
//是否可編輯
editText.setFocusable(infoMultiBean.isEdit());
if (infoMultiBean.isEdit()) {
editText.setTextColor(ContextCompat.getColor(context, R.color.color_3c));
} else {
......@@ -116,29 +89,53 @@ public class InputProvider<T extends InfoMultiBean> extends BaseItemProvider<T>
}
}
private void initEditText(EditText tvThird, String showValue, String hintText) {
if (TextUtil.isNotEmptyOrNullOrUndefined(showValue)) {
tvThird.setText(showValue);
} else if (TextUtil.isNotEmptyOrNullOrUndefined(hintText)) {
tvThird.setHint(hintText);
} else {
tvThird.setText("");
}
tvThird.setText(showValue);
tvThird.setHint(hintText);
}
private void setFilters(EditText editText, MultiInputBean multiSelectBean) {
if (multiSelectBean.getInputFilters() != null) {
editText.setFilters(multiSelectBean.getInputFilters());
} else {
editText.setFilters(editText.getFilters());
//輸入攔截器
editText.setFilters(multiSelectBean.getInputFilters());
//輸入類型限制
editText.setInputType(multiSelectBean.getInputType());
}
public class InputViewHolder extends BaseViewHolder {
public InputTextWatcher inputTextWatcher = new InputTextWatcher();
private TextInputEditText editText;
public InputViewHolder(@NotNull View view) {
super(view);
ButterKnife.bind(this, view);
editText = view.findViewById(R.id.ed_multi_value);
editText.addTextChangedListener(inputTextWatcher);
}
if (multiSelectBean.getInputType() != -1) {
editText.setInputType(multiSelectBean.getInputType());
} else {
editText.setInputType(editText.getInputType());
public void updateView(MultiInputBean infoMultiBean) {
inputTextWatcher.inputViewHolder = this;
inputTextWatcher.infoMultiBean = infoMultiBean;
}
}
class InputTextWatcher implements TextWatcher {
MultiInputBean infoMultiBean;
InputViewHolder inputViewHolder;
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
if (infoMultiBean != null) {
infoMultiBean.setShowValue(s + "");
}
}
}
}
......@@ -3,6 +3,9 @@ package com.gingersoft.gsa.cloud.ui.adapter.multi;
import android.content.Context;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
......@@ -15,11 +18,15 @@ import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.ui.R;
import com.gingersoft.gsa.cloud.ui.adapter.bean.InfoMultiBean;
import com.gingersoft.gsa.cloud.ui.adapter.bean.MultiCheckInputBean;
import com.gingersoft.gsa.cloud.ui.adapter.bean.MultiInputBean;
import com.google.android.material.textfield.TextInputEditText;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import butterknife.ButterKnife;
/**
* @author 宇航.
* User: admin
......@@ -27,7 +34,7 @@ import java.util.List;
* Time: 15:20
* Use:
*/
public class MultiCheckProvider<T extends InfoMultiBean> extends BaseItemProvider<T> {
public class MultiCheckProvider<T extends InfoMultiBean> extends InputProvider<T> {
public MultiCheckProvider(Context context) {
......@@ -44,92 +51,26 @@ public class MultiCheckProvider<T extends InfoMultiBean> extends BaseItemProvide
}
@Override
public @NotNull InputViewHolder onCreateViewHolder(@NotNull ViewGroup parent, int viewType) {
return new InputViewHolder(LayoutInflater.from(context).inflate(getLayoutId(), parent, false));
}
@Override
public void convert(@NotNull BaseViewHolder baseViewHolder, T t) {
super.convert(baseViewHolder, t);
MultiCheckInputBean infoMultiBean = (MultiCheckInputBean) t;
//是否顯示必選
baseViewHolder.setGone(R.id.multi_required, !infoMultiBean.isRequired());
//設置標題
if (TextUtil.isNotEmptyOrNullOrUndefined(infoMultiBean.getShowTitle())) {
baseViewHolder.setText(R.id.tv_multi_title, infoMultiBean.getShowTitle());
} else {
baseViewHolder.setText(R.id.tv_multi_title, "");
}
baseViewHolder.setImageResource(R.id.iv_multi_check_img, infoMultiBean.getIconId());
CheckBox checkBox = baseViewHolder.getView(R.id.cb_multi_check);
InputViewHolder viewHolder = (InputViewHolder) baseViewHolder;
viewHolder.setImageResource(R.id.iv_multi_check_img, infoMultiBean.getIconId());
CheckBox checkBox = viewHolder.getView(R.id.cb_multi_check);
checkBox.setChecked(infoMultiBean.isChecked());
if (infoMultiBean.isDefault()) {
baseViewHolder.setGone(R.id.cb_multi_check, true);
baseViewHolder.setGone(R.id.tv_multi_default, false);
viewHolder.setGone(R.id.cb_multi_check, true);
viewHolder.setGone(R.id.tv_multi_default, false);
} else {
baseViewHolder.setGone(R.id.cb_multi_check, false);
baseViewHolder.setGone(R.id.tv_multi_default, true);
viewHolder.setGone(R.id.cb_multi_check, false);
viewHolder.setGone(R.id.tv_multi_default, true);
}
EditText editText = baseViewHolder.getView(R.id.ed_multi_value);
initEditLimit(infoMultiBean, editText);
setEditText(infoMultiBean, editText);
ImageView ivClear = baseViewHolder.getView(R.id.iv_clear_multi_content);
ivClear.setOnClickListener(v -> editText.setText(""));
infoMultiBean.setTextWatcher(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
List<T> data = getAdapter().getData();
data.get(baseViewHolder.getAdapterPosition()).setShowValue(s + "");
if (s != null && TextUtil.isNotEmptyOrNullOrUndefined(s.toString())) {
baseViewHolder.setGone(R.id.iv_clear_multi_content, false);
} else {
editText.setHint(data.get(baseViewHolder.getAdapterPosition()).getHintText());
baseViewHolder.setGone(R.id.iv_clear_multi_content, true);
}
}
});
editText.addTextChangedListener(infoMultiBean.getTextWatcher());
editText.setFocusable(infoMultiBean.isEdit());
// if(infoMultiBean.isEdit()){
// editText.setTextColor(ContextCompat.getColor(context, R.color.color_3c));
// } else {
// editText.setTextColor(ContextCompat.getColor(context, R.color.color_c9));
// }
viewHolder.setTextColor(R.id.ed_multi_value, ContextCompat.getColor(context, R.color.color_3c));
}
private void setEditText(MultiCheckInputBean infoMultiBean, EditText editText) {
if (TextUtil.isNotEmptyOrNullOrUndefined(infoMultiBean.getShowValue())) {
editText.setText(infoMultiBean.getShowValue());
} else {
editText.setHint(infoMultiBean.getHintText());
editText.setText("");
}
}
private void initEditLimit(MultiCheckInputBean infoMultiBean, EditText editText) {
if (infoMultiBean.getTextWatcher() != null) {
editText.removeTextChangedListener(infoMultiBean.getTextWatcher());
}
if (infoMultiBean.getInputFilters() != null) {
editText.setFilters(infoMultiBean.getInputFilters());
} else {
editText.setFilters(editText.getFilters());
}
if (infoMultiBean.getInputType() != -1) {
editText.setInputType(infoMultiBean.getInputType());
} else {
editText.setInputType(editText.getInputType());
}
}
}
......@@ -23,7 +23,7 @@ import java.util.List;
* Time: 15:52
* Use:
*/
public class MultiUploadPicProvider<T extends InfoMultiBean> extends BaseItemProvider<T> {
public class MultiUploadPicProvider<T extends InfoMultiBean> extends MyBaseItemProvider<T> {
public static final int CHOOSE_PHOTO = 101;
......@@ -43,15 +43,8 @@ public class MultiUploadPicProvider<T extends InfoMultiBean> extends BaseItemPro
@Override
public void convert(@NotNull BaseViewHolder baseViewHolder, T infoMultiBean) {
super.convert(baseViewHolder, infoMultiBean);
ImageView pic = baseViewHolder.getView(R.id.iv_multi_upload_pic);
//是否顯示必選
baseViewHolder.setGone(R.id.multi_required, !infoMultiBean.isRequired());
//設置標題
if (TextUtil.isNotEmptyOrNullOrUndefined(infoMultiBean.getShowTitle())) {
baseViewHolder.setText(R.id.tv_multi_title, infoMultiBean.getShowTitle());
} else {
baseViewHolder.setText(R.id.tv_multi_title, "");
}
if (infoMultiBean instanceof UploadPicMultiBean) {
UploadPicMultiBean uploadPicMultiBean = (UploadPicMultiBean) infoMultiBean;
List<String> picUrl = uploadPicMultiBean.getPicUrl();
......
......@@ -15,10 +15,11 @@ import org.jetbrains.annotations.NotNull;
* Time: 11:07
* Use:
*/
public abstract class MyBaseItemProvider<T extends InfoMultiBean> extends BaseItemProvider<T> {
abstract class MyBaseItemProvider<T> extends BaseItemProvider<T> {
@Override
public void convert(@NotNull BaseViewHolder baseViewHolder, InfoMultiBean infoMultiBean) {
public void convert(@NotNull BaseViewHolder baseViewHolder, T t) {
InfoMultiBean infoMultiBean = (InfoMultiBean)t;
//是否顯示必選
baseViewHolder.setGone(R.id.multi_required, !infoMultiBean.isRequired());
//設置標題
......
......@@ -40,7 +40,7 @@ public class RadioListProvider<T extends InfoMultiBean> extends MyBaseItemProvid
}
@Override
public void convert(@NotNull BaseViewHolder baseViewHolder, InfoMultiBean infoMultiBean) {
public void convert(@NotNull BaseViewHolder baseViewHolder, T infoMultiBean) {
super.convert(baseViewHolder, infoMultiBean);
baseViewHolder.setText(R.id.rb_multi, infoMultiBean.getShowValue());
if (infoMultiBean.getInfoMultiBeans() != null) {
......@@ -53,9 +53,7 @@ public class RadioListProvider<T extends InfoMultiBean> extends MyBaseItemProvid
InfoMultiAdapter infoMultiAdapter = new InfoMultiAdapter(context, infoMultiBean.getInfoMultiBeans());
rv.setAdapter(infoMultiAdapter);
checkBox.setOnCheckedChangeListener((buttonView, isChecked) -> {
rv.setVisibility(isChecked ? View.VISIBLE : View.GONE);
});
checkBox.setOnCheckedChangeListener((buttonView, isChecked) -> rv.setVisibility(isChecked ? View.VISIBLE : View.GONE));
}
}
}
......@@ -22,7 +22,7 @@ import org.jetbrains.annotations.NotNull;
* Time: 15:58
* Use:
*/
public class RadioProvider extends MyBaseItemProvider {
public class RadioProvider<T extends InfoMultiBean> extends MyBaseItemProvider<T> {
private Context context;
......@@ -41,7 +41,7 @@ public class RadioProvider extends MyBaseItemProvider {
}
@Override
public void convert(@NotNull BaseViewHolder baseViewHolder, InfoMultiBean infoMultiBean) {
public void convert(@NotNull BaseViewHolder baseViewHolder, T infoMultiBean) {
super.convert(baseViewHolder, infoMultiBean);
baseViewHolder.setText(R.id.rb_multi, infoMultiBean.getShowValue());
if (infoMultiBean.getInfoMultiBeans() != null) {
......@@ -54,9 +54,7 @@ public class RadioProvider extends MyBaseItemProvider {
InfoMultiAdapter infoMultiAdapter = new InfoMultiAdapter(context, infoMultiBean.getInfoMultiBeans());
rv.setAdapter(infoMultiAdapter);
checkBox.setOnCheckedChangeListener((buttonView, isChecked) -> {
rv.setVisibility(isChecked ? View.VISIBLE : View.GONE);
});
checkBox.setOnCheckedChangeListener((buttonView, isChecked) -> rv.setVisibility(isChecked ? View.VISIBLE : View.GONE));
}
}
}
package com.gingersoft.gsa.cloud.ui.adapter.multi;
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.EditText;
import android.widget.TextView;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.ui.R;
import com.gingersoft.gsa.cloud.ui.adapter.bean.InfoMultiBean;
import com.gingersoft.gsa.cloud.ui.adapter.bean.MultiInputBean;
import org.jetbrains.annotations.NotNull;
......@@ -21,7 +17,7 @@ import org.jetbrains.annotations.NotNull;
* Use: 備註輸入框樣式
*/
public class RemarkProvider<T extends InfoMultiBean> extends InputProvider<T> {
public final static int REMARK_TEXT_LENGTH = 100;
public final static int REMARK_TEXT_LENGTH = 50;
@Override
public int getItemViewType() {
......@@ -34,57 +30,12 @@ public class RemarkProvider<T extends InfoMultiBean> extends InputProvider<T> {
}
@Override
public void convert(@NotNull BaseViewHolder baseViewHolder, T t) {
MultiInputBean infoMultiBean = (MultiInputBean) t;
EditText editText = baseViewHolder.getView(R.id.ed_multi_value);
baseViewHolder.setGone(R.id.tv_edit_text_length, infoMultiBean.getMaxLength() <= 0);
TextView tvEditLength = baseViewHolder.getView(R.id.tv_edit_text_length);
if (infoMultiBean.getInputFilters() != null) {
editText.setFilters(infoMultiBean.getInputFilters());
} else {
editText.setFilters(editText.getFilters());
}
if (infoMultiBean.getInputType() != -1) {
editText.setInputType(infoMultiBean.getInputType());
} else {
editText.setInputType(editText.getInputType());
}
if (infoMultiBean.getMaxLength() > 0) {
tvEditLength.setText(editText.getText().length() + "/" + infoMultiBean.getMaxLength());
}
if (TextUtil.isNotEmptyOrNullOrUndefined(infoMultiBean.getShowValue())) {
editText.setText(infoMultiBean.getShowValue());
} else {
editText.setHint(infoMultiBean.getHintText());
editText.setText("");
}
editText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
public @NotNull InputViewHolder onCreateViewHolder(@NotNull ViewGroup parent, int viewType) {
return new InputViewHolder(LayoutInflater.from(context).inflate(getLayoutId(), parent, false));
}
@Override
public void afterTextChanged(Editable s) {
if (s != null) {
int textLength = TextUtil.getStringLength(s.toString());
tvEditLength.setText(textLength + "/" + infoMultiBean.getMaxLength());
infoMultiBean.setShowValue(s.toString());
} else {
infoMultiBean.setShowValue("");
}
}
});
@Override
public void convert(@NotNull BaseViewHolder baseViewHolder, T t) {
super.convert(baseViewHolder, t);
}
}
......@@ -44,7 +44,7 @@ public class SelectDialogProvider<T extends InfoMultiBean> extends MyBaseItemPro
}
@Override
public void convert(@NotNull BaseViewHolder baseViewHolder, InfoMultiBean infoMultiBean) {
public void convert(@NotNull BaseViewHolder baseViewHolder, T infoMultiBean) {
super.convert(baseViewHolder, infoMultiBean);
currentPosition = baseViewHolder.getAdapterPosition();
infoMultiBeans = infoMultiBean.getInfoMultiBeans();
......
......@@ -21,7 +21,7 @@ import org.jetbrains.annotations.NotNull;
/**
* @author admin
*/
public class SelectItemProvider<T extends InfoMultiBean> extends BaseItemProvider<T> {
public class SelectItemProvider<T extends InfoMultiBean> extends InputProvider<T> {
private Context context;
public SelectItemProvider(Context context) {
......@@ -40,86 +40,21 @@ public class SelectItemProvider<T extends InfoMultiBean> extends BaseItemProvide
@Override
public void convert(@NotNull BaseViewHolder baseViewHolder, T infoMultiBean) {
super.convert(baseViewHolder, infoMultiBean);
if (infoMultiBean instanceof MultiSelectBean) {
MultiSelectBean multiSelectBean = (MultiSelectBean) infoMultiBean;
//是否顯示必選
baseViewHolder.setGone(R.id.multi_required, !infoMultiBean.isRequired());
//設置標題
if (TextUtil.isNotEmptyOrNullOrUndefined(infoMultiBean.getShowTitle())) {
baseViewHolder.setText(R.id.tv_multi_title, infoMultiBean.getShowTitle());
} else {
baseViewHolder.setText(R.id.tv_multi_title, "");
}
// TextView textView = baseViewHolder.getView(R.id.ed_multi_value);
//
// if (TextUtil.isNotEmptyOrNullOrUndefined(infoMultiBean.getShowValue())) {
// textView.setText(infoMultiBean.getShowValue());
// } else if (TextUtil.isNotEmptyOrNullOrUndefined(infoMultiBean.getHintText())) {
// textView.setHint(infoMultiBean.getHintText());
EditText editText = baseViewHolder.getView(R.id.ed_multi_value);
editText.setFocusable(multiSelectBean.isEdit());
// if (multiSelectBean.isEdit()) {
// //可以編輯才配置這些
//// KeyListener keyListener = editText.getKeyListener();
//// editText.setKeyListener(keyListener);
// editText.setFocusable(true);
// } else {
// editText.setKeyListener(null);
// }
EditText edFirst = baseViewHolder.getView(R.id.ed_multi_value_first);
initEditText(edFirst, multiSelectBean.getShowValue(), multiSelectBean.getHintText());
if (multiSelectBean.isEdit()) {
//可以編輯才配置這些
KeyListener keyListener = edFirst.getKeyListener();
edFirst.setKeyListener(keyListener);
setFilters(edFirst, multiSelectBean);
TextWatcher textWatcher = new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
multiSelectBean.setShowValue(s + "");
}
};
edFirst.setOnFocusChangeListener((v, hasFocus) -> {
if (hasFocus) {
edFirst.addTextChangedListener(textWatcher);
} else {
edFirst.removeTextChangedListener(textWatcher);
}
});
// edFirst.setTextColor(getColor(R.color.color_3c));
} else {
edFirst.setKeyListener(null);
// edFirst.setTextColor(getColor(R.color.color_c9));
}
// edFirst.setFocusableInTouchMode(multiSelectBean.isEdit());
// edFirst.setFocusable(multiSelectBean.isEdit());
}
}
private void initEditText(EditText tvThird, String showValue, String hintText) {
if (TextUtil.isNotEmptyOrNullOrUndefined(showValue)) {
tvThird.setText(showValue);
} else if (TextUtil.isNotEmptyOrNullOrUndefined(hintText)) {
tvThird.setHint(hintText);
} else {
tvThird.setText("");
}
}
private void setFilters(EditText editText, MultiSelectBean multiSelectBean) {
if (multiSelectBean.getInputFilters() != null) {
editText.setFilters(multiSelectBean.getInputFilters());
} else {
editText.setFilters(editText.getFilters());
}
if (multiSelectBean.getInputType() != -1) {
editText.setInputType(multiSelectBean.getInputType());
} else {
editText.setInputType(editText.getInputType());
editText.setTextColor(ContextCompat.getColor(context, R.color.color_3c));
}
}
......
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
......@@ -2,6 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:tools="http://schemas.android.com/tools"
android:gravity="center"
android:orientation="horizontal">
......@@ -9,6 +10,7 @@
android:id="@+id/tv_bill_total_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
tools:text="微信:"
android:layout_weight="0.7"
android:gravity="right"
style="@style/Print_text_style"/>
......@@ -20,5 +22,6 @@
android:layout_weight="0.3"
android:layout_gravity="bottom"
android:gravity="right"
tools:text="$500"
style="@style/Print_text_style" />
</LinearLayout>
\ No newline at end of file
......@@ -17,8 +17,8 @@
<!-- android:layout_marginLeft="@dimen/dp_5"-->
<!-- android:layout_weight="1"-->
<!-- tool:hint="默認為全時段" />-->
<EditText
android:id="@+id/ed_multi_value_first"
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/ed_multi_value"
style="@style/Multi_Input_editStyle"
android:layout_width="0dp"
android:layout_height="match_parent"
......
<?xml version="1.0" encoding="utf-8"?>
<com.qmuiteam.qmui.widget.section.QMUIStickySectionLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/item_radio_section_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants"
android:gravity="center_vertical"
android:orientation="horizontal" />
\ No newline at end of file
......@@ -34,7 +34,7 @@
<include layout="@layout/item_multi_title_layout" />
<EditText
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/ed_multi_value"
style="@style/Multi_Input_editStyle"
android:layout_width="0dp"
......@@ -48,8 +48,8 @@
android:id="@+id/iv_clear_multi_content"
android:layout_width="@dimen/dp_30"
android:layout_height="@dimen/dp_30"
android:layout_marginLeft="@dimen/dp_5"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/dp_5"
android:padding="@dimen/dp_5"
android:src="@drawable/ic_clear_text"
android:visibility="gone" />
......
......@@ -13,12 +13,12 @@
style="@style/Multi_Input_editStyle"
android:layout_width="0dp"
android:layout_height="match_parent"
android:drawablePadding="@dimen/dp_5"
android:layout_marginLeft="@dimen/dp_5"
android:layout_weight="1"
android:focusableInTouchMode="true"
android:focusable="true"
android:background="@null"
android:inputType="none"
tools:hint="請輸入食品組名稱" />
<ImageView
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout 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"
style="@style/Multi_Layout_Style"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="@dimen/dp_75">
android:layout_height="wrap_content">
<RelativeLayout
<TextView
android:id="@+id/multi_required"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/dp_5"
android:layout_weight="1">
android:layout_height="0dp"
android:visibility="gone" />
<EditText
<TextView
android:id="@+id/tv_multi_title"
android:layout_width="0dp"
android:layout_height="0dp"
tools:text="" />
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:counterEnabled="true"
app:counterMaxLength="@integer/remark_max_length">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/ed_multi_value"
style="@style/Multi_Input_editStyle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/iv_clear_multi_content"
android:background="@null"
android:gravity="left"
android:minHeight="@dimen/dp_75"
android:paddingTop="@dimen/dp_10"
android:scrollbars="vertical"
tools:hint="請輸入食品組名稱" />
</com.google.android.material.textfield.TextInputLayout>
<ImageView
android:id="@+id/iv_clear_multi_content"
android:layout_width="@dimen/dp_30"
android:layout_height="@dimen/dp_30"
android:layout_alignParentRight="true"
android:layout_marginLeft="@dimen/dp_5"
android:padding="@dimen/dp_8"
android:src="@drawable/ic_clear_text"
android:visibility="gone" />
<TextView
android:id="@+id/tv_edit_text_length"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/hint_color"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_margin="@dimen/dp_5"
android:textSize="@dimen/dp_12"
tools:text="0/50" />
</RelativeLayout>
</LinearLayout>
</FrameLayout>
This source diff could not be displayed because it is too large. You can view the blob instead.
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