Commit 2ea685ea by 宁斌

Merge remote-tracking branch 'origin/dev' into dev

parents 5d6a161a 771adf38
......@@ -2,7 +2,6 @@ package com.joe.print.mvp.print;
import android.content.Context;
import android.graphics.Bitmap;
import android.os.Looper;
import android.util.Log;
import com.epson.epos2.Epos2Exception;
......@@ -113,20 +112,24 @@ public class EpsonPrint implements ReceiveListener {
*/
private boolean createPrintData(Bitmap bitmap) {
try {
mPrinter.addTextAlign(Printer.ALIGN_CENTER);
//Printer.MODE_MONO单色(2个刻度)
//Printer.MODE_GRAY16多灰度(16刻度)
//Printer.MODE_MONO_HIGH_DENSITY 高密度单色(2个刻度),双倍密度
// 使用雙倍密度更清晰。但是寬度會被压窄一半,所以需要处理bitmap宽度为正常的两倍
//Printer.HALFTONE_DITHER 抖動(適用於打印圖形) 打印效果比較多一些噪點
//Printer.HALFTONE_ERROR_DIFFUSION 错误扩散(适合打印文本和图形) 打印效果比較多一些噪點
//Printer.HALFTONE_THRESHOLD 阈值(仅适用于打印文本) 打印效果更平滑
mPrinter.addImage(bitmap, 0, 0,
bitmap.getWidth(),
bitmap.getHeight(),
Printer.COLOR_1,
Printer.MODE_MONO_HIGH_DENSITY,//密度
Printer.HALFTONE_DITHER,//半色調抖動
Printer.PARAM_DEFAULT,
Printer.COMPRESS_NONE);//壓縮
Printer.COLOR_NONE,//顏色
Printer.MODE_MONO_HIGH_DENSITY,//密度
Printer.HALFTONE_THRESHOLD,//色調抖動
Printer.PARAM_DEFAULT,//亮度
Printer.COMPRESS_AUTO);//壓縮
mPrinter.addCut(Printer.CUT_FEED);
//COLOR_NONE 為普通顏色 COLOR_2為紅色
// mPrinter.addTextSize(2, 2);
// mPrinter.addTextStyle(0,0,1, Printer.COLOR_1);
// mPrinter.addText("炒爐打印測試\n");
} catch (Exception e) {
e.printStackTrace();
mPrinter.clearCommandBuffer();
......
package com.joe.print.mvp.print;
import android.content.Context;
import android.graphics.Bitmap;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.gingersoft.gsa.cloud.common.core.table.TableBean;
import com.gingersoft.gsa.cloud.common.core.user.UserContext;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
import com.gingersoft.gsa.cloud.common.utils.time.TimeUtils;
import com.gingersoft.gsa.cloud.database.bean.PrinterDeviceBean;
import com.gingersoft.gsa.cloud.order.commodity.OrderDetail;
import com.gingersoft.gsa.cloud.order.order.DoshokuOrder;
import com.joe.print.R;
import com.joe.print.mvp.ui.adapter.KitChenPrintFoodAdapter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/**
* 廚房單打印
*/
public class PrintKitchen extends PrinterRoot {
@Override
public Map<String, List<Bitmap>> getPrintBitmap(Context mContext, PrinterDeviceBean deviceBean) {
Map<String, List<Bitmap>> bitmapMaps = new HashMap<>();
List<OrderDetail> orderDetails = DoshokuOrder.getInstance().getNewFoodList();
if (orderDetails != null) {
// for (int i = 0; i < orderDetails.size(); i++) {
// orderDetails.get(i).setPrintseting(printLocation[i % 2]);
// }
//廚房單,可能會有多個IP打印
//獲得ip打印列表,
//再將食品數據根據打印位置分組。
//打印一組之後,關閉連接,切換第二台打印機ip,如此循環
//打印完成之後,返回所有打印結果。
Map<String, List<OrderDetail>> foodMaps = new HashMap<>();
String emptyPrintLocation = "";//部分食品沒有打印位置時設置為此key,比如這是第一個食品,沒有打印位置時
int lastEmptyPrintLocationIndex = 0;//上一次遍歷到第一個食品時都沒有打印位置時,開始的食品位置
//將所有食品進行遍歷,分組
for (int i = 0; i < orderDetails.size(); i++) {
OrderDetail food = orderDetails.get(i);
if (TextUtil.isEmptyOrNullOrUndefined(food.getPrintseting())) {
//如果沒有打印位置,向上尋找
if (i == 0) {
food.setPrintseting(emptyPrintLocation);
addToMap(foodMaps, food);
} else {
for (int j = i - 1; j >= lastEmptyPrintLocationIndex; j--) {
//一直遍歷,直到找到有打印位置的食品
// 如果所有食品都沒有打印位置的情況,為了避免多次遍歷
// 如果本次遍歷到第一個食品,都沒有打印位置,記錄下這一次開始遍歷的下標,下一次遍歷到這個位置就停止
if (!TextUtil.isEmptyOrNullOrUndefined(orderDetails.get(j).getPrintseting())) {
//一直遍歷,直到找到有打印位置的食品
//判斷是否帶*號
if (orderDetails.get(j).getPrintseting().contains("*")) {
//帶*號,則需要取得通過下標加去掉*號的標識來取得map中的集合,將i食品裝進去,這樣就能打印在一張紙上
//如果沒取得集合,則通過打印位置去map取得集合,將j食品從map中移除,將這個j食品的和i食品裝一起
// 生成新的key。為當前下標+"標識符"+去掉*的打印位置,不帶*的key取得的食品集合才能打印在一張紙上。
String newKey = j + DELIMITER + orderDetails.get(j).getPrintseting().replaceAll("\\*", "");
//通過newKey取得map中的集合
List<OrderDetail> newKeyfoods = foodMaps.get(newKey);
if (newKeyfoods != null) {
newKeyfoods.add(food);
} else {
List<OrderDetail> printsetingFoods = foodMaps.get(orderDetails.get(j).getPrintseting());
if (printsetingFoods != null) {//理論上不會為空
printsetingFoods.remove(printsetingFoods.lastIndexOf(orderDetails.get(j)));
//移除掉之後,put到newkey中
List<OrderDetail> newFoods = new ArrayList<>();
newFoods.add(orderDetails.get(j));
newFoods.add(food);
foodMaps.put(newKey, newFoods);
}
}
break;
} else {
//沒有*號,不需要做多餘的操作
food.setPrintseting(orderDetails.get(j).getPrintseting());
addToMap(foodMaps, food);
}
} else if (j == lastEmptyPrintLocationIndex) {
//從i到0的打印位置都沒有,記錄下i,下次只遍歷到i就停下來
lastEmptyPrintLocationIndex = i;
//如果找到最初的那個食品,也沒有打印位置,設置打印位置為"null"
food.setPrintseting(emptyPrintLocation);
addToMap(foodMaps, food);
}
}
}
} else {
//有打印位置,
//已經保存過這個位置的,
addToMap(foodMaps, food);
}
}
//通過打印位置生成多張用於打印的bitmap
for (Map.Entry<String, List<OrderDetail>> entry : foodMaps.entrySet()) {
String key = entry.getKey();
List<Bitmap> bitmaps = new ArrayList<>();
if (key.contains("*")) {
//如果帶*號,這個集合就需要切紙,每個食品都需要單獨在一張廚房單上
for (OrderDetail orderDetail : entry.getValue()) {
List<OrderDetail> orders = new ArrayList<>();//這裡new集合是因為下面的方法需要的參數是list集合
orders.add(orderDetail);
Bitmap bitmap = getKitChenPrintBitmap(mContext, orders, deviceBean);
bitmaps.add(bitmap);
}
} else {
Bitmap bitmap = getKitChenPrintBitmap(mContext, entry.getValue(), deviceBean);
//不帶*號,所有同樣廚房位置的食品都在一張紙上
bitmaps.add(bitmap);
}
bitmapMaps.put(key, bitmaps);
}
}
return bitmapMaps;
}
@Override
public String[] getPrintDatas(Context mContext, PrinterDeviceBean deviceBean) {
return null;
}
@Override
public int getPrintCount(Context context) {
return 1;
}
private void addToMap(Map<String, List<OrderDetail>> foodMaps, OrderDetail food) {
if (foodMaps.get(food.getPrintseting()) != null) {
Objects.requireNonNull(foodMaps.get(food.getPrintseting())).add(food);
} else {
List<OrderDetail> newFoods = new ArrayList<>();
newFoods.add(food);
foodMaps.put(food.getPrintseting(), newFoods);
}
}
/**
* 獲取"廚房單"圖片
*
* @param context
* @return
*/
private Bitmap getKitChenPrintBitmap(Context context, List<OrderDetail> foodList, PrinterDeviceBean printerDeviceBean) {
if (foodList == null || foodList.size() <= 0) {
return null;
}
DoshokuOrder doshokuOrder = DoshokuOrder.getInstance();
View view = LinearLayout.inflate(context, R.layout.print_kitchen, null);
TextView tvTableNumber = view.findViewById(R.id.tv_kitchen_print_table_number);
TextView tvOrderNumber = view.findViewById(R.id.tv_order_num);
TextView tvOpeningTime = view.findViewById(R.id.tv_opening_time);
TextView tvOrderTime = view.findViewById(R.id.tv_order_time);
TextView tvKitChenLocation = view.findViewById(R.id.tv_kitchen_location);
TextView tvPeople = view.findViewById(R.id.tv_people);
TextView tvOperator = view.findViewById(R.id.tv_operator);
RecyclerView rvFood = view.findViewById(R.id.rv_kitchen_food);
TextView tvTableNumber2 = view.findViewById(R.id.tv_kitchen_print_table_number2);
if (foodList.size() > 0 && foodList.get(0) != null) {
KitChenPrintFoodAdapter foodAdapter = new KitChenPrintFoodAdapter(foodList);
rvFood.setLayoutManager(new LinearLayoutManager(context));
rvFood.setAdapter(foodAdapter);
//廚房位置
if (!TextUtil.isEmptyOrNullOrUndefined(foodList.get(0).getPrintseting())) {
tvKitChenLocation.setText(foodList.get(0).getPrintseting());//.replace("*", "")
tvKitChenLocation.setVisibility(View.VISIBLE);
} else {
tvKitChenLocation.setVisibility(View.GONE);
}
}
TableBean.DataBean dataBean = doshokuOrder.getOpenTableInfo();
if (dataBean != null) {
//台號
tvTableNumber.setText(dataBean.getTableName() + "");
tvTableNumber2.setText(dataBean.getTableName() + "");
//人數
tvPeople.setText(dataBean.getPerson() + "");
//訂單號
tvOrderNumber.setText("" + dataBean.getOrderId());
//開台時間
tvOpeningTime.setText(TimeUtils.parseTimeRepeat(dataBean.getCreateTime(), TimeUtils.DEFAULT_DATE_FORMAT));
}
//落單時間,為當前時間
tvOrderTime.setText(TimeUtils.getCurrentTimeInString(TimeUtils.DEFAULT_DATE_FORMAT));
//操作人員
tvOperator.setText(UserContext.newInstance().getMemberName());
return viewToZoomBitmap(context, view, printerDeviceBean);
}
}
......@@ -7,9 +7,6 @@ import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.gingersoft.gsa.cloud.common.constans.OrderTypeConstans;
import com.gingersoft.gsa.cloud.common.core.restaurant.utils.RestaurantExpandInfoUtils;
import com.gingersoft.gsa.cloud.common.utils.other.TextUtil;
......@@ -20,6 +17,7 @@ import com.gingersoft.gsa.cloud.print.bean.PrjBean;
import com.joe.print.mvp.model.bean.HtmlLable;
import com.joe.print.mvp.print.common.HtmlContract;
import com.joe.print.R;
import com.joe.print.mvp.print.service.PrjService;
import com.joe.print.mvp.ui.view.KitChenPrjFoodView;
import java.util.ArrayList;
......@@ -254,7 +252,13 @@ public class PrintPrjKitchen extends PrinterRoot {
return null;
}
setFoodItemType(data);
View view = LinearLayout.inflate(context, R.layout.print_kitchen2, null);
View view;
if (PrjService.isPinPrinter(printerDeviceBean)) {
//针式暂时用这个新的布局
view = LinearLayout.inflate(context, R.layout.print_dot_matrix_kitchen, null);
} else {
view = LinearLayout.inflate(context, R.layout.print_kitchen, null);
}
TextView tvTableNumber = view.findViewById(R.id.tv_kitchen_print_table_number);
TextView tvOrderNumberText = view.findViewById(R.id.tv_order_num_text);
TextView tvOrderNumber = view.findViewById(R.id.tv_order_num);
......@@ -267,7 +271,6 @@ public class PrintPrjKitchen extends PrinterRoot {
TextView tvKitChenLocation = view.findViewById(R.id.tv_kitchen_location);
TextView tvPeople = view.findViewById(R.id.tv_people);
TextView tvCurrentPageIndex = view.findViewById(R.id.tv_prj_page_index);
// RecyclerView rvFood = view.findViewById(R.id.rv_kitchen_food);
LinearLayout foodLayout = view.findViewById(R.id.ll_kitchen_food);
TextView tvTableNumber2 = view.findViewById(R.id.tv_kitchen_print_table_number_bottom);
TextView tvFirstOrder = view.findViewById(R.id.tv_kitchen_print_first_order);
......@@ -281,15 +284,14 @@ public class PrintPrjKitchen extends PrinterRoot {
LinearLayout layoutOpenTableTime = view.findViewById(R.id.ll_opening_table_time);
foodLayout.addView(new KitChenPrjFoodView(context, data, printerDeviceBean));
// KitChenPrjPrintFoodAdapter foodAdapter = new KitChenPrjPrintFoodAdapter(data, printerDeviceBean);
// rvFood.setLayoutManager(new LinearLayoutManager(context));
// rvFood.setAdapter(foodAdapter);
//廚房位置
if (!TextUtil.isEmptyOrNullOrUndefined(key) && !key.equals("-1")) {
tvKitChenLocationText.setVisibility(View.VISIBLE);
tvKitChenLocation.setVisibility(View.VISIBLE);
tvKitChenLocation.setText(key);
} else {
tvKitChenLocationText.setVisibility(View.GONE);
tvKitChenLocation.setVisibility(View.GONE);
}
if (!TextUtil.isEmptyOrNullOrUndefined(prjBean.getBillNo())) {
......@@ -307,11 +309,6 @@ public class PrintPrjKitchen extends PrinterRoot {
tvTableNumber2.setText("堂食");
tvTableNumber.setText(prjBean.getTableName());
tvTableNumber2.setText(prjBean.getTableName());
// if (!TextUtil.isEmptyOrNullOrUndefined(prjBean.getTakeFoodCode())) {
// tvTakeCodeText.setVisibility(View.VISIBLE);
// tvTakeCode.setVisibility(View.VISIBLE);
// tvTakeCode.setText(prjBean.getTakeFoodCode());
// }
break;
case OrderTypeConstans.order_type_7:
layoutOpenTableTime.setVisibility(View.GONE);
......@@ -344,45 +341,12 @@ public class PrintPrjKitchen extends PrinterRoot {
} else {
tvWaiter.setText(prjBean.getMemberName());
}
// if (TextUtil.isEmptyOrNullOrUndefined(prjBean.getTableName())) {
// layoutOpenTableTime.setVisibility(View.GONE);
// switch (prjBean.getOrderType()) {
// case 1:
// case 3:
// tvTableNumber.setText("堂食");
// tvTableNumber2.setText("堂食");
// if (!TextUtil.isEmptyOrNullOrUndefined(prjBean.getTakeFoodCode())) {
// tvTakeCodeText.setVisibility(View.VISIBLE);
// tvTakeCode.setVisibility(View.VISIBLE);
// tvTakeCode.setText(prjBean.getTakeFoodCode());
// }
// break;
// case 7:
// tvTableNumber.setText("自取");
// tvTableNumber2.setText("自取");
// if (!TextUtil.isEmptyOrNullOrUndefined(prjBean.getTakeFoodCode())) {
// tvTakeCodeText.setVisibility(View.VISIBLE);
// tvTakeCode.setVisibility(View.VISIBLE);
// tvTakeCode.setText(prjBean.getTakeFoodCode());
// }
// break;
// default:
// tvTableNumber.setText("外賣");
// tvTableNumber2.setText("外賣");
// tvOrderNumberText.setText("訂單碼:");
// tvOrderNumber.setText(prjBean.getTakeFoodCode());
// break;
// }
// } else {
// tvTableNumber.setText(prjBean.getTableName());
// tvTableNumber2.setText(prjBean.getTableName());
// }
//人數
if (prjBean.getPerson() != 0) {
tvPeople.setText(prjBean.getPerson() + "");
view.findViewById(R.id.tv_people_text).setVisibility(View.VISIBLE);
view.findViewById(R.id.tv_people).setVisibility(View.VISIBLE);
}
int visibility = prjBean.getPerson() == 0 ? View.GONE : View.VISIBLE;
view.findViewById(R.id.tv_people_text).setVisibility(visibility);
tvPeople.setVisibility(visibility);
if (TextUtil.isNotEmptyOrNullOrUndefined(prjBean.getTakeTime())) {
tvTakeTime.setText("取餐:" + prjBean.getTakeTime());
} else if (TextUtil.isNotEmptyOrNullOrUndefined(prjBean.getSendTime())) {
......@@ -404,18 +368,6 @@ public class PrintPrjKitchen extends PrinterRoot {
}
//開台時間
tvOpeningTime.setText(TimeUtils.parseTimeRepeat(prjBean.getOrderDetailsTime(), TimeUtils.DEFAULT_DATE_MDHM));
// if (OpenTableManage.getDefault().getTableBean() != null) {
// //台號
// tvTableNumber.setText(prjBean.getTableName());
// tvTableNumber2.setText(prjBean.getTableName());
// //人數
// tvPeople.setText(prjBean.getPerson() + "");
// //訂單號
// tvOrderNumber.setText(prjBean.getOrderNo());
// //開台時間
// tvOpeningTime.setText(TimeUtils.parseTimeRepeat(prjBean.getOrderDetailsTime(), TimeUtils.DEFAULT_DATE_FORMAT));
// }
//落單時間,為當前時間
tvOrderTime.setText(TimeUtils.getCurrentTimeInString(TimeUtils.DEFAULT_DATE_MDHM));
if (RestaurantExpandInfoUtils.getValue(ExpandConstant.PrintPage, false)) {
......@@ -423,7 +375,6 @@ public class PrintPrjKitchen extends PrinterRoot {
tvCurrentPageIndex.setText(prjBean.getCurrentIndex() + "/" + prjBean.getTotalPrj());
}
}
return viewToZoomBitmap(context, view, printerDeviceBean);
}
......
......@@ -9,7 +9,6 @@ import android.os.Build;
import android.os.IBinder;
import android.os.RemoteException;
import android.text.TextUtils;
import android.util.Log;
import android.util.SparseArray;
import android.view.Gravity;
import android.view.View;
......@@ -68,6 +67,7 @@ import com.joe.print.mvp.print.common.HtmlContract;
import com.joe.print.mvp.print.common.PrinterFinderCallback;
import com.joe.print.mvp.print.common.SendResultCode;
import com.joe.print.mvp.print.maker.IpPrintMaker;
import com.joe.print.mvp.print.service.PrjService;
import com.joe.print.mvp.print.usb.EscCommand;
import com.joe.print.mvp.print.usb.UsbPrint;
import com.joe.print.mvp.print.usb.UsbPrinter;
......@@ -82,7 +82,6 @@ import com.xuexiang.rxutil2.rxjava.RxJavaUtils;
import com.xuexiang.rxutil2.rxjava.task.RxIOTask;
import java.io.IOException;
import java.net.ConnectException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
......@@ -454,6 +453,7 @@ public abstract class PrinterRoot<T extends PrintContent> implements PrintExecut
*/
final Bitmap viewToZoomBitmap(Context context, View view, PrinterDeviceBean printerDeviceBean) {
LayoutToBitmapUtils.layoutView(context, view);//先测量view
// return LayoutToBitmapUtils.loadBitmapFromView(view);
//轉為bitmap
return zoomBitmap(printerDeviceBean, LayoutToBitmapUtils.loadBitmapFromView(view));
}
......@@ -467,12 +467,18 @@ public abstract class PrinterRoot<T extends PrintContent> implements PrintExecut
*/
private Bitmap zoomBitmap(PrinterDeviceBean printerDeviceBean, Bitmap bitmap) {
int printWidth;
if (PrjService.isPinPrinter(printerDeviceBean)) {
//epson针式打印機
printWidth = 200;
return ImageUtils.dotMatrixZoomDrawable(bitmap, printWidth);
} else {
if (printerDeviceBean != null && printerDeviceBean.getPaperSpecification() != null) {
printWidth = Double.valueOf(printerDeviceBean.getPaperSpecification()).intValue();
} else {
//如果打印機沒設置寬度
printWidth = 480;
}
}
return ImageUtils.zoomDrawable(bitmap, printWidth);
}
......@@ -939,7 +945,7 @@ public abstract class PrinterRoot<T extends PrintContent> implements PrintExecut
}
public View getAmountText(Context mContext, String text) {
return getTextView(mContext, text, Gravity.RIGHT, 24, ContextCompat.getColor(mContext, R.color.black));
return getTextView(mContext, text, Gravity.RIGHT, 28, ContextCompat.getColor(mContext, R.color.black));
}
public TextView getTextView(Context mContext, String text, int gravity, float textSize) {
......
......@@ -1044,7 +1044,7 @@ public class PrjService extends Service implements ReceiveListener {
* @param printerDeviceBean 打印機實體類
* @return true是
*/
private boolean isPinPrinter(PrinterDeviceBean printerDeviceBean) {
public static boolean isPinPrinter(PrinterDeviceBean printerDeviceBean) {
return (printerDeviceBean != null && printerDeviceBean.getPrinterName() != null && printerDeviceBean.getPrinterName().toLowerCase().contains("EPSON".toLowerCase()))
&& (printerDeviceBean.getModel() != null && printerDeviceBean.getModel().toLowerCase().contains("TM-U220B".toLowerCase()));
}
......
......@@ -7,7 +7,7 @@
<TextView
android:id="@+id/print_brand_name"
style="@style/Print_text_style"
style="@style/Print_header_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
......@@ -17,7 +17,7 @@
<TextView
android:id="@+id/print_restaurant_name"
style="@style/Print_text_style"
style="@style/Print_header_textStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
......
......@@ -31,7 +31,7 @@
<style name="print_other_order_twenty_six_style">
<item name="android:textColor">@color/theme_333_color</item>
<item name="android:textSize">@dimen/dp_26</item>
<item name="android:textSize">@dimen/dp_28</item>
</style>
<style name="print_other_order_thirty_style">
......@@ -58,4 +58,10 @@
<item name="android:textSize">@dimen/dp_16</item>
<item name="android:textColor">@color/theme_color</item>
</style>
<style name="Print_header_textStyle">
<item name="android:textSize">@dimen/dp_26</item>
<item name="android:textColor">@color/black</item>
</style>
</resources>
\ No newline at end of file
package com.gingersoft.supply_chain.mvp.bean;
/**
* @author 宇航.
* User: admin
* Date: 2021/3/19
* Time: 18:54
* Use:打印出庫單用
*/
public class OutboundOrderBean {
private String name;
private String value;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public OutboundOrderBean(String name, String value) {
this.name = name;
this.value = value;
}
}
......@@ -166,12 +166,12 @@ public class PurchaseFoodBean implements Serializable, QMUISection.Model<Purchas
@Override
public boolean isSameItem(PurchaseFoodBean other) {
return false;
return id.equals(other.id);
}
@Override
public boolean isSameContent(PurchaseFoodBean other) {
return false;
return foodNo.equals(other.foodNo);
}
}
package com.gingersoft.supply_chain.mvp.bean;
import java.io.Serializable;
import java.util.List;
import lombok.Data;
......@@ -31,7 +32,7 @@ public class WareHouseListBean {
* purchaseWarehousingOrderDetailsVOS : [{"id":84,"name":"阿克苏苹果🍎","cateName":"特级水果","supplierName":"盒马生鲜","basicUnitName":"1","foodPrice":89,"foodNum":3,"foodAmount":267},{"id":67,"name":"大閘蟹","cateName":"海鮮","supplierName":"測試供應商1205","basicUnitName":"1","foodPrice":100,"foodNum":3,"foodAmount":300},{"id":66,"name":"澳洲龍蝦","cateName":"海鮮","supplierName":"測試供應商1205","basicUnitName":"1","foodPrice":100,"foodNum":3,"foodAmount":300},{"id":3,"name":"香蕉","cateName":"青菜","supplierName":"人民公社供應商","basicUnitName":"3","foodPrice":2,"foodNum":20,"foodAmount":200}]
*/
private TotalBean total;
private List<PurchaseWarehousingOrderDetailsVOSBean> purchaseWarehousingOrderDetailsVOS;
private List<PurchaseWarehousingOrderDetailsVO> purchaseWarehousingOrderDetailsVOS;
/**
* 數量統計
......@@ -71,7 +72,7 @@ public class WareHouseListBean {
* 食品信息
*/
@Data
public static class PurchaseWarehousingOrderDetailsVOSBean {
public static class PurchaseWarehousingOrderDetailsVO implements Serializable {
/**
* id : 84
* name : 阿克苏苹果🍎
......@@ -92,6 +93,7 @@ public class WareHouseListBean {
private int foodNum;
private double foodAmount;
private String images;
private boolean snFood;
}
}
}
......@@ -52,7 +52,7 @@ public interface BuyIngredientsContract {
* 加載食品
* @param food
*/
void loadFood(List<QMUISection<CategoryBean, PurchaseFoodBean>> food);
void loadFood(int categoryId, List<QMUISection<CategoryBean, PurchaseFoodBean>> food);
}
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
......
......@@ -28,7 +28,7 @@ public interface WareHouseListContract {
interface View extends IView {
void loadWarehousingInfo(WareHouseListBean.WareHousingDataBean data);
void loadListInfo(List<WareHouseListBean.WareHousingDataBean.PurchaseWarehousingOrderDetailsVOSBean> purchaseWarehousingOrderDetailsVos);
void loadListInfo(List<WareHouseListBean.WareHousingDataBean.PurchaseWarehousingOrderDetailsVO> purchaseWarehousingOrderDetailsVos);
void finishLoad();
......
......@@ -65,6 +65,10 @@ public class BuyIngredientsPresenter extends BasePresenter<BuyIngredientsContrac
private List<CategoryFoodTreeBean> categoryFoodTreeBeans;
private Map<Integer, List<QMUISection<CategoryBean, PurchaseFoodBean>>> foodSectionMap = new HashMap<>();
/**
* 是否正在加載食品中
*/
private boolean isLoadFood = false;
@Inject
public BuyIngredientsPresenter(BuyIngredientsContract.Model model, BuyIngredientsContract.View rootView) {
......@@ -159,6 +163,17 @@ public class BuyIngredientsPresenter extends BasePresenter<BuyIngredientsContrac
}
public void getFoodByCategoryId() {
}
public void getFood(int parentCategoryId) {
List<QMUISection<CategoryBean, PurchaseFoodBean>> foodSections = foodSectionMap.get(parentCategoryId);
if (foodSections == null) {
getFoodByCategoryId(parentCategoryId);
} else {
mRootView.loadFood(parentCategoryId, foodSections);
}
}
/**
......@@ -166,7 +181,7 @@ public class BuyIngredientsPresenter extends BasePresenter<BuyIngredientsContrac
*
* @param parentCategoryId 父分類id
*/
public void getFoodByCategoryId(int parentCategoryId) {
private void getFoodByCategoryId(int parentCategoryId) {
Map<String, Object> map = new HashMap<>(5);
map.put("pageSize", 1000);
map.put("pageIndex", 0);
......@@ -191,7 +206,7 @@ public class BuyIngredientsPresenter extends BasePresenter<BuyIngredientsContrac
//將食品和分類整合到一起,List<QMUISection<CategoryBean, PurchaseFoodBean>>
val sections = foodToList(info.getData());
foodSectionMap.put(parentCategoryId, sections);
mRootView.loadFood(sections);
mRootView.loadFood(parentCategoryId, sections);
// mRootView.loadRightFoodIngredients(filterThisCategoryFood(categoryId, info.getData()));
} else if (TextUtil.isNotEmptyOrNullOrUndefined(info.getErrMsg())) {
mRootView.showMessage(info.getErrMsg());
......@@ -235,7 +250,7 @@ public class BuyIngredientsPresenter extends BasePresenter<BuyIngredientsContrac
List<QMUISection<CategoryBean, PurchaseFoodBean>> sections = new ArrayList<>();
CategoryBean categoryBean = new CategoryBean();
List<PurchaseFoodBean> purchaseFoodBeans = new ArrayList<>();
for (int i = 0; i < data.size(); i++) {
for (int i = data.size() - 1; i >= 0; i--) {
PurchaseFoodBean purchaseFoodBean = data.get(i);
if (categoryBean.getId() == null) {
categoryBean.setId(purchaseFoodBean.getFoodCategoryId());
......@@ -248,7 +263,7 @@ public class BuyIngredientsPresenter extends BasePresenter<BuyIngredientsContrac
}
}
purchaseFoodBeans.add(purchaseFoodBean);
if (i == data.size() - 1) {
if (i == 0) {
//最後一個食品
sections.add(new QMUISection<>(categoryBean, purchaseFoodBeans));
}
......@@ -288,4 +303,13 @@ public class BuyIngredientsPresenter extends BasePresenter<BuyIngredientsContrac
}
return foods;
}
public boolean isLoadFood() {
return isLoadFood;
}
public void setLoadFood(boolean loadFood) {
isLoadFood = loadFood;
}
}
......@@ -23,6 +23,7 @@ import javax.inject.Inject;
import com.gingersoft.supply_chain.mvp.contract.WarehousingInventoryContract;
import com.jess.arms.utils.RxLifecycleUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -51,6 +52,8 @@ public class WarehousingInventoryPresenter extends BasePresenter<WarehousingInve
@Inject
AppManager mAppManager;
private List<InventoryRecordBean> inventoryRecordBeanList;
@Inject
public WarehousingInventoryPresenter(WarehousingInventoryContract.Model model, WarehousingInventoryContract.View rootView) {
super(model, rootView);
......@@ -122,7 +125,14 @@ public class WarehousingInventoryPresenter extends BasePresenter<WarehousingInve
public void onNext(BaseResult baseResult) {
if (baseResult != null && baseResult.isSuccess()) {
List<InventoryRecordBean> inventoryRecordBeans = GsonUtils.jsonToList(baseResult.getData(), InventoryRecordBean.class);
mRootView.loadRecord(inventoryRecordBeans);
if (inventoryRecordBeanList == null) {
inventoryRecordBeanList = new ArrayList<>();
}
if (pageIndex == 0) {
inventoryRecordBeanList.clear();
}
inventoryRecordBeanList.addAll(inventoryRecordBeans);
mRootView.loadRecord(inventoryRecordBeanList);
} else if (baseResult != null && TextUtil.isNotEmptyOrNullOrUndefined(baseResult.getErrMsg())) {
mRootView.showMessage(baseResult.getErrMsg());
} else {
......
......@@ -2,6 +2,7 @@ package com.gingersoft.supply_chain.mvp.ui.adapter;
import android.content.Context;
import android.text.Editable;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
......@@ -40,13 +41,14 @@ import butterknife.ButterKnife;
public class BuyIngredientsAdapter extends QMUIDefaultStickySectionAdapter<CategoryBean, PurchaseFoodBean> {
private Context context;
private boolean isShowDouble = false;
private boolean isSinger = true;
public BuyIngredientsAdapter(Context context, List<QMUISection<CategoryBean, PurchaseFoodBean>> food) {
this.context = context;
setData(food);
}
@NonNull
@Override
protected HeadViewHolder onCreateSectionHeaderViewHolder(@NonNull ViewGroup viewGroup) {
......@@ -54,14 +56,14 @@ public class BuyIngredientsAdapter extends QMUIDefaultStickySectionAdapter<Categ
}
public int getLayoutId() {
if (isShowDouble) {
return R.layout.item_buy_food_ingredient_double_row;
}
if (isSinger) {
return R.layout.item_buy_food_ingredient;
}
return R.layout.item_buy_food_ingredient_double_row;
}
public void setShowDoubleRow(boolean showType) {
isShowDouble = showType;
public void setShowSingerRow(boolean showType) {
isSinger = showType;
}
@NonNull
......@@ -115,7 +117,7 @@ public class BuyIngredientsAdapter extends QMUIDefaultStickySectionAdapter<Categ
//食材數量增加
purchaseFoodBean.setFoodQuantity(purchaseFoodBean.getFoodQuantity() + 1);
itemViewHolder.edFoodIngredientNumber.setText(String.valueOf(purchaseFoodBean.getFoodQuantity()));
setSubAndNumShow(itemViewHolder, true);
setSubAndNumShow(itemViewHolder, false);
});
//輸入框焦點監聽
itemViewHolder.edFoodIngredientNumber.setOnFocusChangeListener((v, hasFocus) -> {
......
......@@ -22,13 +22,13 @@ public class ConsumptionReasonAdapter extends BaseQuickAdapter<ConsumeReasonBean
private int selectIndex = 0;
public ConsumptionReasonAdapter(List<ConsumeReasonBean> consumeReasonBeans) {
super(R.layout.item_consumption_reason, consumeReasonBeans);
addChildClickViewIds(R.id.cb_consumption_reason);
super(R.layout.btn_gray_to_blue, consumeReasonBeans);
addChildClickViewIds(R.id.cb_gray_to_blue);
}
@Override
protected void convert(@NotNull BaseViewHolder viewHolder, ConsumeReasonBean consumeReasonBean) {
AppCompatCheckBox compatCheckBox = viewHolder.getView(R.id.cb_consumption_reason);
AppCompatCheckBox compatCheckBox = viewHolder.getView(R.id.cb_gray_to_blue);
compatCheckBox.setText(consumeReasonBean.getDescription());
compatCheckBox.setChecked(viewHolder.getAdapterPosition() == selectIndex);
}
......
......@@ -6,12 +6,14 @@ 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.time.TimeUtils;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.mvp.bean.InventoryRecordBean;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.sql.Time;
import java.util.List;
import cn.bingoogolapple.baseadapter.BGABaseAdapterUtil;
......@@ -33,9 +35,9 @@ public class InventoryRecordAdapter extends BaseQuickAdapter<InventoryRecordBean
@Override
protected void convert(@NotNull BaseViewHolder viewHolder, InventoryRecordBean inventoryRecordBean) {
viewHolder.setText(R.id.tv_inventory_record_username, inventoryRecordBean.getUserName());
viewHolder.setText(R.id.tv_inventory_record_number, inventoryRecordBean.getUserName());
viewHolder.setText(R.id.tv_inventory_record_difference, inventoryRecordBean.getUserName());
viewHolder.setText(R.id.tv_inventory_record_operating_data, inventoryRecordBean.getUserName());
viewHolder.setText(R.id.tv_inventory_record_number, String.valueOf(inventoryRecordBean.getRemainingQuantity()));
viewHolder.setText(R.id.tv_inventory_record_difference, String.valueOf(inventoryRecordBean.getConsumeQuantity()));
viewHolder.setText(R.id.tv_inventory_record_operating_data, TimeUtils.getTime(inventoryRecordBean.getCreateTime(), TimeUtils.DEFAULT_DATE_FORMAT));
viewHolder.setTextColor(R.id.tv_inventory_record_username, ContextCompat.getColor(getContext(), R.color.color_3c));
viewHolder.setTextColor(R.id.tv_inventory_record_number, ContextCompat.getColor(getContext(), R.color.color_3c));
......@@ -43,6 +45,12 @@ public class InventoryRecordAdapter extends BaseQuickAdapter<InventoryRecordBean
viewHolder.setTextColor(R.id.tv_inventory_record_operating_data, ContextCompat.getColor(getContext(), R.color.color_3c));
viewHolder.setBackgroundColor(R.id.layout_inventory_record, BGABaseAdapterUtil.getColor(colors[viewHolder.getAdapterPosition() % 2]));
if (inventoryRecordBean.getConsumeQuantity() > 0) {
viewHolder.setTextColor(R.id.tv_inventory_record_difference, ContextCompat.getColor(getContext(), R.color.required_color));
} else {
viewHolder.setTextColor(R.id.tv_inventory_record_difference, ContextCompat.getColor(getContext(), R.color.purchase_buy_again_color));
}
}
......
package com.gingersoft.supply_chain.mvp.ui.adapter;
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.OutboundOrderBean;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
/**
* @author 宇航.
* User: admin
* Date: 2021/3/19
* Time: 18:59
* Use:
*/
public class OutboundOrderAdapter extends BaseQuickAdapter<OutboundOrderBean, BaseViewHolder> {
public OutboundOrderAdapter(@Nullable List<OutboundOrderBean> data) {
super(R.layout.item_outbound_order, data);
}
@Override
protected void convert(@NotNull BaseViewHolder viewHolder, OutboundOrderBean outboundOrderBean) {
viewHolder.setText(R.id.tv_item_name,outboundOrderBean.getName());
viewHolder.setText(R.id.tv_item_value,outboundOrderBean.getValue());
}
}
package com.gingersoft.supply_chain.mvp.ui.adapter;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.pdf.PdfDocument;
import android.graphics.pdf.PdfRenderer;
import android.os.Build;
import android.os.Bundle;
import android.os.CancellationSignal;
import android.os.ParcelFileDescriptor;
import android.print.PageRange;
import android.print.PrintAttributes;
import android.print.PrintDocumentAdapter;
import android.print.PrintDocumentInfo;
import android.print.pdf.PrintedPdfDocument;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/**
* @author 宇航.
* User: admin
* Date: 2021/3/19
* Time: 17:56
* Use:
*/
public class PrintPdfAdapter extends PrintDocumentAdapter {
private Context context;
private int pageHeight;
private int pageWidth;
private PdfDocument mPdfDocument;
private int totalPages = 1;
private String pdfPath;
private List<Bitmap> mList;
public PrintPdfAdapter(Context context, String pdfPath) {
this.context = context;
this.pdfPath = pdfPath;
}
@Override
public void onLayout(PrintAttributes oldAttributes, PrintAttributes newAttributes, CancellationSignal cancellationSignal,
LayoutResultCallback callback,
Bundle metadata) {
mPdfDocument = new PrintedPdfDocument(context, newAttributes); //创建可打印PDF文档对象
pageHeight = PrintAttributes.MediaSize.ISO_A4.getHeightMils() * 72 / 1000; //设置尺寸
pageWidth = PrintAttributes.MediaSize.ISO_A4.getWidthMils() * 72 / 1000;
if (cancellationSignal.isCanceled()) {
callback.onLayoutCancelled();
return;
}
ParcelFileDescriptor mFileDescriptor;
PdfRenderer pdfRender = null;
PdfRenderer.Page page = null;
try {
mFileDescriptor = ParcelFileDescriptor.open(new File(pdfPath), ParcelFileDescriptor.MODE_READ_ONLY);
if (mFileDescriptor != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
pdfRender = new PdfRenderer(mFileDescriptor);
}
}
mList = new ArrayList<>();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
if (pdfRender != null && pdfRender.getPageCount() > 0) {
totalPages = pdfRender.getPageCount();
for (int i = 0; i < pdfRender.getPageCount(); i++) {
if (null != page) {
page.close();
}
page = pdfRender.openPage(i);
Bitmap bmp = Bitmap.createBitmap(page.getWidth() * 2, page.getHeight() * 2, Bitmap.Config.ARGB_8888);
page.render(bmp, null, null, PdfRenderer.Page.RENDER_MODE_FOR_DISPLAY);
mList.add(bmp);
}
}
}
if (null != page) {
page.close();
}
if (null != mFileDescriptor) {
mFileDescriptor.close();
}
if (null != pdfRender) {
pdfRender.close();
}
} catch (IOException e) {
e.printStackTrace();
}
if (totalPages > 0) {
PrintDocumentInfo.Builder builder = new PrintDocumentInfo
.Builder("快速入门.pdf")
.setContentType(PrintDocumentInfo.CONTENT_TYPE_DOCUMENT)
.setPageCount(totalPages); //构建文档配置信息
PrintDocumentInfo info = builder.build();
callback.onLayoutFinished(info, true);
} else {
callback.onLayoutFailed("Page count is zero.");
}
}
@Override
public void onWrite(final PageRange[] pageRanges, final ParcelFileDescriptor destination, final CancellationSignal cancellationSignal,
final WriteResultCallback callback) {
for (int i = 0; i < totalPages; i++) {
if (pageInRange(pageRanges, i)) //保证页码正确
{
PdfDocument.PageInfo newPage = new PdfDocument.PageInfo.Builder(pageWidth,
pageHeight, i).create();
PdfDocument.Page page =
mPdfDocument.startPage(newPage); //创建新页面
if (cancellationSignal.isCanceled()) { //取消信号
callback.onWriteCancelled();
mPdfDocument.close();
mPdfDocument = null;
return;
}
drawPage(page, i); //将内容绘制到页面Canvas上
mPdfDocument.finishPage(page);
}
}
try {
mPdfDocument.writeTo(new FileOutputStream(
destination.getFileDescriptor()));
} catch (IOException e) {
callback.onWriteFailed(e.toString());
return;
} finally {
mPdfDocument.close();
mPdfDocument = null;
}
callback.onWriteFinished(pageRanges);
}
private boolean pageInRange(PageRange[] pageRanges, int page) {
for (PageRange pageRange : pageRanges) {
if ((page >= pageRange.getStart()) &&
(page <= pageRange.getEnd())) {
return true;
}
}
return false;
}
/**
* 页面绘制(渲染)
*/
private void drawPage(PdfDocument.Page page, int pagenumber) {
Canvas canvas = page.getCanvas();
if (mList != null) {
Paint paint = new Paint();
Bitmap bitmap = mList.get(pagenumber);
int bitmapWidth = bitmap.getWidth();
int bitmapHeight = bitmap.getHeight();
// 计算缩放比例
float scale = (float) pageWidth / (float) bitmapWidth;
// 取得想要缩放的matrix参数
Matrix matrix = new Matrix();
matrix.postScale(scale, scale);
canvas.drawBitmap(bitmap, matrix, paint);
}
}
}
......@@ -50,7 +50,11 @@ public class SecondCategoryAdapter extends BaseQuickAdapter<OrderCategoryBean.Fo
TextView tvName = viewHolder.getView(R.id.tv_second_category_title);
CardView cardView = viewHolder.getView(R.id.card_purchase_category);
viewHolder.setVisible(R.id.tv_second_category_title, TextUtil.isNotEmptyOrNullOrUndefined(categoryBean.getName()));
if (viewHolder.getAdapterPosition() == selectIndex) {
notifyCheckState(viewHolder.getAdapterPosition(), tvName, cardView);
}
private void notifyCheckState(@NotNull int position, TextView tvName, CardView cardView) {
if (position == selectIndex) {
cardView.setBackground(ContextCompat.getDrawable(getContext(), checkedBg));
tvName.setTextColor(checkedTextColor);
} else {
......@@ -59,6 +63,18 @@ public class SecondCategoryAdapter extends BaseQuickAdapter<OrderCategoryBean.Fo
}
}
public static final int UPDATE_STATE = 101;
@Override
public void onBindViewHolder(@NotNull BaseViewHolder holder, int position, @NotNull List<Object> payloads) {
//list为空时,必须调用两个参数的onBindViewHolder(@NonNull LabelHolder holder, int position)
if (payloads.isEmpty()) {
onBindViewHolder(holder, position);
} else {
notifyCheckState(position, holder.getView(R.id.tv_second_category_title), holder.getView(R.id.card_purchase_category));
}
}
public SecondCategoryAdapter setCheckedBg(int checkedBg) {
this.checkedBg = checkedBg;
return this;
......@@ -69,14 +85,14 @@ public class SecondCategoryAdapter extends BaseQuickAdapter<OrderCategoryBean.Fo
return this;
}
public SecondCategoryAdapter setSelectIndex(int selectIndex) {
public SecondCategoryAdapter setSelectedIndex(int selectIndex) {
int lastIndex = this.selectIndex;
this.selectIndex = selectIndex;
if (lastIndex >= 0 && lastIndex < getItemCount()) {
notifyItemChanged(lastIndex);
notifyItemChanged(lastIndex, UPDATE_STATE);
}
if (this.selectIndex >= 0 && this.selectIndex < getItemCount()) {
notifyItemChanged(this.selectIndex);
notifyItemChanged(this.selectIndex, UPDATE_STATE);
}
return this;
}
......
......@@ -20,19 +20,19 @@ import java.util.List;
* Time: 16:36
* Use:庫存查詢的訂單列表
*/
public class WarehousingQueryAdapter extends BaseQuickAdapter<WareHouseListBean.WareHousingDataBean.PurchaseWarehousingOrderDetailsVOSBean, BaseViewHolder> {
public class WarehousingQueryAdapter extends BaseQuickAdapter<WareHouseListBean.WareHousingDataBean.PurchaseWarehousingOrderDetailsVO, BaseViewHolder> {
private Context context;
private int[] colors = new int[]{R.color.color_f9, R.color.white};
public WarehousingQueryAdapter(Context context, List<WareHouseListBean.WareHousingDataBean.PurchaseWarehousingOrderDetailsVOSBean> purchaseWarehousingOrderDetailsVosBeans) {
public WarehousingQueryAdapter(Context context, List<WareHouseListBean.WareHousingDataBean.PurchaseWarehousingOrderDetailsVO> purchaseWarehousingOrderDetailsVosBeans) {
super(R.layout.item_warehousing_query, purchaseWarehousingOrderDetailsVosBeans);
addChildClickViewIds(R.id.tv_warehouse_item_inventory_quantity);
this.context = context;
}
@Override
protected void convert(@NotNull BaseViewHolder viewHolder, WareHouseListBean.WareHousingDataBean.PurchaseWarehousingOrderDetailsVOSBean item) {
protected void convert(@NotNull BaseViewHolder viewHolder, WareHouseListBean.WareHousingDataBean.PurchaseWarehousingOrderDetailsVO item) {
viewHolder.setText(R.id.tv_warehouse_item_ingredients_name, item.getName());
viewHolder.setText(R.id.tv_warehouse_item_ingredients_species, item.getFoodCategoryName());
viewHolder.setText(R.id.tv_warehouse_item_unit, item.getUnitName());
......
......@@ -113,8 +113,8 @@ public class FunctionListFragment extends BaseSupplyChainFragment<FunctionListPr
start(SupplierListFragment.newInstance(false, null));
break;
case "食材":
start(FoodIngredientsFragment.newInstance(FOOD_INGREDIENTS));
// start(BuyIngredientsFragment.newInstance());
// start(FoodIngredientsFragment.newInstance(FOOD_INGREDIENTS));
start(BuyIngredientsFragment.newInstance());
break;
case "種類":
start(CategoryFragment.newInstance());
......
......@@ -18,9 +18,11 @@ import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
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.CollectionUtils;
import com.gingersoft.gsa.cloud.ui.bean.view.CategoryBean;
import com.gingersoft.supply_chain.R;
import com.gingersoft.supply_chain.R2;
......@@ -33,6 +35,7 @@ import com.gingersoft.supply_chain.mvp.ui.adapter.BuyIngredientsAdapter;
import com.gingersoft.supply_chain.mvp.ui.adapter.FirstLevelCategoryAdapter;
import com.gingersoft.supply_chain.mvp.ui.adapter.SecondCategoryAdapter;
import com.gingersoft.supply_chain.mvp.ui.fragment.BaseSupplyChainFragment;
import com.gingersoft.supply_chain.mvp.ui.widget.CenterLayoutManager;
import com.gingersoft.supply_chain.mvp.ui.widget.ShowSecondCategoryPopup;
import com.gingersoft.supply_chain.mvp.utils.ViewUtils;
import com.jess.arms.di.component.AppComponent;
......@@ -46,7 +49,9 @@ import com.qmuiteam.qmui.alpha.QMUIAlphaImageButton;
import com.qmuiteam.qmui.alpha.QMUIAlphaTextView;
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 com.scwang.smartrefresh.layout.SmartRefreshLayout;
import org.jetbrains.annotations.NotNull;
......@@ -76,8 +81,6 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien
RecyclerView rvFirstCategory;
private FirstLevelCategoryAdapter firstLevelCategoryAdapter;
@BindView(R2.id.layout_right_content)
LinearLayout layoutRightContent;
@BindView(R2.id.layout_ingredients_left)
LinearLayout layoutIngredientsLeft;
@BindView(R2.id.rv_food_ingredients_second_category)
......@@ -112,6 +115,8 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien
@BindView(R2.id.tv_unfold_category)
TextView tvUnfoldCategory;
TextView tvShoppingCart;
@BindView(R2.id.refreshLayout)
SmartRefreshLayout refreshLayout;
/**
* 0單列
* 1雙列
......@@ -143,10 +148,36 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien
@Override
public void initData(@Nullable Bundle savedInstanceState) {
initTopBar();
loadService = LoadSir.getDefault().register(layoutRightContent, (Callback.OnReloadListener) v -> {
});
// loadService = LoadSir.getDefault().register(layoutRightContent, (Callback.OnReloadListener) v -> {
// });
fullRegister = LoadSir.getDefault().register(layoutContent, (Callback.OnReloadListener) v -> {
});
// refreshLayout.setEnableOverScrollBounce(false);
// refreshLayout.setEnableOverScrollDrag(false);
// refreshLayout.setEnablePureScrollMode(true);
// refreshLayout.resetNoMoreData();
refreshLayout.setEnableOverScrollBounce(false)
.setFooterTriggerRate(0.1f);
// refreshLayout.setOnRefreshListener(refreshLayout -> {
// //在這裡不是刷新,而是獲取上一個分類的數據
// int i = firstLevelCategoryAdapter.getSelectedIndex() - 1;
// if (i >= 0) {
// firstLevelCategoryAdapter.getOnItemClickListener().onItemClick(firstLevelCategoryAdapter, null, i);
// } else {
// refreshLayout.finishRefreshWithNoMoreData();
// }
// });
// refreshLayout.setOnLoadMoreListener(refreshLayout -> {
// //加載下一個分類
// int itemCount = firstLevelCategoryAdapter.getItemCount();
// int i = firstLevelCategoryAdapter.getSelectedIndex() + 1;
// if (i < itemCount) {
// firstLevelCategoryAdapter.getOnItemClickListener().onItemClick(firstLevelCategoryAdapter, null, i);
// } else {
// refreshLayout.finishLoadMoreWithNoMoreData();
// }
// });
//獲取一級分類
mPresenter.getCategoryTrees();
}
......@@ -197,12 +228,141 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien
private void switchShowSingerOrDouble() {
//切換單雙列
isSinger = !isSinger;
sectionFood.setLayoutManager(isSinger ? new LinearLayoutManager(requireContext()) : getDoubleRowManager());
adapter.setShowDoubleRow(isSinger);
setLayoutManager();
adapter.setShowSingerRow(isSinger);
btnSwitchRow.setImageResource(isSinger ? R.drawable.ic_single_row : R.drawable.ic_double_row);
sectionFood.setAdapter(adapter);
}
private int lastIndex = 0;
/**
* 0為滑動到頂部
* 1為滑動到底部
* 2為用戶點擊加載
*/
private int isTailOrHead = 0;
private boolean isNextCategory = false;
private void setLayoutManager() {
LinearLayoutManager linearLayoutManager = isSinger ? new LinearLayoutManager(requireContext()) : getDoubleRowManager();
sectionFood.setLayoutManager(linearLayoutManager);
sectionFood.getRecyclerView().clearOnScrollListeners();
sectionFood.getRecyclerView().addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
int firstVisibleItemPosition = linearLayoutManager.findFirstVisibleItemPosition();
int lastVisibleItemPosition = linearLayoutManager.findLastVisibleItemPosition();
//手指往上滑動,獲取下一個分類數據
//記錄當前滑動到哪個header,如果和上次不一致,頂部的分類就切換選中
if (!mPresenter.isLoadFood()) {
if (lastVisibleItemPosition == adapter.getItemCount() - 1) {
//最後一個,獲取下一個一級分類的數據
//當前一級分類不是最後一個
if (firstLevelCategoryAdapter.getSelectedIndex() != firstLevelCategoryAdapter.getItemCount() - 1) {
isTailOrHead = 1;
mPresenter.setLoadFood(true);
mPresenter.getFood(firstLevelCategoryAdapter.getItem(firstLevelCategoryAdapter.getSelectedIndex() + 1).getId());
}
} else if (firstVisibleItemPosition == 0) {
//第一個,獲取上一個一級分類的數據
//當前一級分類不是第一個
if (firstLevelCategoryAdapter.getSelectedIndex() != 0) {
isTailOrHead = 0;
mPresenter.setLoadFood(true);
mPresenter.getFood(firstLevelCategoryAdapter.getItem(firstLevelCategoryAdapter.getSelectedIndex() - 1).getId());
}
}
}
}
}
@Override
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
int firstVisibleItemPosition = linearLayoutManager.findFirstVisibleItemPosition();
// int lastVisibleItemPosition = linearLayoutManager.findLastVisibleItemPosition();
int sectionIndex = adapter.getSectionIndex(firstVisibleItemPosition);
// //手指往上滑動,獲取下一個分類數據
// //記錄當前滑動到哪個header,如果和上次不一致,頂部的分類就切換選中
// if (!mPresenter.isLoadFood()) {
// if (lastVisibleItemPosition == adapter.getItemCount() - 1) {
// //最後一個,獲取下一個一級分類的數據
// //當前一級分類不是最後一個
// if (firstLevelCategoryAdapter.getSelectedIndex() != firstLevelCategoryAdapter.getItemCount() - 1) {
// isTailOrHead = 1;
// mPresenter.setLoadFood(true);
// mPresenter.getFood(firstLevelCategoryAdapter.getItem(firstLevelCategoryAdapter.getSelectedIndex() + 1).getId());
// }
// } else if (firstVisibleItemPosition == 0) {
// //第一個,獲取上一個一級分類的數據
// //當前一級分類不是第一個
// if (firstLevelCategoryAdapter.getSelectedIndex() != 0) {
// isTailOrHead = 0;
// mPresenter.setLoadFood(true);
// mPresenter.getFood(firstLevelCategoryAdapter.getItem(firstLevelCategoryAdapter.getSelectedIndex() - 1).getId());
// }
// }
// }
if (sectionIndex != lastIndex) {
QMUISection<CategoryBean, PurchaseFoodBean> sectionDirectly = adapter.getSectionDirectly(sectionIndex);
if (sectionDirectly != null && sectionDirectly.getHeader() != null) {
Integer id = sectionDirectly.getHeader().getId();
List<OrderCategoryBean.FoodCategoryTrees> data = secondCategoryAdapter.getData();
for (int i = lastIndex; i < data.size(); i = dy > 0 ? i + 1 : i - 1) {
if (i < 0) {
break;
}
if (data.get(i).getId() == id) {
secondCategoryAdapter.setSelectedIndex(i);
CenterLayoutManager layoutManager = (CenterLayoutManager) rvSecondCategory.getLayoutManager();
layoutManager.smoothScrollToPosition(rvSecondCategory, new RecyclerView.State(), i);
break;
}
}
lastIndex = sectionIndex;
}
}
}
});
}
private void switchCategory(BaseQuickAdapter<OrderCategoryBean.FoodCategoryTrees, ? extends RecyclerView.ViewHolder> adapter, RecyclerView recyclerView, Integer id) {
List<OrderCategoryBean.FoodCategoryTrees> data = adapter.getData();
for (int i = 0; i < data.size(); i++) {
if (data.get(i).getId() == id) {
if (adapter instanceof SecondCategoryAdapter) {
((SecondCategoryAdapter) adapter).setSelectedIndex(i);
} else if (adapter instanceof FirstLevelCategoryAdapter) {
((FirstLevelCategoryAdapter) adapter).setSelectedIndex(i);
}
CenterLayoutManager layoutManager = (CenterLayoutManager) recyclerView.getLayoutManager();
layoutManager.smoothScrollToPosition(recyclerView, new RecyclerView.State(), i);
if (i == data.size() - 1) {
if (adapter instanceof FirstLevelCategoryAdapter) {
} else {
}
//現在是最後一個二級分類,這時候去獲取下一個一級分類的內容
if (!isNextCategory) {
isNextCategory = true;
} else {
//是一級分類最後一個
refreshLayout.setNoMoreData(true);
}
} else {
isNextCategory = false;
}
return;
}
}
}
/**
* 切換顯示分類或供應商
*/
......@@ -221,7 +381,7 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien
.atView(layoutCategory)
.hasShadowBg(false)
.popupPosition(PopupPosition.Bottom)
.asCustom(new ShowSecondCategoryPopup(requireContext(), secondCategoryAdapter.getSelectIndex(), layoutCategory.getWidth(), secondCategoryAdapter.getData(), (adapter, view, position) -> {
.asCustom(new ShowSecondCategoryPopup(requireContext(), secondCategoryAdapter.getSelectIndex(), layoutCategory.getMeasuredWidth(), secondCategoryAdapter.getData(), (adapter, view, position) -> {
//二級分類滾動顯示,當前彈窗顯示三級分類,顯示三級分類在popup內部處理
secondCategoryAdapter.getOnItemClickListener().onItemClick(secondCategoryAdapter, view, position);
}))
......@@ -239,7 +399,6 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien
public void loadCategory(List<OrderCategoryBean.FoodCategoryTrees> foodCategoryTrees) {
if (foodCategoryTrees.size() > 0) {
fullRegister.showSuccess();
loadService.showSuccess();
if (firstLevelCategoryAdapter == null) {
firstLevelCategoryAdapter = new FirstLevelCategoryAdapter(foodCategoryTrees, requireContext());
rvFirstCategory.setAdapter(firstLevelCategoryAdapter);
......@@ -249,7 +408,7 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien
ViewUtils.moveToCenterByVertical(rvFirstCategory, position);
loadSecondCategory(firstLevelCategoryAdapter.getData().get(position).getFoodCategoryTrees());
//獲取當前分類所有食材
mPresenter.getFoodByCategoryId(firstLevelCategoryAdapter.getItem(position).getId());
mPresenter.getFood(firstLevelCategoryAdapter.getItem(position).getId());
});
//默認選中第0個分類
firstLevelCategoryAdapter.getOnItemClickListener().onItemClick(firstLevelCategoryAdapter, null, 0);
......@@ -270,7 +429,7 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien
@Override
public void loadFail() {
loadService.showCallback(EmptyCallback.class);
// loadService.showCallback(EmptyCallback.class);
}
/**
......@@ -279,37 +438,77 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien
* @param foodCategoryTrees
*/
private void loadSecondCategory(List<OrderCategoryBean.FoodCategoryTrees> foodCategoryTrees) {
if (secondCategoryAdapter == null) {
secondCategoryAdapter = new SecondCategoryAdapter(requireContext(), foodCategoryTrees);
rvSecondCategory.setLayoutManager(new LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false));
rvSecondCategory.setLayoutManager(new CenterLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false));
rvSecondCategory.setAdapter(secondCategoryAdapter);
OnItemClickListener onItemClickListener = (adapter, view, position) -> {
secondCategoryAdapter.setSelectIndex(position);
secondCategoryAdapter.setSelectedIndex(position);
ViewUtils.moveToCenterByHorizontal(rvSecondCategory, position);
//加載當前分類下的食品
};
secondCategoryAdapter.setOnItemClickListener(onItemClickListener);
} else {
secondCategoryAdapter.setNewInstance(foodCategoryTrees);
}
//默認選中第0個
if (foodCategoryTrees != null && foodCategoryTrees.size() > 0) {
onItemClickListener.onItemClick(secondCategoryAdapter, rvSecondCategory, 0);
secondCategoryAdapter.getOnItemClickListener().onItemClick(secondCategoryAdapter, rvSecondCategory, 0);
}
}
/**
* 加載食品,找到這些食品最近的上一個分類,將數據添加到這個分類下面,如果沒有,就添加到最頂部
*
* @param categoryId 當前分類id
* @param food 食品
*/
@Override
public void loadFood(List<QMUISection<CategoryBean, PurchaseFoodBean>> food) {
public void loadFood(int categoryId, List<QMUISection<CategoryBean, PurchaseFoodBean>> food) {
refreshLayout.finishRefresh();
refreshLayout.finishLoadMore();
food.addAll(food);
food.addAll(food);
if (adapter == null) {
adapter = new BuyIngredientsAdapter(requireContext(), food);
adapter.setCallback(new QMUIStickySectionAdapter.Callback<CategoryBean, PurchaseFoodBean>() {
@Override
public void loadMore(QMUISection<CategoryBean, PurchaseFoodBean> section, boolean loadMoreBefore) {
}
@Override
public void onItemClick(QMUIStickySectionAdapter.ViewHolder holder, int position) {
}
@Override
public boolean onItemLongClick(QMUIStickySectionAdapter.ViewHolder holder, int position) {
return false;
}
});
sectionFood.setAdapter(adapter);
setLayoutManager();
// mPresenter.setLoadFood(false);
} else {
// if (isTailOrHead == 2) {
adapter.setData(food);
}
if (isSinger) {
sectionFood.setLayoutManager(new LinearLayoutManager(requireContext()));
} else {
sectionFood.setLayoutManager(getDoubleRowManager());
// } else {
// List<QMUISection<CategoryBean, PurchaseFoodBean>> currentData = CollectionUtils.deepCopy(adapter.getCurrentData());
// if (isTailOrHead == 0) {
// currentData.addAll(0, food);
// } else {
// currentData.addAll(food);
// }
// adapter.setData(currentData);
// }
// mPresenter.setLoadFood(false);
}
}
@NotNull
private GridLayoutManager getDoubleRowManager() {
val gridLayoutManager = new GridLayoutManager(requireContext(), 2);
......
......@@ -79,8 +79,7 @@ public class PurchaseListFragment extends BaseSupplyChainFragment<PurchaseListPr
private PurchaseOrderAdapter purchaseOrderAdapter;
public static PurchaseListFragment newInstance() {
PurchaseListFragment fragment = new PurchaseListFragment();
return fragment;
return new PurchaseListFragment();
}
/**
......@@ -187,9 +186,12 @@ public class PurchaseListFragment extends BaseSupplyChainFragment<PurchaseListPr
.setOnSelectListener((popupPosition, text) -> {
if (popupPosition == 0) {
//刪除
AppDialog.getInstance().showWaringDialog(mContext, "是否刪除訂單", (view1, dialog) -> {
mPresenter.deleteOrder(position, purchaseOrderAdapter.getData().get(position).getId());
});
if (purchaseOrderAdapter.getItem(position).getStatus() == PurchaseOrderDetailsBean.WAIT_RECEIVED) {
//只有待收貨可以刪除
AppDialog.getInstance().showWaringDialog(mContext, "是否刪除訂單", (view1, dialog) -> mPresenter.deleteOrder(position, purchaseOrderAdapter.getData().get(position).getId()));
} else {
showMessage("該訂單已有入庫食品,不可刪除!");
}
} else if (popupPosition == 1) {
//發送採購單
sendPurchase(position);
......@@ -252,7 +254,7 @@ public class PurchaseListFragment extends BaseSupplyChainFragment<PurchaseListPr
screenView.setVisibility(screenView.getVisibility() == View.VISIBLE ? View.GONE : View.VISIBLE);
} else if (viewId == R.id.iv_purchase_list_search) {
getOrderList();
} else if(viewId == R.id.btn_save){
} else if (viewId == R.id.btn_save) {
//跳轉到下單頁面
startForResult(FoodIngredientsFragment.newInstance(ADD_ORDER), REQUEST_ORDER_DETAILS_CODE);
}
......@@ -293,13 +295,14 @@ public class PurchaseListFragment extends BaseSupplyChainFragment<PurchaseListPr
@Override
public void deleteOrder(int position) {
purchaseOrderAdapter.removeAt(position);
showMessage("訂單已刪除,請打電話聯繫供應商訂單刪除!");
}
@Override
public void onFragmentResult(int requestCode, int resultCode, Bundle data) {
super.onFragmentResult(requestCode, resultCode, data);
if (requestCode == REQUEST_ORDER_DETAILS_CODE) {
// //用戶對訂單進行了操作,需要對列表進行刷新
//用戶對訂單進行了操作,需要對列表進行刷新
getOrderList();
}
}
......
......@@ -38,6 +38,8 @@ import butterknife.OnClick;
/**
* 庫存查詢列表
*
* @author admin
*/
public class WareHouseListFragment extends BaseSupplyChainFragment<WareHouseListPresenter> implements WareHouseListContract.View {
......@@ -59,14 +61,13 @@ public class WareHouseListFragment extends BaseSupplyChainFragment<WareHouseList
RecyclerView rvWarehouseList;
@BindView(R2.id.sl_warehousing_list)
SmartRefreshLayout smartRefreshLayout;
// @BindView(R2.id.hs_warehousing_list)
// HorizontalScrollView hsWarehousingList;
@BindView(R2.id.tv_warehouse_item_unit_price)
TextView tvUnitPrice;
@BindView(R2.id.tv_warehouse_item_inventory_quantity)
TextView tvWarehousingQuantity;
@BindView(R2.id.tv_warehouse_item_total_amount)
TextView tvTotalAmount;
private int SORT_TYPE = 0;
/**
* 升序或降序
......@@ -80,8 +81,7 @@ public class WareHouseListFragment extends BaseSupplyChainFragment<WareHouseList
private WarehousingQueryAdapter warehousingQueryAdapter;
public static WareHouseListFragment newInstance() {
WareHouseListFragment fragment = new WareHouseListFragment();
return fragment;
return new WareHouseListFragment();
}
@Override
......@@ -151,9 +151,9 @@ public class WareHouseListFragment extends BaseSupplyChainFragment<WareHouseList
@Override
public void loadWarehousingInfo(WareHouseListBean.WareHousingDataBean data) {
WareHouseListBean.WareHousingDataBean.TotalBean total = data.getTotal();
tvOverdueFoodNum.setText(total.getOverdue() + "");
tvExpiringSoonFoodNum.setText(total.getAboutExpire() + "");
tvLowInventoryFoodNum.setText(total.getOutStock() + "");
tvOverdueFoodNum.setText(String.valueOf(total.getOverdue()));
tvExpiringSoonFoodNum.setText(String.valueOf(total.getAboutExpire()));
tvLowInventoryFoodNum.setText(String.valueOf(total.getOutStock()));
tvIngredientsCostInventory.setText(String.format(getString(R.string.amount_string), total.getCost()));
loadListInfo(data.getPurchaseWarehousingOrderDetailsVOS());
}
......@@ -171,7 +171,7 @@ public class WareHouseListFragment extends BaseSupplyChainFragment<WareHouseList
}
@Override
public void loadListInfo(List<WareHouseListBean.WareHousingDataBean.PurchaseWarehousingOrderDetailsVOSBean> purchaseWarehousingOrderDetailsVos) {
public void loadListInfo(List<WareHouseListBean.WareHousingDataBean.PurchaseWarehousingOrderDetailsVO> purchaseWarehousingOrderDetailsVos) {
if (purchaseWarehousingOrderDetailsVos == null || purchaseWarehousingOrderDetailsVos.size() <= 0) {
loadService.showCallback(EmptyCallback.class);
return;
......
package com.gingersoft.supply_chain.mvp.ui.fragment.warehouse;
import android.animation.LayoutTransition;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
......@@ -12,19 +14,28 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.print.PrintHelper;
import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager2.widget.ViewPager2;
import com.gingersoft.gsa.cloud.common.core.restaurant.RestaurantInfoManager;
import com.gingersoft.gsa.cloud.common.core.user.UserContext;
import com.gingersoft.gsa.cloud.common.loadsir.EmptyCallback;
import com.gingersoft.gsa.cloud.common.utils.MoneyUtil;
import com.gingersoft.gsa.cloud.common.utils.glide.GlideUtils;
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.view.LayoutToBitmapUtils;
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.OutboundOrderBean;
import com.gingersoft.supply_chain.mvp.bean.WareHouseListBean;
import com.gingersoft.supply_chain.mvp.bean.WarehouseDetailsBean;
import com.gingersoft.supply_chain.mvp.contract.WarehouseDetailsContract;
import com.gingersoft.supply_chain.mvp.presenter.WarehouseDetailsPresenter;
import com.gingersoft.supply_chain.mvp.ui.adapter.OutboundOrderAdapter;
import com.gingersoft.supply_chain.mvp.ui.adapter.PurchasePageAdapter;
import com.gingersoft.supply_chain.mvp.ui.adapter.WareHousingDetailsAdapter;
import com.gingersoft.supply_chain.mvp.ui.fragment.BaseSupplyChainFragment;
......@@ -44,6 +55,8 @@ import butterknife.OnClick;
/**
* Description: 入庫詳情
*
* @author admin
*/
public class WarehouseDetailsFragment extends BaseSupplyChainFragment<WarehouseDetailsPresenter> implements WarehouseDetailsContract.View, View.OnClickListener {
......@@ -74,25 +87,19 @@ public class WarehouseDetailsFragment extends BaseSupplyChainFragment<WarehouseD
@BindView(R2.id.layout_warehousing_title)
LinearLayout layoutTitle;
//庫存消耗view
/**
* 庫存消耗view
*/
private InventoryConsumptionView inventoryConsumptionView;
//掃碼sn碼view
/**
* 掃碼sn碼view
*/
private ScanSnView scanSnView;
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 String FOOD_INFO_KEY = "purchaseWarehousingBean";
private WareHouseListBean.WareHousingDataBean.PurchaseWarehousingOrderDetailsVO purchaseWarehousingOrderDetailsVO;
/**
* 入庫
*/
......@@ -102,17 +109,10 @@ public class WarehouseDetailsFragment extends BaseSupplyChainFragment<WarehouseD
*/
public final static int OUT_STOCK_TYPE = 1;
public static WarehouseDetailsFragment newInstance(WareHouseListBean.WareHousingDataBean.PurchaseWarehousingOrderDetailsVOSBean purchaseWarehousingOrderDetailsVosBean) {
public static WarehouseDetailsFragment newInstance(WareHouseListBean.WareHousingDataBean.PurchaseWarehousingOrderDetailsVO 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.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());
bundle.putSerializable(FOOD_INFO_KEY, purchaseWarehousingOrderDetailsVosBean);
fragment.setArguments(bundle);
return fragment;
}
......@@ -139,31 +139,31 @@ public class WarehouseDetailsFragment extends BaseSupplyChainFragment<WarehouseD
loadService = LoadSir.getDefault().register(smartRefreshLayout);
// smartRefreshLayout.setEnableHeaderTranslationContent(false).
// setEnableFooterTranslationContent(false);
LayoutTransition layoutTransition = new LayoutTransition();
layoutTransition.enableTransitionType(LayoutTransition.CHANGING);
layoutRoot.setLayoutTransition(layoutTransition);
smartRefreshLayout.setOnRefreshListener(refreshLayout -> getPageInfo());
if (arguments != null) {
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);
purchaseWarehousingOrderDetailsVO = (WareHouseListBean.WareHousingDataBean.PurchaseWarehousingOrderDetailsVO) arguments.getSerializable(FOOD_INFO_KEY);
if (purchaseWarehousingOrderDetailsVO == null) {
killMyself();
showMessage("食材信息獲取失敗,請稍候重試");
}
initTopBar(supplyTopBar, purchaseWarehousingOrderDetailsVO.getName());
tvUnit.setText(purchaseWarehousingOrderDetailsVO.getUnitName());
String foodImageUrl = arguments.getString(purchaseWarehousingOrderDetailsVO.getImages());
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);
tvWarehouseInventoryNumber.setText(String.valueOf(purchaseWarehousingOrderDetailsVO.getFoodNum()));
tvWarehouseUnitPrice.setText(String.format(getString(R.string.str_latest_unit_price_colon), purchaseWarehousingOrderDetailsVO.getFoodPrice()));
tvWarehouseTotalAmount.setText(String.format(getString(R.string.str_total_amount_colon), purchaseWarehousingOrderDetailsVO.getFoodAmount()));
tvWarehouseSpecifications.setText(purchaseWarehousingOrderDetailsVO.getUnitName());
getWarehouseDetails();
if (wareHousingNum > 0) {
if (purchaseWarehousingOrderDetailsVO.getFoodNum() > 0) {
//獲取庫存消耗的原因列表
mPresenter.getWarehouseInventoryReason();
}
......@@ -175,14 +175,14 @@ public class WarehouseDetailsFragment extends BaseSupplyChainFragment<WarehouseD
* 獲取入庫詳情
*/
private void getWarehouseDetails() {
mPresenter.getWarehousingOrderDetails(foodNo);
mPresenter.getWarehousingOrderDetails(purchaseWarehousingOrderDetailsVO.getFoodNo());
}
/**
* 獲取出庫詳情
*/
private void getOutStockDetails() {
mPresenter.getOutStockDetails(foodNo);
mPresenter.getOutStockDetails(purchaseWarehousingOrderDetailsVO.getFoodNo());
}
private void initViewPager() {
......@@ -255,44 +255,125 @@ public class WarehouseDetailsFragment extends BaseSupplyChainFragment<WarehouseD
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();
smartRefreshLayout.setVisibility(View.GONE);
layoutTitle.setVisibility(View.GONE);
loadService.getLoadLayout().setVisibility(View.GONE);
inventoryConsumptionView = new InventoryConsumptionView(requireContext(), consumeReasonBeans, wareHousingNum);
button.setOnClickListener(v -> showInventory(consumeReasonBeans));
}
/**
* 顯示庫存消耗
*
* @param consumeReasonBeans 庫存消耗原因
*/
private void showInventory(List<ConsumeReasonBean> consumeReasonBeans) {
if (smartRefreshLayout.getVisibility() == View.VISIBLE) {
//隱藏庫存消耗記錄列表
showList(View.GONE);
//移除掉
if (inventoryConsumptionView != null) {
layoutRoot.removeView(inventoryConsumptionView);
layoutRoot.removeView(scanSnView);
}
//初始化消耗view
inventoryConsumptionView = new InventoryConsumptionView(requireContext(), consumeReasonBeans, purchaseWarehousingOrderDetailsVO.getFoodNum());
layoutRoot.addView(inventoryConsumptionView);
//如果不是sn食材
if (!purchaseWarehousingOrderDetailsVO.isSnFood()) {
inventoryConsumptionView.setShowBtn();
inventoryConsumptionView.setOnConfirmClickListener((consumptionNum, reasonIndex, remarks) -> inventory(consumeReasonBeans))
.setOnCancelListener(() -> showList(View.VISIBLE));
return;
}
//初始化掃碼view
scanSnView = new ScanSnView(this, null, scanResult -> inventory(consumeReasonBeans)).setOnCancelListener(() -> {
//取消
showList(View.VISIBLE);
});
//設置LayoutParam
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
int dimensionPixelOffset = requireContext().getResources().getDimensionPixelOffset(R.dimen.dp_10);
layoutParams.leftMargin = dimensionPixelOffset;
layoutParams.rightMargin = dimensionPixelOffset;
layoutParams.bottomMargin = dimensionPixelOffset;
scanSnView.setBackground(ContextCompat.getDrawable(requireContext(), R.drawable.shape_white_eight_corners_bg));
layoutRoot.addView(scanSnView, layoutParams);
} else {
showList(View.VISIBLE);
}
}
scanSnView = new ScanSnView(this, null, scanResult -> {
smartRefreshLayout.setVisibility(View.VISIBLE);
layoutTitle.setVisibility(View.VISIBLE);
loadService.getLoadLayout().setVisibility(View.VISIBLE);
private void inventory(List<ConsumeReasonBean> consumeReasonBeans) {
//掃完碼,點擊確認
showList(View.VISIBLE);
//獲取用戶輸入的消耗數量
int consumptionNum = inventoryConsumptionView.getConsumptionNum();
if (consumptionNum == -1) {
return;
}
mPresenter.consumeWareHousing(foodNo, consumptionNum, consumeReasonBeans.get(inventoryConsumptionView.getReasonIndex()).getId(), inventoryConsumptionView.getRemark());
//調用消耗接口
mPresenter.consumeWareHousing(purchaseWarehousingOrderDetailsVO.getFoodNo(), consumptionNum, consumeReasonBeans.get(inventoryConsumptionView.getReasonIndex()).getId(), inventoryConsumptionView.getRemark());
setFragmentResult(RESULT_OK, null);
}).setOnCancelListener(() -> {
//取消
smartRefreshLayout.setVisibility(View.VISIBLE);
layoutTitle.setVisibility(View.VISIBLE);
loadService.getLoadLayout().setVisibility(View.VISIBLE);
if (inventoryConsumptionView.getIsPrint()) {
//打印
onPrintPdf(consumeReasonBeans.get(inventoryConsumptionView.getReasonIndex()).getDescription(), inventoryConsumptionView.getRemark(), consumptionNum);
}
}
private void onPrintPdf(String consumptionReason, String remarks, int foodNum) {
PrintHelper printHelper = new PrintHelper(requireContext());
boolean b = PrintHelper.systemSupportsPrint();
if (b) {
//設置縮放模式
printHelper.setScaleMode(PrintHelper.SCALE_MODE_FIT);
//設置打印方向
//橫向 PrintHelper.ORIENTATION_LANDSCAPE
//縱向 PrintHelper.ORIENTATION_PORTRAIT
printHelper.setOrientation(PrintHelper.ORIENTATION_LANDSCAPE);
//設置打印顏色
printHelper.setColorMode(PrintHelper.COLOR_MODE_MONOCHROME);
printHelper.printBitmap(String.format(getString(R.string.str_restaurant_outbound_order), purchaseWarehousingOrderDetailsVO.getName()), generatePrintBitmap(consumptionReason, remarks, foodNum), () -> {
//打印完成回調
});
layoutRoot.addView(scanSnView);
});
} else {
//不支持打印
showMessage(getString(R.string.str_device_not_print));
}
}
private Bitmap generatePrintBitmap(String consumptionReason, String remarks, int foodNum) {
View view = LayoutInflater.from(requireContext()).inflate(R.layout.layout_print_consume, null);
TextView restaurantName = view.findViewById(R.id.tv_print_consume_restaurant_name);
TextView tvDate = view.findViewById(R.id.tv_print_consume_date);
TextView tvFoodNo = view.findViewById(R.id.tv_print_consume_no);
RecyclerView rvInfo = view.findViewById(R.id.rv_print_consume_info);
TextView tvUserName = view.findViewById(R.id.tv_print_consume_user_name);
restaurantName.setText(String.format(getString(R.string.str_restaurant_outbound_order), RestaurantInfoManager.newInstance().getRestaurantName()));
tvDate.setText(TimeUtils.getCurrentDate(TimeUtils.DEFAULT_DATE_FORMAT_YMDHM));
tvFoodNo.setText(String.format(getString(R.string.str_no), purchaseWarehousingOrderDetailsVO.getFoodNo()));
tvUserName.setText(String.format(getString(R.string.str_prepared), UserContext.newInstance().getMemberName()));
List<OutboundOrderBean> outboundOrderBeans = new ArrayList<>();
outboundOrderBeans.add(new OutboundOrderBean("品名", purchaseWarehousingOrderDetailsVO.getName()));
outboundOrderBeans.add(new OutboundOrderBean("單位", purchaseWarehousingOrderDetailsVO.getUnitName()));
outboundOrderBeans.add(new OutboundOrderBean("數量", String.valueOf(foodNum)));
outboundOrderBeans.add(new OutboundOrderBean("單價", String.valueOf(purchaseWarehousingOrderDetailsVO.getFoodPrice())));
outboundOrderBeans.add(new OutboundOrderBean("金額", String.valueOf(MoneyUtil.priceCalculation(purchaseWarehousingOrderDetailsVO.getFoodPrice(), foodNum))));
outboundOrderBeans.add(new OutboundOrderBean("消耗原因", consumptionReason));
outboundOrderBeans.add(new OutboundOrderBean("備註", remarks));
OutboundOrderAdapter outboundOrderAdapter = new OutboundOrderAdapter(outboundOrderBeans);
rvInfo.setAdapter(outboundOrderAdapter);
return LayoutToBitmapUtils.getBitmapByView(requireContext(), view);
}
/**
* 顯示消耗列表
*
* @param visible 是否顯示
*/
private void showList(int visible) {
smartRefreshLayout.setVisibility(visible);
layoutTitle.setVisibility(visible);
loadService.getLoadLayout().setVisibility(visible);
}
@Override
......
......@@ -13,7 +13,6 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;
import com.gingersoft.gsa.cloud.common.utils.glide.GlideUtils;
......@@ -28,11 +27,11 @@ import com.gingersoft.supply_chain.mvp.presenter.WarehousingInventoryPresenter;
import com.gingersoft.supply_chain.mvp.ui.adapter.InventoryRecordAdapter;
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 com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnLoadMoreListener;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;
import java.util.List;
......@@ -57,22 +56,16 @@ public class WarehousingInventoryFragment extends BaseSupplyChainFragment<Wareho
@BindView(R2.id.rv_warehouse_inventory_record)
RecyclerView rvRecord;
private InventoryRecordAdapter adapter;
/**
* 食品總庫存
*/
private int foodNum;
private String foodNo;
@BindView(R2.id.smart_inventory_record)
SmartRefreshLayout smartRefreshLayout;
private int pageIndex;
public static WarehousingInventoryFragment newInstance(WareHouseListBean.WareHousingDataBean.PurchaseWarehousingOrderDetailsVOSBean purchaseWarehousingOrderDetailsVosBean) {
private WareHouseListBean.WareHousingDataBean.PurchaseWarehousingOrderDetailsVO purchaseWarehousingOrderDetailsVo;
public static WarehousingInventoryFragment newInstance(WareHouseListBean.WareHousingDataBean.PurchaseWarehousingOrderDetailsVO purchaseWarehousingOrderDetailsVo) {
WarehousingInventoryFragment fragment = new WarehousingInventoryFragment();
Bundle bundle = new Bundle();
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());
bundle.putSerializable(WarehouseDetailsFragment.FOOD_INFO_KEY, purchaseWarehousingOrderDetailsVo);
fragment.setArguments(bundle);
return fragment;
}
......@@ -96,34 +89,38 @@ public class WarehousingInventoryFragment extends BaseSupplyChainFragment<Wareho
public void initData(@Nullable Bundle savedInstanceState) {
Bundle arguments = getArguments();
if (arguments != null) {
int foodId = arguments.getInt(WarehouseDetailsFragment.FOOD_ID_KEY);
//食品編號
foodNo = arguments.getString(WarehouseDetailsFragment.FOOD_NO_KEY);
//食品庫存總數
foodNum = arguments.getInt(WarehouseDetailsFragment.FOOD_NUM_KEY);
purchaseWarehousingOrderDetailsVo = (WareHouseListBean.WareHousingDataBean.PurchaseWarehousingOrderDetailsVO) arguments.getSerializable(WarehouseDetailsFragment.FOOD_INFO_KEY);
//獲取庫存盤點記錄
getWarehousingRecord();
//加載食品圖片
loadFoodImage(arguments);
loadFoodImage();
//初始化標題
initTopBar(arguments);
initTopBar(purchaseWarehousingOrderDetailsVo.getName());
//初始化數量和編輯監聽
initEdit();
} else {
showMessage("獲取食材信息失敗,請稍候重試");
killMyself();
}
smartRefreshLayout.setOnRefreshListener(refreshLayout -> {
pageIndex = 0;
getWarehousingRecord();
});
smartRefreshLayout.setOnLoadMoreListener(refreshLayout -> {
pageIndex++;
getWarehousingRecord();
});
}
private void getWarehousingRecord() {
mPresenter.getWarehousingRecord(foodNo, pageIndex);
mPresenter.getWarehousingRecord(purchaseWarehousingOrderDetailsVo.getFoodNo(), pageIndex);
}
private void initEdit() {
//庫存數量
tvWarehouseTotal.setText(String.valueOf(foodNum));
tvWarehouseTotal.setText(String.valueOf(purchaseWarehousingOrderDetailsVo.getFoodNum()));
//庫存差異
tvWarehouseDifference.setText(String.valueOf(foodNum));
tvWarehouseDifference.setText(String.valueOf(purchaseWarehousingOrderDetailsVo.getFoodNum()));
edWarehouseLoss.setOnFocusChangeListener((v, hasFocus) -> {
//當輸入框獲得焦點時,數量為0,去掉0
if (hasFocus && edWarehouseLoss.getText().toString().equals("0")) {
......@@ -152,16 +149,15 @@ public class WarehousingInventoryFragment extends BaseSupplyChainFragment<Wareho
// edWarehouseLoss.setText(String.valueOf(foodNum));
// edWarehouseLoss.setSelection(edWarehouseLoss.getText().length());
// }
tvWarehouseDifference.setText(String.valueOf(Math.abs(foodNum - inventoryNum)));
tvWarehouseDifference.setText(String.valueOf(Math.abs(purchaseWarehousingOrderDetailsVo.getFoodNum() - inventoryNum)));
} else {
tvWarehouseDifference.setText(String.valueOf(foodNum));
tvWarehouseDifference.setText(String.valueOf(purchaseWarehousingOrderDetailsVo.getFoodNum()));
}
}
});
}
private void initTopBar(Bundle arguments) {
String foodName = arguments.getString(WarehouseDetailsFragment.FOOD_NAME_KEY);
private void initTopBar(String foodName) {
//初始化標題
initTopBar(supplyTopBar, foodName);
//添加保存按鈕
......@@ -170,10 +166,9 @@ public class WarehousingInventoryFragment extends BaseSupplyChainFragment<Wareho
btnSave.setOnClickListener(mOnClickListener);
}
private void loadFoodImage(Bundle arguments) {
String foodImageUrl = arguments.getString(WarehouseDetailsFragment.FOOD_IMAGE_KEY);
if (TextUtil.isNotEmptyOrNullOrUndefined(foodImageUrl)) {
GlideUtils.display(requireContext(), ivWarehouseImg, foodImageUrl);
private void loadFoodImage() {
if (TextUtil.isNotEmptyOrNullOrUndefined(purchaseWarehousingOrderDetailsVo.getImages())) {
GlideUtils.display(requireContext(), ivWarehouseImg, purchaseWarehousingOrderDetailsVo.getImages());
} else {
ivWarehouseImg.setImageResource(R.drawable.img_small_default);
}
......@@ -192,8 +187,8 @@ public class WarehousingInventoryFragment extends BaseSupplyChainFragment<Wareho
showMessage("請輸入盤點庫存數量");
edWarehouseLoss.requestFocus();
} else {
int remainingAmount = foodNum - inventoryNum;
mPresenter.consumeWareHousing(foodNo, remainingAmount);
int remainingAmount = purchaseWarehousingOrderDetailsVo.getFoodNum() - inventoryNum;
mPresenter.consumeWareHousing(purchaseWarehousingOrderDetailsVo.getFoodNo(), remainingAmount);
}
}
}
......@@ -206,6 +201,8 @@ public class WarehousingInventoryFragment extends BaseSupplyChainFragment<Wareho
@Override
public void loadRecord(List<InventoryRecordBean> inventoryRecordBeans) {
smartRefreshLayout.finishLoadMore();
smartRefreshLayout.finishRefresh();
//加載盤點記錄
if (adapter == null) {
adapter = new InventoryRecordAdapter(inventoryRecordBeans);
......
package com.gingersoft.supply_chain.mvp.ui.widget;
import android.content.Context;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.Log;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.LinearSmoothScroller;
import androidx.recyclerview.widget.RecyclerView;
/**
* @author 宇航.
* User: admin
* Date: 2021/3/23
* Time: 15:38
* Use:
*/
public class CenterLayoutManager extends LinearLayoutManager {
public CenterLayoutManager(Context context) {
super(context);
}
public CenterLayoutManager(Context context, int orientation, boolean reverseLayout) {
super(context, orientation, reverseLayout);
}
public CenterLayoutManager(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}
@Override
public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, int position) {
RecyclerView.SmoothScroller smoothScroller = new CenterSmoothScroller(recyclerView.getContext());
smoothScroller.setTargetPosition(position);
startSmoothScroll(smoothScroller);
}
private static class CenterSmoothScroller extends LinearSmoothScroller {
public CenterSmoothScroller(Context context) {
super(context);
}
/**
*
* @param viewStart view起點
* @param viewEnd view重點
* @param boxStart 整個recyclerview的起點
* @param boxEnd 整個recyclerview的終點
* @param snapPreference 未知
* @return 滑動到哪個位置
*/
@Override
public int calculateDtToFit(int viewStart, int viewEnd, int boxStart, int boxEnd, int snapPreference) {
return (boxStart + (boxEnd - boxStart) / 2) - (viewStart + (viewEnd - viewStart) / 2);
}
/**
* 滑動速度
*/
@Override
protected float calculateSpeedPerPixel(DisplayMetrics displayMetrics) {
return 100f / displayMetrics.densityDpi;
}
}
}
......@@ -52,21 +52,24 @@ public class InventoryConsumptionView extends FrameLayout {
QMUIAlphaTextView tvConfirm;
@BindView(R2.id.tv_cancel)
QMUIAlphaTextView tvCancel;
@BindView(R2.id.layout_inventory_btn)
LinearLayout layoutBtn;
private OnConfirmClickListener onConfirmClickListener;
private ScanSnView.OnCancelListener onCancelListener;
private ConsumptionReasonAdapter consumptionReasonAdapter;
public InventoryConsumptionView(@NonNull Context context, List<ConsumeReasonBean> consumeReasonBeans, int maxConsumption) {
super(context);
View rootView = LayoutInflater.from(context).inflate(R.layout.layout_inventory_consumption, null,false);
View rootView = LayoutInflater.from(context).inflate(R.layout.layout_inventory_consumption, null, false);
ButterKnife.bind(this, rootView);
addView(rootView);
this.maxConsumption = maxConsumption;
edRemarks.setFilters(new InputFilter[]{InputFilterUtils.getLengthFilter(getContext(), RemarkProvider.REMARK_TEXT_LENGTH), InputFilterUtils.getChAndEnAndNumAndPtInputFilter(getContext())});
consumptionReasonAdapter = new ConsumptionReasonAdapter(consumeReasonBeans);
consumptionReasonAdapter.setOnItemChildClickListener((adapter, view, position) -> consumptionReasonAdapter.setSelectIndex(position));
rvConsumptionReason.setLayoutManager(new GridLayoutManager(getContext(), 2));
rvConsumptionReason.setLayoutManager(new GridLayoutManager(getContext(), 3));
rvConsumptionReason.setAdapter(consumptionReasonAdapter);
tvCancel.setOnClickListener(v -> onCancelListener.onCancel());
tvConfirm.setOnClickListener(v -> {
if (onConfirmClickListener != null) {
String s = edInput.getText().toString();
......@@ -119,6 +122,16 @@ public class InventoryConsumptionView extends FrameLayout {
return this;
}
public InventoryConsumptionView setOnCancelListener(ScanSnView.OnCancelListener onCancelListener) {
this.onCancelListener = onCancelListener;
return this;
}
public InventoryConsumptionView setShowBtn() {
layoutBtn.setVisibility(VISIBLE);
return this;
}
public String getRemark() {
return edRemarks.getText().toString();
}
......@@ -132,6 +145,10 @@ public class InventoryConsumptionView extends FrameLayout {
return consumptionReasonAdapter.getSelectIndex();
}
public boolean getIsPrint() {
return switchMultiBooleanState.isChecked();
}
/**
* 獲取消耗數量
*
......
......@@ -85,7 +85,7 @@ public class ScanSnView extends FrameLayout {
}
private void init() {
View rootView = LayoutInflater.from(getContext()).inflate(R.layout.layout_scan_sn, null, false);
View rootView = LayoutInflater.from(getContext()).inflate(R.layout.layout_scan_sn, this, false);
ButterKnife.bind(this, rootView);
//初始化adapter
SnCodeAdapter adapter = new SnCodeAdapter(R.layout.item_sn_code, snCodes);
......
......@@ -57,7 +57,7 @@ public class ShowSecondCategoryPopup extends AttachPopupView {
flexboxLayoutManager.setFlexWrap(FlexWrap.WRAP);
recyclerView.setLayoutManager(flexboxLayoutManager);
SecondCategoryAdapter secondCategoryAdapter = new SecondCategoryAdapter(getContext(), foodCategoryTreesList);
secondCategoryAdapter.setSelectIndex(defaultSelect);
secondCategoryAdapter.setSelectedIndex(defaultSelect);
secondCategoryAdapter.setOnItemClickListener((adapter, view, position) -> {
if (!showThirdCategory) {
//三級分類就不回調
......
......@@ -35,8 +35,9 @@ public class TextPopup extends CenterPopupView {
protected void onCreate() {
super.onCreate();
TextView tvTitle = findViewById(R.id.tv_title);
tvTitle.setText(title);
TextView tvContent = findViewById(R.id.tv_content);
tvContent.setText(content);
tvContent.setText(content.replace("\\n", "\n"));
}
}
//package com.gingersoft.supply_chain.mvp.ui.widget;
//
//import android.content.Context;
//import android.content.res.ColorStateList;
//import android.content.res.TypedArray;
//import android.graphics.Canvas;
//import android.graphics.Paint;
//import android.graphics.Rect;
//import android.graphics.Region;
//import android.graphics.drawable.Drawable;
//import android.text.Layout;
//import android.text.StaticLayout;
//import android.text.TextPaint;
//import android.util.AttributeSet;
//import android.util.Log;
//import android.view.Gravity;
//
//import androidx.annotation.NonNull;
//import androidx.annotation.Nullable;
//import androidx.appcompat.text.AllCapsTransformationMethod;
//import androidx.appcompat.widget.DrawableUtils;
//import androidx.appcompat.widget.SwitchCompat;
//import androidx.appcompat.widget.TintTypedArray;
//import androidx.appcompat.widget.ViewUtils;
//import androidx.core.graphics.drawable.DrawableCompat;
//
//import com.gingersoft.supply_chain.R;
//
//import java.lang.reflect.Field;
//import java.lang.reflect.InvocationTargetException;
//import java.lang.reflect.Method;
//
///**
// * @author 宇航.
// * User: admin
// * Date: 2021/3/19
// * Time: 14:41
// * Use:
// */
//public class TextSwitchCompat extends SwitchCompat {
//
//
// public TextSwitchCompat(@NonNull Context context) {
// super(context);
// }
//
// public TextSwitchCompat(@NonNull Context context, @Nullable AttributeSet attrs) {
// super(context, attrs);
// }
//
// public TextSwitchCompat(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// }
//
// private int mThumbTextPadding;
// private int mSwitchMinWidth;
// private int mSwitchPadding;
//
// private Layout mOnLayout;
// private Layout mOffLayout;
// private int mSwitchWidth;
// private int mSwitchHeight;
//
// private int mThumbWidth;
//
// private int mSwitchLeft;
// private int mSwitchTop;
// private int mSwitchBottom;
// private int mSwitchRight;
//
//
// private final Rect padding = new Rect();
//
// @Override
// public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// super.onMeasure(widthMeasureSpec, heightMeasureSpec);
// if (getShowText()) {
// if (mOnLayout == null) {
// mOnLayout = makeLayout(getTextOn());
// }
//
// if (mOffLayout == null) {
// mOffLayout = makeLayout(getTextOff());
// }
// }
// //拿到按鈕
// Drawable mThumbDrawable = getThumbDrawable();
// mThumbDrawable.getPadding(padding);
//
// mThumbWidth = mThumbDrawable.getIntrinsicWidth() - padding.left - padding.right;
// int thumbHeight = mThumbDrawable.getIntrinsicHeight();
// //獲取開和關文字最寬的值
// int maxTextWidth = Math.max(mOnLayout.getWidth(), mOffLayout.getWidth())
// + getThumbTextPadding() * 2;
// //拿文字最寬值和按鈕最寬值比較,決定了按鈕的寬度
//// int mThumbWidth = Math.max(maxTextWidth, thumbWidth);
//
//
// //獲得按鈕的軌道
// Drawable mTrackDrawable = getTrackDrawable();
// mTrackDrawable.getPadding(padding);
// int trackHeight = mTrackDrawable.getIntrinsicHeight();
//
// int paddingLeft = padding.left;
// int paddingRight = padding.right;
// //軌跡的寬度為 按鈕的寬度+文字的寬度
// final int switchWidth = Math.max(getSwitchMinWidth(),
// 2 * mThumbWidth + paddingLeft + paddingRight + maxTextWidth);
// final int switchHeight = Math.max(trackHeight, thumbHeight);
// mSwitchWidth = switchWidth;
// mSwitchHeight = switchHeight;
//// final int measuredHeight = getMeasuredHeight();
//// if (measuredHeight < switchHeight) {
// setMeasuredDimension(switchWidth, switchHeight);
//// }
// }
//
// private final Rect mTempRect = new Rect();
//
// @Override
// protected void onDraw(Canvas canvas) {
//// super.onDraw(canvas);
// Log.e("eee", "onDraw");
//
// final Rect padding = mTempRect;
// final Drawable trackDrawable = getTrackDrawable();
// if (trackDrawable != null) {
// trackDrawable.getPadding(padding);
// } else {
// padding.setEmpty();
// }
//
// final int switchTop = (getPaddingTop() + getHeight() - getPaddingBottom()) / 2 -
// getHeight() / 2;
// final int switchBottom = switchTop + getHeight();
// final int switchInnerTop = switchTop + padding.top;
// final int switchInnerBottom = switchBottom - padding.bottom;
//
// final Drawable thumbDrawable = getThumbDrawable();
// if (trackDrawable != null) {
// trackDrawable.draw(canvas);
// }
//
// final int saveCount = canvas.save();
// if (thumbDrawable != null) {
// thumbDrawable.draw(canvas);
// }
//
// Class<?> switchCompatClass = getClass().getSuperclass();
// Method method = null;
// try {
// method = switchCompatClass.getDeclaredMethod("getTargetCheckedState");
// } catch (NoSuchMethodException e) {
// e.printStackTrace();
// }
// method.setAccessible(true);
// boolean state = false;
// try {
// state = (boolean) method.invoke(this);
// } catch (IllegalAccessException | InvocationTargetException e) {
// e.printStackTrace();
// }
//
// final Layout switchText = state ? mOnLayout : mOffLayout;
// if (switchText != null) {
// final int[] drawableState = getDrawableState();
// ColorStateList textColors = getTextColors();
// if (textColors != null) {
// getPaint().setColor(textColors.getColorForState(drawableState, 0));
// }
// getPaint().drawableState = drawableState;
//
// final int cX;
// final int left;
// if (thumbDrawable != null) {
// final Rect bounds = thumbDrawable.getBounds();
// cX = bounds.left + bounds.right;
// left = state ? (bounds.left - getLeft() - switchText.getWidth()) / 2 : bounds.right + ((getRight() - bounds.right) - switchText.getWidth()) / 2;
// } else {
// cX = getWidth();
// left = cX / 2 - switchText.getWidth() / 2;
// }
//// final int left = cX / 2 - switchText.getWidth() / 2;
//// final int top = (switchInnerTop + switchInnerBottom) / 2 - switchText.getHeight() / 2;
// final int top = (getHeight() - switchText.getHeight()) / 2;
// canvas.translate(left, top);
// switchText.draw(canvas);
// }
//
// canvas.restoreToCount(saveCount);
// }
//
// @Override
// protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
// super.onLayout(changed, left, top, right, bottom);
// Log.e("eee", "onLayout");
//
// int opticalInsetLeft = 0;
// int opticalInsetRight = 0;
// Drawable mThumbDrawable = getThumbDrawable();
// Drawable mTrackDrawable = getTrackDrawable();
// if (mThumbDrawable != null) {
// final Rect trackPadding = mTempRect;
// if (mTrackDrawable != null) {
// mTrackDrawable.getPadding(trackPadding);
// } else {
// trackPadding.setEmpty();
// }
//
// opticalInsetLeft = trackPadding.left;
// opticalInsetRight = trackPadding.right;
// }
//
// final int switchLeft = getPaddingLeft() + opticalInsetLeft;
// final int switchRight = switchLeft + mSwitchWidth - opticalInsetLeft - opticalInsetRight;
//
// final int switchTop;
// final int switchBottom;
// switch (getGravity() & Gravity.VERTICAL_GRAVITY_MASK) {
// default:
// case Gravity.TOP:
// switchTop = getPaddingTop();
// switchBottom = switchTop + mSwitchHeight;
// break;
//
// case Gravity.CENTER_VERTICAL:
// switchTop = (getPaddingTop() + getHeight() - getPaddingBottom()) / 2 -
// mSwitchHeight / 2;
// switchBottom = switchTop + mSwitchHeight;
// break;
//
// case Gravity.BOTTOM:
// switchBottom = getHeight() - getPaddingBottom();
// switchTop = switchBottom - mSwitchHeight;
// break;
// }
//
// mSwitchLeft = switchLeft;
// mSwitchTop = switchTop;
// mSwitchBottom = switchBottom;
// mSwitchRight = switchRight;
// }
//
// @Override
// public void draw(Canvas c) {
// Log.e("eee", "draw");
// final Rect padding = mTempRect;
// final int switchLeft = mSwitchLeft;
// final int switchTop = mSwitchTop;
// final int switchRight = mSwitchRight;
// final int switchBottom = mSwitchBottom;
//
// int thumbInitialLeft = switchLeft;
// Drawable mThumbDrawable = getThumbDrawable();
// Drawable mTrackDrawable = getTrackDrawable();
// final Rect thumbInsets;
// thumbInsets = DrawableUtils.INSETS_NONE;
// // Layout the track.
// if (mTrackDrawable != null) {
// mTrackDrawable.getPadding(padding);
//
// // Adjust thumb position for track padding.
// thumbInitialLeft += padding.left;
//
// // If necessary, offset by the optical insets of the thumb asset.
// int trackLeft = switchLeft;
// int trackTop = switchTop;
// int trackRight = switchRight;
// int trackBottom = switchBottom;
// if (thumbInsets != null) {
// if (thumbInsets.left > padding.left) {
// trackLeft += thumbInsets.left - padding.left;
// }
// if (thumbInsets.top > padding.top) {
// trackTop += thumbInsets.top - padding.top;
// }
// if (thumbInsets.right > padding.right) {
// trackRight -= thumbInsets.right - padding.right;
// }
// if (thumbInsets.bottom > padding.bottom) {
// trackBottom -= thumbInsets.bottom - padding.bottom;
// }
// }
// mTrackDrawable.setBounds(trackLeft, trackTop, trackRight, trackBottom);
// }
//
// // Layout the thumb.
// if (mThumbDrawable != null) {
// mThumbDrawable.getPadding(padding);
//
// final int thumbLeft = thumbInitialLeft - padding.left;
// final int thumbRight = thumbInitialLeft + mThumbWidth + padding.right;
// mThumbDrawable.setBounds(thumbLeft, switchTop, thumbRight, switchBottom);
//
// final Drawable background = getBackground();
// if (background != null) {
// DrawableCompat.setHotspotBounds(background, thumbLeft, switchTop,
// thumbRight, switchBottom);
// }
// }
// super.draw(c);
// }
//
// private Layout makeLayout(CharSequence text) {
// return new StaticLayout(text, getPaint(),
// text != null ?
// (int) Math.ceil(Layout.getDesiredWidth(text, getPaint())) : 0,
// Layout.Alignment.ALIGN_NORMAL, 1.f, 0, true);
// }
//
//
//}
......@@ -26,7 +26,7 @@ public class ViewUtils {
int halfLeftRvHeight = recyclerView.getHeight() / 2;
if (childAt != null) {
//中間位置那個item減去一半的高度等於中間item一半顯示在列表中間
int y = (int) (childAt.getTop() - halfLeftRvHeight);
int y = childAt.getTop() - halfLeftRvHeight;
recyclerView.smoothScrollBy(0, y);
}
}
......@@ -42,7 +42,7 @@ public class ViewUtils {
int halfLeftRvHeight = recyclerView.getWidth() / 2;
if (childAt != null) {
//中間位置那個item減去一半的高度等於中間item一半顯示在列表中間
int x = (int) (childAt.getLeft() - halfLeftRvHeight);
int x = childAt.getLeft() - halfLeftRvHeight;
recyclerView.smoothScrollBy(x, 0);
}
}
......
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.AppCompatCheckBox
android:id="@+id/cb_gray_to_blue"
android:layout_width="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_2"
android:layout_marginRight="@dimen/dp_2"
android:layout_marginBottom="@dimen/dp_15"
android:background="@drawable/selector_new_order_radio_bg"
android:button="@null"
android:paddingLeft="@dimen/dp_10"
android:paddingTop="@dimen/dp_5"
android:paddingRight="@dimen/dp_10"
android:paddingBottom="@dimen/dp_5"
android:textColor="@color/s_gray_blue"
android:textSize="@dimen/dp_15"
tools:text="正常消耗" />
</FrameLayout>
......@@ -105,39 +105,44 @@
</LinearLayout>
<LinearLayout
android:id="@+id/layout_right_content"
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4"
android:orientation="vertical">
<!-- 二級分類 -->
<LinearLayout
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/layout_category"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="horizontal">
android:layout_marginBottom="@dimen/dp_5"
android:background="@color/white">
<!-- 二級分類 -->
<com.google.android.material.appbar.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|enterAlways">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_food_ingredients_second_category"
android:layout_width="0dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
android:layout_marginRight="@dimen/dp_58" />
<androidx.cardview.widget.CardView
android:id="@+id/card_show_more_category"
android:layout_width="wrap_content"
android:layout_width="@dimen/dp_58"
android:layout_height="match_parent"
android:layout_gravity="right"
android:background="@color/white"
app:cardElevation="@dimen/dp_10">
<LinearLayout
android:layout_width="@dimen/dp_58"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:gravity="center">
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:id="@+id/iv_unfold_arrow"
......@@ -156,15 +161,16 @@
</LinearLayout>
</androidx.cardview.widget.CardView>
</com.google.android.material.appbar.CollapsingToolbarLayout>
</LinearLayout>
</com.google.android.material.appbar.AppBarLayout>
<!-- 食材 -->
<com.scwang.smartrefresh.layout.SmartRefreshLayout
android:id="@+id/refreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/dp_5">
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<com.qmuiteam.qmui.widget.section.QMUIStickySectionLayout
android:id="@+id/section_food_ingredients"
......@@ -173,13 +179,15 @@
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
<!-- <androidx.recyclerview.widget.RecyclerView-->
<!-- android:id="@+id/rv_food_ingredients"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"-->
<!-- android:layout_marginTop="@dimen/dp_5"-->
<!-- app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />-->
</LinearLayout>
<!-- <androidx.recyclerview.widget.RecyclerView-->
<!-- android:id="@+id/rv_food_ingredients"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"-->
<!-- android:layout_marginTop="@dimen/dp_5"-->
<!-- app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />-->
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</LinearLayout>
<LinearLayout
......
......@@ -13,7 +13,9 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/dp_10"
android:layout_marginTop="@dimen/dp_10"
android:layout_marginLeft="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_10"
android:background="@drawable/shape_white_eight_corners_bg"
android:orientation="horizontal"
android:paddingTop="@dimen/dp_10"
......@@ -100,6 +102,7 @@
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:orientation="horizontal">
......@@ -128,7 +131,6 @@
android:text="出庫流水"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_17" />
</LinearLayout>
<com.scwang.smartrefresh.layout.SmartRefreshLayout
......
......@@ -122,6 +122,17 @@
</LinearLayout>
</LinearLayout>
<com.scwang.smartrefresh.layout.SmartRefreshLayout
android:id="@+id/smart_inventory_record"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/dp_1"
android:orientation="vertical">
<include layout="@layout/item_inventory_record" />
<androidx.recyclerview.widget.RecyclerView
......@@ -129,6 +140,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
</LinearLayout>
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
</LinearLayout>
\ No newline at end of file
......@@ -2,8 +2,8 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_marginBottom="@dimen/dp_1"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/dp_1">
<LinearLayout
android:layout_width="match_parent"
......@@ -33,24 +33,27 @@
<TextView
android:id="@+id/tv_food_item_no"
android:layout_width="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/dp_10"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:textColor="@color/color_3c"
android:textSize="@dimen/dp_12"
tools:text="SP001" />
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<TextView
android:id="@+id/tv_food_item_supplier_name"
android:layout_width="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="2"
android:gravity="right"
android:maxLines="2"
android:textColor="@color/black"
android:textSize="@dimen/dp_13"
android:textStyle="bold"
......
<?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="wrap_content"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatCheckBox
android:id="@+id/cb_consumption_reason"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:textColor="@color/color_3c"
android:layout_marginTop="@dimen/dp_10"
android:text="正常消耗" />
</LinearLayout>
\ No newline at end of file
......@@ -9,40 +9,50 @@
<TextView
android:id="@+id/tv_inventory_record_username"
style="@style/WareHouse_item_TextStyle"
style="@style/Inventory_Record_style"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="20"
android:paddingLeft="@dimen/dp_2"
android:paddingTop="@dimen/dp_10"
android:paddingRight="@dimen/dp_2"
android:paddingBottom="@dimen/dp_10"
android:text="用戶名" />
<include layout="@layout/include_vertical_color_white_dividing_line" />
<include layout="@layout/include_vertical_color_e8_dividing_line" />
<TextView
android:id="@+id/tv_inventory_record_number"
style="@style/WareHouse_item_TextStyle"
style="@style/Inventory_Record_style"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_weight="17"
android:paddingLeft="@dimen/dp_2"
android:paddingRight="@dimen/dp_2"
android:text="盤點" />
<include layout="@layout/include_vertical_color_white_dividing_line" />
<include layout="@layout/include_vertical_color_e8_dividing_line" />
<TextView
android:id="@+id/tv_inventory_record_difference"
style="@style/WareHouse_item_TextStyle"
style="@style/Inventory_Record_style"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_weight="23"
android:paddingLeft="@dimen/dp_2"
android:paddingRight="@dimen/dp_2"
android:text="差異數" />
<include layout="@layout/include_vertical_color_white_dividing_line" />
<include layout="@layout/include_vertical_color_e8_dividing_line" />
<TextView
android:id="@+id/tv_inventory_record_operating_data"
style="@style/WareHouse_item_TextStyle"
style="@style/Inventory_Record_style"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_weight="39"
android:paddingLeft="@dimen/dp_2"
android:paddingRight="@dimen/dp_2"
android:text="操作日期" />
</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"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_item_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.18"
android:background="#D9E1F2"
android:gravity="center"
android:paddingLeft="@dimen/dp_10"
android:paddingTop="@dimen/dp_5"
android:paddingRight="@dimen/dp_10"
android:paddingBottom="@dimen/dp_5"
tools:text="品名" />
<View
android:layout_width="@dimen/dp_1"
android:layout_height="match_parent"
android:background="#BAC5D3" />
<TextView
android:id="@+id/tv_item_value"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.82"
android:gravity="center_vertical"
android:paddingLeft="@dimen/dp_10"
android:paddingTop="@dimen/dp_5"
android:paddingRight="@dimen/dp_10"
android:paddingBottom="@dimen/dp_5"
tools:text="巴西肥牛" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="@dimen/dp_1"
android:background="#BAC5D3" />
</LinearLayout>
<?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"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_500"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/dp_10"
android:background="@drawable/shape_white_eight_corners_bg"
android:orientation="vertical"
......@@ -52,6 +56,7 @@
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_5"
android:shadowColor="@color/trans"
android:text="打印:"
android:thumb="@drawable/shape_thumb_on"
android:track="@drawable/selector_switch_track"
app:layout_constraintBottom_toBottomOf="parent"
......@@ -103,6 +108,7 @@
</LinearLayout>
<LinearLayout
android:id="@+id/layout_inventory_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_20"
......@@ -132,4 +138,5 @@
android:paddingBottom="@dimen/dp_12"
android:text="@string/str_cancel" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</FrameLayout>
<?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">
<TextView
android:id="@+id/tv_print_consume_restaurant_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_16"
android:textStyle="bold"
tools:text="餐廳名" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:orientation="horizontal"
android:paddingLeft="@dimen/dp_10"
android:paddingRight="@dimen/dp_10">
<TextView
android:id="@+id/tv_print_consume_date"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_14"
tools:text="日期:" />
<TextView
android:id="@+id/tv_print_consume_no"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_14"
tools:text="編號" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_marginTop="@dimen/dp_5"
android:layout_height="@dimen/dp_1"
android:background="@color/theme_333_color" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_print_consume_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
<TextView
android:id="@+id/tv_print_consume_user_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:layout_marginLeft="@dimen/dp_5"
android:text="製單人:"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_14" />
</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="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
......@@ -67,12 +67,17 @@
<include layout="@layout/item_sn_code" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_sn_code"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
android:layout_height="match_parent"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
......
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/centerPopupContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
......@@ -27,7 +28,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:text="標題"
tools:text="內存\n阿薩德好看熬好久是"
android:textColor="@color/theme_333_color"
android:textSize="@dimen/dp_14" />
</LinearLayout>
......
......@@ -28,4 +28,9 @@
<string name="str_Inbound_quantity">入庫數量:</string>
<string name="str_enter_scan_sn">輸入/掃描SN碼:</string>
<string name="str_sn_code">SN碼</string>
<string name="str_restaurant_outbound_order">%1$s-出庫單</string>
<string name="str_no">NO:%1$s</string>
<string name="str_prepared">製單人:%1$s</string>
<string name="str_device_not_print">您的設備不支持打印</string>
</resources>
\ No newline at end of file
......@@ -59,6 +59,7 @@
<item name="android:textSize">@dimen/dp_14</item>
<item name="android:textColor">@color/color_3c</item>
</style>
<style name="Remark_editStyle">
<item name="android:textColorHint">@color/color_c9</item>
<item name="android:textSize">@dimen/dp_16</item>
......@@ -77,4 +78,12 @@
<item name="android:textColorHint">@color/color_b8</item>
<item name="android:textSize">@dimen/dp_16</item>
</style>
<style name="Inventory_Record_style">
<item name="android:textSize">@dimen/dp_14</item>
<item name="android:textColor">@color/white</item>
<item name="android:ellipsize">end</item>
<item name="android:maxLines">1</item>
<item name="android:gravity">center</item>
</style>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
</resources>
\ No newline at end of file
......@@ -110,17 +110,37 @@ public class ImageUtils {
int height = oldbmp.getHeight();
Matrix matrix = new Matrix();
float scaleWidth = ((float) w / width);
// float scaleWidth = ((float) w / (width / 2f));//0.37
// float scaleHeight = scaleWidth / 2;
matrix.postScale(scaleWidth, scaleWidth);
return Bitmap.createBitmap(oldbmp, 0, 0, width, height,
matrix, true);
}
/**
* 針式打印機用,因為是高密度模式,打印出來寬度會少一半,所以需要除以2
*
* @param oldbmp 圖片
* @param w 打印紙寬度
* @return 縮放後的圖片
*/
public static Bitmap dotMatrixZoomDrawable(Bitmap oldbmp, int w) {
int width = oldbmp.getWidth();
int height = oldbmp.getHeight();
Matrix matrix = new Matrix();
float scaleWidth = ((float) w / (width / 2f));
float scaleHeight = scaleWidth / 2;
matrix.postScale(scaleWidth, scaleHeight);
return Bitmap.createBitmap(oldbmp, 0, 0, width, height,
matrix, true);
}
public static Bitmap zoomDrawable(Bitmap oldbmp, int w, double heightMultiple) {
int width = oldbmp.getWidth();
int height = oldbmp.getHeight();
Matrix matrix = new Matrix();
float scaleWidth = ((float) w / width);
float scaleHeight = (float) (scaleWidth/heightMultiple);
float scaleHeight = (float) (scaleWidth / heightMultiple);
matrix.postScale(scaleWidth, scaleHeight);
return Bitmap.createBitmap(oldbmp, 0, 0, width, height,
matrix, true);
......
......@@ -5,6 +5,8 @@ import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.PaintFlagsDrawFilter;
import android.os.Environment;
import android.util.Log;
import android.view.View;
......@@ -171,12 +173,17 @@ public class LayoutToBitmapUtils {
c.drawColor(Color.WHITE);
/** 如果不设置canvas画布为白色,则生成透明 */
c.setDrawFilter(new PaintFlagsDrawFilter(Paint.ANTI_ALIAS_FLAG, Paint.FILTER_BITMAP_FLAG));
v.layout(0, 0, w, h);
v.draw(c);
return bmp;
}
public static Bitmap getBitmapByView(Context context, View v){
layoutView(context, v);
return loadBitmapFromView(v);
}
//-----------------------------------------------------------------
//然后View和其内部的子View都具有了实际大小,也就是完成了布局,相当与添加到了界面上。接着就可以创建位图并在上面绘制了:
......
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/other_order_details_sure_btn_color" android:state_checked="true" />
<item android:color="@color/color_c8" />
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/other_order_details_sure_btn_color" android:state_checked="true"/>
<item android:drawable="@drawable/shape_border_bg" android:state_checked="true" />
<item android:drawable="@drawable/shape_delivery_item_btn_normal"/>
<item android:drawable="@drawable/shape_delivery_item_btn_normal" />
</selector>
\ No newline at end of file
......@@ -295,7 +295,7 @@
<style name="Print_text_style">
<item name="android:textColor">@color/black</item>
<item name="android:textSize">@dimen/sp_24</item>
<item name="android:textSize">@dimen/sp_28</item>
</style>
<!-- 廚房單菜品名字體樣式-->
......
......@@ -44,7 +44,7 @@ public class PrjBean implements Serializable {
private String tableName;
private String orderNo;
private int orderTime;
private String orderTime;
private int person;
private String orderDetailsTime;
private int orderDetailsId;
......
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
......@@ -14,23 +14,26 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="頭單"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
tools:text="頭單" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<!-- 台號-->
<TextView
android:id="@+id/tv_kitchen_print_table_number"
style="@style/Print_kitchen_table_number_text_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="外賣19"
android:textStyle="bold"
android:textSize="@dimen/sp_42"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_kitchen_print_first_order" />
android:textStyle="bold"
tools:text="外賣19" />
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<!--預留-->
<TextView
android:id="@+id/tv_order_reserved"
......@@ -38,20 +41,39 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:text="預存"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_kitchen_print_first_order" />
android:visibility="visible"
tools:text="預存" />
</LinearLayout>
<!--單號-->
<LinearLayout
android:id="@+id/ll_order"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_order_num_text"
style="@style/Print_dot_matrix_normal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="單號:" />
<TextView
android:id="@+id/tv_order_num"
style="@style/Print_forty_two_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
tools:text="AE86" />
</LinearLayout>
<TextView
android:id="@+id/tv_food_time"
style="@style/Print_text_style"
style="@style/Print_dot_matrix_normal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/sp_18"
android:visibility="visible"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_kitchen_print_table_number"
tools:text="盡快送達" />
<!--落單時間-->
......@@ -59,27 +81,21 @@
android:id="@+id/ll_order_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_food_time">
android:orientation="horizontal">
<TextView
android:id="@+id/tv_order_time_text"
style="@style/Print_text_style"
style="@style/Print_dot_matrix_normal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="落單:"
android:textColor="@color/black"
android:textSize="@dimen/sp_18" />
android:text="落單:" />
<TextView
android:id="@+id/tv_order_time"
style="@style/Print_text_style"
style="@style/Print_dot_matrix_normal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="01-04 19:32"
android:textColor="@color/black"
android:textSize="@dimen/sp_18" />
tools:text="01-04 19:32" />
</LinearLayout>
<!--開台時間-->
......@@ -87,27 +103,21 @@
android:id="@+id/ll_opening_table_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/ll_order_time">
android:orientation="horizontal">
<TextView
android:id="@+id/tv_opening_time_text"
style="@style/Print_text_style"
style="@style/Print_dot_matrix_normal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="開檯:"
android:textColor="@color/black"
android:textSize="@dimen/sp_18" />
android:text="開檯:" />
<TextView
android:id="@+id/tv_opening_time"
style="@style/Print_text_style"
style="@style/Print_dot_matrix_normal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="01-20 12:00"
android:textColor="@color/black"
android:textSize="@dimen/sp_18" />
tools:text="01-20 12:00" />
</LinearLayout>
<!--人數,廚房-->
......@@ -116,93 +126,56 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5"
android:orientation="horizontal"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/ll_opening_table_time">
android:orientation="horizontal">
<TextView
android:id="@+id/tv_people_text"
style="@style/Print_text_style"
style="@style/Print_dot_matrix_normal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="人數:"
android:textColor="@color/black"
android:textSize="@dimen/sp_18"
android:text="人數:"
android:visibility="visible" />
<TextView
android:id="@+id/tv_people"
style="@style/Print_text_style"
style="@style/Print_dot_matrix_normal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/black"
android:textSize="@dimen/sp_18"
android:text="0"
android:visibility="visible" />
android:layout_marginRight="@dimen/dp_20"
android:visibility="visible"
tools:text="0" />
<TextView
android:id="@+id/tv_kitchen_location_text"
style="@style/Print_text_style"
style="@style/Print_dot_matrix_normal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_20"
android:text="廚房:"
android:textColor="@color/black"
android:textSize="@dimen/sp_18"
android:text="廚房:"
android:visibility="visible" />
<TextView
android:id="@+id/tv_kitchen_location"
style="@style/Print_text_style"
style="@style/Print_dot_matrix_normal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="@color/black"
android:textSize="@dimen/sp_18"
android:visibility="visible" />
android:visibility="visible"
tools:text="K1" />
</LinearLayout>
<!--單號-->
<LinearLayout
android:id="@+id/ll_order"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/ll_order_time">
<TextView
android:id="@+id/tv_order_num_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="單號:"
android:textColor="@color/black"
android:textSize="@dimen/sp_18" />
<TextView
android:id="@+id/tv_order_num"
style="@style/Print_text_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="AE86"
android:textSize="@dimen/sp_42" />
</LinearLayout>
<!--自取取餐碼-->
<LinearLayout
android:id="@+id/ll_take_code"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintLeft_toLeftOf="@+id/ll_order"
app:layout_constraintTop_toBottomOf="@+id/ll_order">
android:orientation="horizontal">
<TextView
android:id="@+id/tv_take_code_text"
style="@style/Print_text_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="取餐碼:"
android:text="取餐碼"
android:textSize="@dimen/sp_18"
android:visibility="gone" />
......@@ -220,40 +193,31 @@
android:id="@+id/ll_waiter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/ll_take_code">
android:orientation="horizontal">
<TextView
android:id="@+id/tv_waiter_text"
style="@style/Print_text_style"
style="@style/Print_dot_matrix_normal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="服務員:"
android:textColor="@color/black"
android:textSize="@dimen/sp_18" />
android:text="服務員:" />
<TextView
android:id="@+id/tv_waiter"
style="@style/Print_text_style"
style="@style/Print_dot_matrix_normal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="GSPOS"
android:textColor="@color/black"
android:textSize="@dimen/sp_18" />
tools:text="GSPOS" />
</LinearLayout>
<TextView
android:id="@+id/line_kitchen_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_12"
android:layout_marginTop="@dimen/dp_5"
android:maxLines="1"
android:text="————————————————————————————————————————————"
android:textSize="@dimen/sp_18"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/ll_waiter" />
android:textSize="@dimen/sp_18" />
<!-- <androidx.recyclerview.widget.RecyclerView-->
<!-- android:id="@+id/rv_kitchen_food"-->
......@@ -267,7 +231,6 @@
android:id="@+id/ll_kitchen_food"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:orientation="vertical"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/line_kitchen_info" />
......@@ -276,7 +239,6 @@
android:id="@+id/tv_kitchen_food_end_line"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5"
android:maxLines="1"
android:text="————————————————————————————————————————————"
android:textSize="@dimen/sp_18"
......@@ -297,11 +259,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_20"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_kitchen_food_end_line">
android:orientation="horizontal">
<TextView
android:id="@+id/tv_prj_page_index"
......@@ -319,9 +277,9 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="外賣19"
android:textSize="@dimen/sp_42"
android:textStyle="bold"
android:textSize="@dimen/sp_42"/>
tools:text="外賣19" />
<TextView
android:id="@+id/tv_kitchen_print_quantity"
......@@ -359,7 +317,7 @@
<!-- style="@style/Print_text_style"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:text="落單時間:"-->
<!-- android:text="落單時間"-->
<!-- android:textColor="@color/black"-->
<!-- android:textSize="@dimen/sp_18" />-->
......@@ -382,7 +340,7 @@
<!-- android:id="@+id/tv_order_num_text"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:text="單號:"-->
<!-- android:text="單號"-->
<!-- android:textColor="@color/black"-->
<!-- android:textSize="@dimen/sp_18" />-->
......@@ -406,7 +364,7 @@
<!-- style="@style/Print_text_style"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:text="取餐碼:"-->
<!-- android:text="取餐碼"-->
<!-- android:textSize="@dimen/dp_20"-->
<!-- android:visibility="gone" />-->
......@@ -429,7 +387,7 @@
<!-- style="@style/Print_text_style"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:text="落單時間:"-->
<!-- android:text="落單時間"-->
<!-- android:textColor="@color/black"-->
<!-- android:textSize="@dimen/sp_18" />-->
......@@ -462,7 +420,7 @@
<!-- style="@style/Print_text_style"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:text="開檯時間:"-->
<!-- android:text="開檯時間"-->
<!-- android:textColor="@color/black"-->
<!-- android:textSize="@dimen/sp_18" />-->
......@@ -508,7 +466,7 @@
<!-- style="@style/Print_text_style"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:text="人數:"-->
<!-- android:text="人數"-->
<!-- android:textColor="@color/black"-->
<!-- android:textSize="@dimen/sp_18"-->
<!-- android:visibility="visible" />-->
......@@ -582,4 +540,4 @@
<!-- tools:text="統計數量" />-->
<!-- </RelativeLayout>-->
<!-- </LinearLayout>-->
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!--廚房單-->
<!-- 頭單-->
<TextView
android:id="@+id/tv_kitchen_print_first_order"
style="@style/Print_kitchen_table_number_text_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="頭單"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<!-- 台號-->
<TextView
android:id="@+id/tv_kitchen_print_table_number"
style="@style/Print_kitchen_table_number_text_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="19"
android:textSize="@dimen/dp_48"
android:textStyle="bold" />
android:text="外賣19"
android:textSize="@dimen/sp_42"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_kitchen_print_first_order" />
<!--預留-->
<TextView
android:id="@+id/tv_kitchen_print_first_order"
android:id="@+id/tv_order_reserved"
style="@style/Print_kitchen_table_number_text_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:textSize="@dimen/dp_40" />
tools:text="預存"
android:textStyle="bold"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_kitchen_print_first_order" />
<LinearLayout
android:layout_width="match_parent"
<TextView
android:id="@+id/tv_food_time"
style="@style/Print_eighteen_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="@dimen/dp_10">
android:visibility="visible"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_kitchen_print_table_number"
tools:text="盡快送達" />
<!--落單時間-->
<LinearLayout
android:layout_width="match_parent"
android:id="@+id/ll_order_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
android:orientation="horizontal"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_food_time">
<TextView
android:id="@+id/tv_order_num_text"
style="@style/Print_text_style"
android:id="@+id/tv_order_time_text"
style="@style/Print_eighteen_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="單號:" />
android:text="落單:" />
<TextView
android:id="@+id/tv_order_num"
style="@style/Print_text_style"
android:id="@+id/tv_order_time"
style="@style/Print_eighteen_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="AE86"
android:textSize="@dimen/dp_40" />
android:text="01-04 19:32" />
</LinearLayout>
<!--開台時間-->
<LinearLayout
android:id="@+id/layout_take_code"
android:layout_width="match_parent"
android:id="@+id/ll_opening_table_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
android:orientation="horizontal"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/ll_order_time">
<TextView
android:id="@+id/tv_take_code_text"
style="@style/Print_text_style"
android:id="@+id/tv_opening_time_text"
style="@style/Print_eighteen_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="取餐碼:"
android:textSize="@dimen/dp_20"
android:visibility="visible" />
android:text="開檯:" />
<TextView
android:id="@+id/tv_take_code"
style="@style/Print_text_style"
android:id="@+id/tv_opening_time"
style="@style/Print_eighteen_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/dp_20"
android:visibility="visible" />
android:text="01-20 12:00" />
</LinearLayout>
<!--人數,廚房-->
<LinearLayout
android:layout_width="match_parent"
android:id="@+id/ll_people_and_kitchen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
android:layout_marginTop="@dimen/dp_5"
android:orientation="horizontal"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/ll_opening_table_time">
<TextView
android:id="@+id/tv_order_time_text"
style="@style/Print_text_style"
android:id="@+id/tv_people_text"
style="@style/Print_eighteen_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="落單時間:"
android:textSize="@dimen/dp_28" />
android:text="人數:"
android:visibility="visible" />
<TextView
android:id="@+id/tv_order_time"
style="@style/Print_text_style"
android:id="@+id/tv_people"
style="@style/Print_eighteen_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="01-04 19:32"
android:textSize="@dimen/dp_28" />
</LinearLayout>
android:text="0"
android:visibility="visible" />
<TextView
android:id="@+id/tv_food_time"
style="@style/Print_text_style"
android:id="@+id/tv_kitchen_location_text"
style="@style/Print_eighteen_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/dp_28"
tools:text="盡快送達" />
android:layout_marginLeft="@dimen/dp_20"
android:text="廚房:"
android:visibility="visible" />
<TextView
android:id="@+id/tv_kitchen_location"
style="@style/Print_eighteen_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:visibility="visible" />
</LinearLayout>
<!--單號-->
<LinearLayout
android:id="@+id/layout_opening_table_time"
android:layout_width="match_parent"
android:id="@+id/ll_order"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/ll_order_time">
<TextView
android:id="@+id/tv_opening_time_text"
style="@style/Print_text_style"
android:id="@+id/tv_order_num_text"
style="@style/Print_eighteen_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="開檯時間:"
android:textSize="@dimen/dp_20" />
android:text="單號:" />
<TextView
android:id="@+id/tv_opening_time"
android:id="@+id/tv_order_num"
style="@style/Print_text_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/dp_20" />
android:text="AE86"
android:textSize="@dimen/sp_42" />
</LinearLayout>
<!--自取取餐碼-->
<LinearLayout
android:layout_width="match_parent"
android:id="@+id/ll_take_code"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
android:orientation="horizontal"
app:layout_constraintLeft_toLeftOf="@+id/ll_order"
app:layout_constraintTop_toBottomOf="@+id/ll_order">
<TextView
android:id="@+id/tv_kitchen_location"
android:id="@+id/tv_take_code_text"
style="@style/Print_text_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/dp_20"
android:text="K1 廚房" />
android:text="取餐碼:"
android:textSize="@dimen/sp_18"
android:visibility="gone" />
<TextView
android:id="@+id/tv_operator"
android:id="@+id/tv_take_code"
style="@style/Print_text_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="gsadmin" />
android:textSize="@dimen/sp_18"
android:visibility="gone" />
</LinearLayout>
<!--服務員-->
<LinearLayout
android:layout_width="match_parent"
android:id="@+id/ll_waiter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
android:orientation="horizontal"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/ll_take_code">
<TextView
android:id="@+id/tv_people_text"
style="@style/Print_text_style"
android:id="@+id/tv_waiter_text"
style="@style/Print_eighteen_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="人數:"
android:visibility="gone" />
android:text="服務員:" />
<TextView
android:id="@+id/tv_people"
style="@style/Print_text_style"
android:id="@+id/tv_waiter"
style="@style/Print_eighteen_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1000"
android:visibility="gone" />
android:text="GSPOS" />
</LinearLayout>
<TextView
android:id="@+id/line_kitchen_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_5"
android:maxLines="1"
android:text="——————————————————————————————————————————————————"
app:layout_constraintTop_toBottomOf="@id/tv_operator" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_kitchen_food"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:visibility="gone" />
android:text="————————————————————————————————————————————"
android:textSize="@dimen/sp_18"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/ll_waiter" />
<LinearLayout
android:id="@+id/layout_kitchen_food"
android:id="@+id/ll_kitchen_food"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10"
android:orientation="vertical" />
android:orientation="vertical"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/line_kitchen_info" />
<TextView
android:id="@+id/tv_kitchen_print_table_number2"
style="@style/Print_kitchen_table_number_text_style"
android:layout_width="wrap_content"
android:id="@+id/tv_kitchen_food_end_line"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="19"
android:textSize="@dimen/dp_48"
android:textStyle="bold" />
android:layout_marginTop="@dimen/dp_5"
android:maxLines="1"
android:text="————————————————————————————————————————————"
android:textSize="@dimen/sp_18"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/ll_kitchen_food" />
<RelativeLayout
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_20"
android:orientation="horizontal">
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_kitchen_food_end_line">
<TextView
android:id="@+id/tv_prj_page_index"
style="@style/Print_kitchen_table_number_text_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center_horizontal"
android:textSize="@dimen/dp_28"
android:layout_gravity="center_vertical"
android:textSize="@dimen/sp_28"
tools:text="1/2" />
<TextView
android:id="@+id/tv_kitchen_print_table_number_bottom"
style="@style/Print_kitchen_table_number_text_style"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="外賣19"
android:textSize="@dimen/sp_42"
android:textStyle="bold" />
<TextView
android:id="@+id/tv_kitchen_print_quantity"
style="@style/Print_kitchen_table_number_text_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:textSize="@dimen/dp_30"
android:layout_gravity="center_vertical"
android:textSize="@dimen/sp_28"
tools:text="統計數量" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Print_eighteen_text">
<item name="android:textSize">@dimen/dp_18</item>
<item name="android:textColor">@color/black</item>
<item name="android:includeFontPadding">false</item>
</style>
<style name="Print_twenty_four_text">
<item name="android:textSize">@dimen/dp_24</item>
<item name="android:textColor">@color/black</item>
<item name="android:includeFontPadding">false</item>
</style>
<style name="Print_twenty_six_text">
<item name="android:textSize">@dimen/dp_26</item>
<item name="android:textColor">@color/black</item>
<item name="android:includeFontPadding">false</item>
</style>
<style name="Print_twenty_eight_text">
<item name="android:textSize">@dimen/dp_28</item>
<item name="android:textColor">@color/black</item>
<item name="android:includeFontPadding">false</item>
</style>
<style name="Print_thirty_two_text">
<item name="android:textSize">@dimen/dp_32</item>
<item name="android:textColor">@color/black</item>
<item name="android:includeFontPadding">false</item>
</style>
<style name="Print_forty_two_text">
<item name="android:textSize">@dimen/dp_42</item>
<item name="android:textColor">@color/black</item>
<item name="android:includeFontPadding">false</item>
</style>
<style name="Print_dot_matrix_normal" parent="@style/Print_twenty_six_text" />
</resources>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment