Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
supplier
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王宇航
supplier
Commits
dfe4f9a3
Commit
dfe4f9a3
authored
Apr 01, 2021
by
Wyh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1、外送接單訂單數量沒刷新問題 2、針式打印輪詢查看打印狀態 3、打印字體大小預設問題 4、供應鏈SN食材
parent
e716d712
Show whitespace changes
Inline
Side-by-side
Showing
50 changed files
with
3284 additions
and
738 deletions
+3284
-738
component-delivery-pick/src/main/java/com/gingersoft/gsa/delivery_pick_mode/model/viewModel/PageViewModel.kt
+5
-0
component-delivery-pick/src/main/java/com/gingersoft/gsa/delivery_pick_mode/ui/activity/DeliveryOrderMainActivity.kt
+2
-1
component-print/src/main/java/com/joe/print/mvp/print/EpsonPrint.java
+29
-6
component-print/src/main/java/com/joe/print/mvp/print/service/PrjService.java
+2
-1
component-print/src/main/java/com/joe/print/mvp/print/utils/MyPrintUtils.java
+16
-4
component-supply-chain/build.gradle
+3
-0
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/bean/BuyIngredientsBean.java
+29
-0
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/bean/GroupStructure.java
+43
-0
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/bean/OrderWareHouseBean.java
+1
-2
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/bean/PurchaseConsumeSnBean.java
+11
-9
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/bean/PurchaseFoodEncodeSn.java
+37
-0
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/content/Constant.java
+4
-0
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/contract/BuyIngredientsContract.java
+2
-1
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/contract/OrderDetailsContract.java
+11
-1
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/contract/WarehouseDetailsContract.java
+7
-2
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/model/OrderDetailsModel.java
+6
-0
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/model/WarehouseDetailsModel.java
+5
-0
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/presenter/BuyIngredientsPresenter.java
+24
-20
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/presenter/FoodIngredientsPresenter.java
+3
-3
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/presenter/OrderDetailsPresenter.java
+77
-11
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/presenter/WareHouseListPresenter.java
+2
-2
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/presenter/WarehouseDetailsPresenter.java
+50
-10
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/server/SupplierServer.java
+19
-2
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/ui/adapter/BaseViewHolder.java
+122
-0
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/ui/adapter/BuyIngredientsAdapter.java
+62
-55
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/ui/adapter/GroupedRecyclerViewAdapter.java
+1254
-0
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/ui/adapter/OldBuyIngredientsAdapter.java
+179
-0
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/ui/adapter/SnCodesAdapter.java
+1
-1
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/ui/fragment/food/BuyIngredientsFragment.java
+78
-106
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/ui/fragment/order/OrderDetailsFragment.java
+125
-44
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/ui/fragment/order/SendMsgFragment.java
+14
-5
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/ui/fragment/warehouse/WarehouseDetailsFragment.java
+51
-27
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/ui/widget/GroupedGridLayoutManager.java
+77
-0
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/ui/widget/InventoryConsumptionView.java
+29
-2
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/ui/widget/ScanSnPopup.java
+64
-12
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/ui/widget/ScanSnView.java
+97
-30
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/ui/widget/ShowSnView.java
+68
-0
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/ui/widget/StickyHeaderLayout.java
+418
-0
component-supply-chain/src/main/res/layout/fragment_buy_ingredients.xml
+11
-10
component-supply-chain/src/main/res/layout/fragment_warehouse_details.xml
+0
-9
component-supply-chain/src/main/res/layout/item_show_sn_code.xml
+54
-0
component-supply-chain/src/main/res/layout/layout_print_consume.xml
+12
-0
component-supply-chain/src/main/res/layout/layout_show_sn.xml
+26
-0
component-supply-chain/src/main/res/values/strings.xml
+2
-1
component-supply-chain/src/main/res/values/values.xml
+5
-1
library-common/src/main/java/com/gingersoft/gsa/cloud/common/utils/CollectionUtils.java
+38
-7
library-database/src/main/java/com/gingersoft/gsa/cloud/database/bean/PrinterDeviceBean.java
+2
-0
library-ui/src/main/res/layout/print_dot_matrix_kitchen.xml
+93
-341
library-ui/src/main/res/layout/print_kitchen.xml
+12
-12
library-ui/src/main/res/values/style.xml
+2
-0
No files found.
component-delivery-pick/src/main/java/com/gingersoft/gsa/delivery_pick_mode/model/viewModel/PageViewModel.kt
View file @
dfe4f9a3
...
...
@@ -39,6 +39,7 @@ import com.gingersoft.gsa.delivery_pick_mode.data.model.bean.*
import
com.gingersoft.gsa.delivery_pick_mode.ui.adapter.DeliveryAdapter
import
com.gingersoft.gsa.delivery_pick_mode.util.OtherOrderUtils
import
com.jess.arms.utils.ArmsUtils
import
kotlinx.android.synthetic.main.activity_other_order.*
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.launch
import
kotlinx.coroutines.withContext
...
...
@@ -265,6 +266,10 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
receiveOrder
()
}
else
{
receiverProgress
=
0
//獲取每個狀態的訂單數量
getOrderGroupNum
()
//查詢預約單和即時單數量
getOrderStatistics
(
fragmentStatus
[
0
])
}
}
}
...
...
component-delivery-pick/src/main/java/com/gingersoft/gsa/delivery_pick_mode/ui/activity/DeliveryOrderMainActivity.kt
View file @
dfe4f9a3
...
...
@@ -462,13 +462,14 @@ class DeliveryOrderMainActivity : BaseActivity<IPresenter>(), View.OnClickListen
if
(
cb_takeaway_auto_receiving_orders
.
isChecked
)
{
//查詢待確定的訂單id
pageViewModel
.
getToBeConfirmedOrderIds
()
}
}
else
{
//獲取每個狀態的訂單數量
pageViewModel
.
getOrderGroupNum
()
//查詢預約單和即時單數量
pageViewModel
.
getOrderStatistics
(
fragmentStatus
[
view_pager
.
currentItem
])
}
}
}
})
it
.
execute
{
if
(
it
)
{
...
...
component-print/src/main/java/com/joe/print/mvp/print/EpsonPrint.java
View file @
dfe4f9a3
...
...
@@ -49,7 +49,7 @@ public class EpsonPrint implements ReceiveListener {
/**
* 初始化
*
* @return
* @return
初始化是否成功
*/
public
boolean
initializeObject
(
Context
context
,
ReceiveListener
receiveListener
,
OnPrjPrintResultListener
onPrjPrintResultListener
)
{
try
{
...
...
@@ -84,7 +84,7 @@ public class EpsonPrint implements ReceiveListener {
if
(
e
instanceof
Epos2Exception
)
{
//Note: If printer is processing such as printing and so on, the disconnect API returns ERR_PROCESSING.
if
(((
Epos2Exception
)
e
).
getErrorStatus
()
==
Epos2Exception
.
ERR_PROCESSING
)
{
//报错
}
else
{
break
;
}
...
...
@@ -111,7 +111,7 @@ public class EpsonPrint implements ReceiveListener {
/**
* 創建打印數據
*
* @return
* @return
创建数据是否成功
*/
private
boolean
createPrintData
(
Bitmap
bitmap
)
{
try
{
...
...
@@ -282,6 +282,11 @@ public class EpsonPrint implements ReceiveListener {
}
}
/**
* 最后一次添加到队列的时间
*/
private
long
lastInputTime
=
0
;
public
void
putPrintData
(
String
ip
,
Bitmap
bitmap
,
String
foodId
)
{
//把bitmap存隊列中,下次打印
if
(
bitmaps
.
size
()
<=
0
)
{
...
...
@@ -292,6 +297,11 @@ public class EpsonPrint implements ReceiveListener {
if
(
isPrint
)
{
LogUtil
.
d
(
"eee"
,
"prj針式打印機隊列中,前面還有"
+
bitmaps
.
size
()
+
"個任務"
);
PrinterFlowProxy
.
newInstance
().
dispatchConnectionBefore
(
"針式打印機隊列中,前面還有"
+
bitmaps
.
size
()
+
"個任務"
,
ip
,
0
,
0
,
0
);
//做一個校驗,如果三十秒後,isPrint還是true,就手動改為false。
if
(
System
.
currentTimeMillis
()
-
lastInputTime
>
30
*
1000
)
{
isPrint
=
true
;
printData
(
ip
,
foodId
,
bitmap
);
}
return
;
}
isPrint
=
true
;
...
...
@@ -299,9 +309,11 @@ public class EpsonPrint implements ReceiveListener {
}
private
void
printData
(
String
ip
,
String
ids
,
Bitmap
bitmap
)
{
//记录下本次打印的时间
lastInputTime
=
System
.
currentTimeMillis
();
PrinterFlowProxy
.
newInstance
().
dispatchPrinterDataBefore
(
0
,
0
,
"針式打印機"
,
ip
);
mPrinter
.
clearCommandBuffer
();
LogUtil
.
d
(
"eee"
,
"prj針式打印機創建數據中
,
任務數:"
+
bitmaps
.
size
());
LogUtil
.
d
(
"eee"
,
"prj針式打印機創建數據中
:"
+
ids
+
"——IP地址:"
+
ip
+
"
任務數:"
+
bitmaps
.
size
());
if
(!
createPrintData
(
bitmap
))
{
LogUtil
.
d
(
"eee"
,
"prj針式打印機創建數據失敗"
);
//如果是創建數據失敗,說明這個數據有問題,移除掉
...
...
@@ -312,10 +324,10 @@ public class EpsonPrint implements ReceiveListener {
connectByIp
(
ip
,
mPrinter
.
getStatus
());
//獲取打印機狀態
PrinterStatusInfo
statusInfo
=
mPrinter
.
getStatus
();
Log
Util
.
d
(
"eee"
,
"prj針式打印機:"
+
"紙張狀態:"
+
statusInfo
.
getPaper
()
+
"連接狀態:"
+
statusInfo
.
getConnection
()
+
",任務數:"
+
bitmaps
.
size
());
Log
anManager
.
w_printer
(
TAG
,
"prj針式打印機:"
+
"紙張狀態:"
+
statusInfo
.
getPaper
()
+
"連接狀態:"
+
statusInfo
.
getConnection
()
+
",任務數:"
+
bitmaps
.
size
());
if
(
statusInfo
.
getConnection
()
!=
1
)
{
//未連接到打印機
Log
Util
.
d
(
"eee"
,
"prj針式打印機連接失敗
:"
+
ids
);
Log
anManager
.
w_printer
(
TAG
,
"連接失敗::"
+
statusInfo
.
getConnection
()
+
"prj
:"
+
ids
);
printErrorProcess
(
ids
,
bitmap
,
new
Exception
(
"針式打印機連接失敗"
+
ip
),
PrintSocketHolder
.
ERROR_7
);
return
;
}
else
if
(
statusInfo
.
getPaper
()
!=
0
)
{
...
...
@@ -347,6 +359,7 @@ public class EpsonPrint implements ReceiveListener {
* @param bitmap
*/
private
void
printErrorProcess
(
String
ids
,
Bitmap
bitmap
,
Exception
e
,
int
errorCode
)
{
LoganManager
.
w_printer
(
TAG
,
"當前"
+
ids
+
"執行下一個printErrorProcess"
);
bitmaps
.
remove
(
bitmap
);
prjIds
.
remove
(
ids
);
PrinterFlowProxy
.
newInstance
().
dispatchConnectionError
(
e
);
...
...
@@ -421,6 +434,7 @@ public class EpsonPrint implements ReceiveListener {
}
private
void
updatePrintState
(
String
ids
,
int
code
)
{
LoganManager
.
w_printer
(
TAG
,
"修改打印狀態updatePrintState"
+
ids
+
"_"
+
code
+
"回調接口:"
+
onPrjPrintResultListener
);
if
(
onPrjPrintResultListener
!=
null
)
{
onPrjPrintResultListener
.
onResult
(
code
,
ids
);
}
...
...
@@ -465,11 +479,20 @@ public class EpsonPrint implements ReceiveListener {
*/
private
void
isExecutionNextTask
()
{
if
(
bitmaps
.
size
()
>
0
)
{
LoganManager
.
w_printer
(
TAG
,
"isExecutionNextTask"
+
bitmaps
.
size
());
printData
(
ipAddress
,
prjIds
.
get
(
0
),
bitmaps
.
get
(
0
));
}
else
{
LoganManager
.
w_printer
(
TAG
,
"isExecutionNextTask任務完成"
);
isPrint
=
false
;
disconnectPrinter
();
finalizeObject
();
}
}
public
void
canNextTask
()
{
//距离上一次打印超过三十秒并且状态还是打印中。
if
(
System
.
currentTimeMillis
()
-
lastInputTime
>
30
*
1000
&&
isPrint
)
{
isExecutionNextTask
();
}
}
}
component-print/src/main/java/com/joe/print/mvp/print/service/PrjService.java
View file @
dfe4f9a3
...
...
@@ -169,6 +169,7 @@ public class PrjService extends Service implements ReceiveListener {
//輪詢時,關閉打印機連接,避免一直佔用打印機socket連接
EpsonPrint
.
getInstance
().
disconnectPrinter
();
EpsonPrint
.
getInstance
().
finalizeObject
();
EpsonPrint
.
getInstance
().
canNextTask
();
//獲取prj數據
getPrjInfo
();
});
...
...
@@ -223,7 +224,7 @@ public class PrjService extends Service implements ReceiveListener {
}
}
private
String
prjJson
=
"{\"success\":true,\"sysTime\":1614581072400,\"data\":{\"K3\":[{\"id\":44419,\"printerDeviceId\":149,\"status\":2,\"orderNo\":\"233212281076117397\",\"orderTime\":2021,\"sender\":\"\",\"sendTime\":\"盡快送達 預計 15:49-16:04\",\"person\":0,\"number\":1,\"orderDetailsTime\":\"Mar 1, 2021 2:43:38 PM\",\"orderDetailsId\":12895,\"productName\":\"鬥獸場大什扒\",\"productName2\":\"\",\"productName3\":\"\",\"parentId\":0,\"type\":3,\"createTime\":1614581044514,\"productId\":27921,\"requests\":1,\"actualPrinterDeviceId\":149,\"flyPrinterDeviceId\":150,\"takeFoodCode\":\"1074\",\"billNo\":\"\",\"orderType\":2,\"userName\":\"wyh\",\"isFirstSendOrder\":1,\"quantity\":49,\"memberName\":\"\"}],\"K4\":[{\"id\":44420,\"printerDeviceId\":150,\"status\":2,\"orderNo\":\"233212281076117397\",\"orderTime\":2021,\"sender\":\"\",\"sendTime\":\"盡快送達 預計 15:49-16:04\",\"person\":0,\"number\":1,\"orderDetailsTime\":\"Mar 1, 2021 2:43:38 PM\",\"orderDetailsId\":12896,\"productName\":\"芝士焗龍蝦\",\"productName2\":\"\",\"productName3\":\"\",\"parentId\":0,\"type\":3,\"createTime\":1614581044521,\"productId\":27926,\"requests\":1,\"actualPrinterDeviceId\":150,\"takeFoodCode\":\"1074\",\"billNo\":\"\",\"orderType\":2,\"userName\":\"wyh\",\"isFirstSendOrder\":1,\"quantity\":50,\"memberName\":\"
\"}]}}\n"
;
// private String prjJson = "{\"success\":true,\"sysTime\":1614581072400,\"data\":{\"K2\":[{\"id\":92701,\"printerDeviceId\":65,\"status\":2,\"tableName\":\"2\",\"orderNo\":\"0020\",\"orderTime\":2021,\"person\":2,\"number\":1,\"orderDetailsTime\":\"Mar 27, 2021 11:43:57 AM\",\"orderDetailsId\":59507759,\"productName\":\"海家酸菜魚 (辣)K2\",\"productName2\":\"\",\"productName3\":\"\",\"parentId\":0,\"type\":3,\"createTime\":1616816636920,\"productId\":63323,\"requests\":1,\"actualPrinterDeviceId\":65,\"orderType\":1,\"isFirstSendOrder\":2,\"quantity\":89,\"memberName\":\"BARRY1\"},{\"id\":92702,\"printerDeviceId\":65,\"status\":3,\"tableName\":\"2\",\"orderNo\":\"0020\",\"orderTime\":2021,\"person\":2,\"number\":1,\"orderDetailsTime\":\"Mar 27, 2021 11:43:57 AM\",\"orderDetailsId\":59507760,\"productName\":\"蓮藕\",\"parentId\":59507759,\"type\":4,\"createTime\":1616816636922,\"productId\":29923,\"requests\":1,\"actualPrinterDeviceId\":65,\"orderType\":1,\"isFirstSendOrder\":2,\"quantity\":89,\"memberName\":\"BARRY1\"},{\"id\":92703,\"printerDeviceId\":65,\"status\":3,\"tableName\":\"2\",\"orderNo\":\"0020\",\"orderTime\":2021,\"person\":2,\"number\":1,\"orderDetailsTime\":\"Mar 27, 2021 11:43:57 AM\",\"orderDetailsId\":59507761,\"productName\":\"腐竹\",\"parentId\":59507759,\"type\":4,\"createTime\":1616816636928,\"productId\":29928,\"requests\":1,\"actualPrinterDeviceId\":65,\"orderType\":1,\"isFirstSendOrder\":2,\"quantity\":89,\"memberName\":\"BARRY1\"},{\"id\":92704,\"printerDeviceId\":65,\"status\":3,\"tableName\":\"2\",\"orderNo\":\"0020\",\"orderTime\":2021,\"person\":2,\"number\":1,\"orderDetailsTime\":\"Mar 27, 2021 11:43:57 AM\",\"orderDetailsId\":59507762,\"productName\":\"木耳\",\"parentId\":59507759,\"type\":4,\"createTime\":1616816636934,\"productId\":29924,\"requests\":1,\"actualPrinterDeviceId\":65,\"orderType\":1,\"isFirstSendOrder\":2,\"quantity\":89,\"memberName\":\"BARRY1\"},{\"id\":92705,\"printerDeviceId\":65,\"status\":3,\"tableName\":\"2\",\"orderNo\":\"0020\",\"orderTime\":2021,\"person\":2,\"number\":1,\"orderDetailsTime\":\"Mar 27, 2021 11:43:57 AM\",\"orderDetailsId\":59507763,\"productName\":\"豆乾\",\"parentId\":59507759,\"type\":4,\"createTime\":1616816636939,\"productId\":29929,\"requests\":1,\"actualPrinterDeviceId\":65,\"orderType\":1,\"isFirstSendOrder\":2,\"quantity\":89,\"memberName\":\"BARRY1
\"}]}}\n";
private
void
newPrint
(
String
json
)
{
Map
<
String
,
List
<
PrjBean
>>
listMap
=
new
HashMap
<>();
...
...
component-print/src/main/java/com/joe/print/mvp/print/utils/MyPrintUtils.java
View file @
dfe4f9a3
...
...
@@ -112,18 +112,28 @@ public class MyPrintUtils {
if
(
defaultPrint
.
getFoodIsBold
()
==
0
)
{
defaultPrint
.
setFoodIsBold
(
printCurrencyBean
.
getFoodIsBold
());
}
if
(
PrinterDeviceBean
.
DEFAULT_FONT_SIZE
.
equals
(
defaultPrint
.
getFoodFont
()))
{
if
(
PrinterDeviceBean
.
DEFAULT_FONT_SIZE
.
equals
(
defaultPrint
.
getFoodFont
())
||
PrinterDeviceBean
.
PRESET
.
equals
(
defaultPrint
.
getFoodFont
()))
{
if
(
PrinterDeviceBean
.
PRESET
.
equals
(
printCurrencyBean
.
getFoodFont
()))
{
defaultPrint
.
setFoodFont
(
"18"
);
}
else
{
defaultPrint
.
setFoodFont
(
printCurrencyBean
.
getFoodFont
());
}
}
if
(
defaultPrint
.
getFoodIsItalic
()
==
0
)
{
defaultPrint
.
setFoodIsItalic
(
printCurrencyBean
.
getFoodIsItalic
());
}
if
(
defaultPrint
.
getModifierIsBold
()
==
0
)
{
defaultPrint
.
setModifierIsBold
(
printCurrencyBean
.
getModifierIsBold
());
}
if
(
PrinterDeviceBean
.
DEFAULT_FONT_SIZE
.
equals
(
defaultPrint
.
getModifierFont
()))
{
if
(
PrinterDeviceBean
.
DEFAULT_FONT_SIZE
.
equals
(
defaultPrint
.
getModifierFont
())
||
PrinterDeviceBean
.
PRESET
.
equals
(
defaultPrint
.
getModifierFont
()))
{
if
(
PrinterDeviceBean
.
PRESET
.
equals
(
printCurrencyBean
.
getModifierFont
()))
{
defaultPrint
.
setModifierFont
(
"16"
);
}
else
{
defaultPrint
.
setModifierFont
(
printCurrencyBean
.
getModifierFont
());
}
}
if
(
defaultPrint
.
getModifierIsItalic
()
==
0
)
{
defaultPrint
.
setModifierIsItalic
(
printCurrencyBean
.
getModifierIsItalic
());
}
...
...
@@ -134,10 +144,12 @@ public class MyPrintUtils {
if
(
printCurrencyBean
==
null
)
{
// 如果沒有預設,那麼判斷打印機字體大小是不是設置為預設
// 如果是預設,那麼手動給設置食品字體大小,不然打印不出來食品
if
(
PrinterDeviceBean
.
DEFAULT_FONT_SIZE
.
equals
(
defaultPrint
.
getFoodFont
()))
{
if
(
PrinterDeviceBean
.
DEFAULT_FONT_SIZE
.
equals
(
defaultPrint
.
getFoodFont
())
||
PrinterDeviceBean
.
PRESET
.
equals
(
defaultPrint
.
getFoodFont
()))
{
defaultPrint
.
setFoodFont
(
"18"
);
}
if
(
PrinterDeviceBean
.
DEFAULT_FONT_SIZE
.
equals
(
defaultPrint
.
getModifierFont
()))
{
if
(
PrinterDeviceBean
.
DEFAULT_FONT_SIZE
.
equals
(
defaultPrint
.
getModifierFont
())
||
PrinterDeviceBean
.
PRESET
.
equals
(
defaultPrint
.
getModifierFont
()))
{
defaultPrint
.
setModifierFont
(
"16"
);
}
}
...
...
component-supply-chain/build.gradle
View file @
dfe4f9a3
...
...
@@ -11,6 +11,9 @@ android {
lintOptions
{
abortOnError
false
}
dataBinding
{
enabled
true
}
defaultConfig
{
if
(
project
.
ext
.
runAsApp
)
{
applicationId
"com.gingersoft.supply_chain"
...
...
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/bean/BuyIngredientsBean.java
0 → 100644
View file @
dfe4f9a3
package
com
.
gingersoft
.
supply_chain
.
mvp
.
bean
;
import
java.util.List
;
/**
* @author 宇航.
* User: admin
* Date: 2021/3/30
* Time: 10:19
* Use: 食材列表展示數據
*/
public
class
BuyIngredientsBean
{
/**
* 分類id
*/
public
int
id
;
/**
* 分類名
*/
public
String
categoryName
;
/**
* 分類的id
*/
public
int
parentId
;
/**
* 食材信息
*/
public
List
<
PurchaseFoodBean
>
purchaseFoodList
;
}
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/bean/GroupStructure.java
0 → 100644
View file @
dfe4f9a3
package
com
.
gingersoft
.
supply_chain
.
mvp
.
bean
;
/**
* 这个类是用来记录分组列表中组的结构的。
* 通过GroupStructure记录每个组是否有头部,是否有尾部和子项的数量。从而能方便的计算
* 列表的长度和每个组的组头、组尾和子项在列表中的位置。
*/
public
class
GroupStructure
{
private
boolean
hasHeader
;
private
boolean
hasFooter
;
private
int
childrenCount
;
public
GroupStructure
(
boolean
hasHeader
,
boolean
hasFooter
,
int
childrenCount
)
{
this
.
hasHeader
=
hasHeader
;
this
.
hasFooter
=
hasFooter
;
this
.
childrenCount
=
childrenCount
;
}
public
boolean
hasHeader
()
{
return
hasHeader
;
}
public
void
setHasHeader
(
boolean
hasHeader
)
{
this
.
hasHeader
=
hasHeader
;
}
public
boolean
hasFooter
()
{
return
hasFooter
;
}
public
void
setHasFooter
(
boolean
hasFooter
)
{
this
.
hasFooter
=
hasFooter
;
}
public
int
getChildrenCount
()
{
return
childrenCount
;
}
public
void
setChildrenCount
(
int
childrenCount
)
{
this
.
childrenCount
=
childrenCount
;
}
}
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/bean/OrderWareHouseBean.java
View file @
dfe4f9a3
...
...
@@ -15,10 +15,9 @@ import lombok.Data;
public
class
OrderWareHouseBean
{
private
int
status
;
private
int
orderId
;
private
List
<
String
>
encodeFoodNos
;
private
PurchaseWarehousingOrder
purchaseWarehousingOrder
;
private
List
<
PurchaseWarehousingOrderDetail
>
purchaseWarehousingOrderDetailsTOS
;
@Data
public
static
class
PurchaseWarehousingOrder
{
/**
...
...
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/bean/PurchaseConsumeSnBean.java
View file @
dfe4f9a3
...
...
@@ -16,13 +16,15 @@ public class PurchaseConsumeSnBean {
public
int
consumeQuantity
;
public
int
purchaseConsumeReasonId
;
public
String
remarks
;
public
List
<
PurchaseFoodEncodeSn
>
purchaseFoodEncodeSn
;
public
static
class
PurchaseFoodEncodeSn
{
public
PurchaseFoodEncodeSn
(
String
encodeSnNo
)
{
this
.
encodeSnNo
=
encodeSnNo
;
}
public
String
encodeSnNo
;
}
// public String encodeFoodNos;
public
List
<
String
>
encodeFoodNos
;
// public List<PurchaseFoodEncodeSn> purchaseFoodEncodeSn;
//
// public static class PurchaseFoodEncodeSn {
// public PurchaseFoodEncodeSn(String encodeSnNo) {
// this.encodeSnNo = encodeSnNo;
// }
//
// public String encodeSnNo;
// }
}
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/bean/PurchaseFoodEncodeSn.java
View file @
dfe4f9a3
package
com
.
gingersoft
.
supply_chain
.
mvp
.
bean
;
import
java.io.Serializable
;
import
java.util.Objects
;
/**
* @author 宇航.
...
...
@@ -33,10 +34,18 @@ public class PurchaseFoodEncodeSn implements Serializable {
* 是否新增
*/
public
boolean
newAdd
=
false
;
/**
* 1未消耗
*/
public
int
status
=
1
;
public
PurchaseFoodEncodeSn
()
{
}
public
PurchaseFoodEncodeSn
(
String
encodeSnNo
)
{
this
.
encodeSnNo
=
encodeSnNo
;
}
public
PurchaseFoodEncodeSn
(
String
encodeFoodNo
,
String
encodeOrderNo
,
String
encodeSnNo
)
{
this
.
encodeFoodNo
=
encodeFoodNo
;
this
.
encodeOrderNo
=
encodeOrderNo
;
...
...
@@ -66,4 +75,32 @@ public class PurchaseFoodEncodeSn implements Serializable {
public
void
setEncodeSnNo
(
String
encodeSnNo
)
{
this
.
encodeSnNo
=
encodeSnNo
;
}
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
{
return
true
;
}
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
{
return
false
;
}
PurchaseFoodEncodeSn
that
=
(
PurchaseFoodEncodeSn
)
o
;
return
createTime
==
that
.
createTime
&&
updateTime
==
that
.
updateTime
&&
createUid
==
that
.
createUid
&&
updateUid
==
that
.
updateUid
&&
newAdd
==
that
.
newAdd
&&
status
==
that
.
status
&&
Objects
.
equals
(
encodeFoodNo
,
that
.
encodeFoodNo
)
&&
Objects
.
equals
(
encodeOrderNo
,
that
.
encodeOrderNo
)
&&
Objects
.
equals
(
encodeSnNo
,
that
.
encodeSnNo
)
&&
Objects
.
equals
(
id
,
that
.
id
)
&&
Objects
.
equals
(
userName
,
that
.
userName
);
}
@Override
public
int
hashCode
()
{
return
Objects
.
hash
(
encodeFoodNo
,
encodeOrderNo
,
encodeSnNo
,
id
,
createTime
,
updateTime
,
createUid
,
updateUid
,
userName
,
newAdd
,
status
);
}
}
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/content/Constant.java
View file @
dfe4f9a3
...
...
@@ -35,6 +35,10 @@ public class Constant {
* 上傳圖片類型:訂單收貨圖
*/
public
static
final
int
UPLOAD_PIC_TYPE_ORDER
=
2
;
/**
* 逗號分隔符
*/
public
static
final
String
COMMA_SEPARATED
=
","
;
public
static
final
String
GET_INFO_ERROR
=
"數據獲取失敗,請稍候再試"
;
public
static
final
String
INFO_SYNTAX_ERROR
=
"數據解析失敗,請聯繫開發人員"
;
...
...
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/contract/BuyIngredientsContract.java
View file @
dfe4f9a3
...
...
@@ -2,6 +2,7 @@ package com.gingersoft.supply_chain.mvp.contract;
import
com.gingersoft.gsa.cloud.common.bean.BaseResult
;
import
com.gingersoft.gsa.cloud.ui.bean.view.CategoryBean
;
import
com.gingersoft.supply_chain.mvp.bean.BuyIngredientsBean
;
import
com.gingersoft.supply_chain.mvp.bean.FoodByCategoryResultBean
;
import
com.gingersoft.supply_chain.mvp.bean.FoodListInfoBean
;
import
com.gingersoft.supply_chain.mvp.bean.OrderCategoryBean
;
...
...
@@ -52,7 +53,7 @@ public interface BuyIngredientsContract {
* 加載食品
* @param food
*/
void
loadFood
(
int
categoryId
,
List
<
QMUISection
<
CategoryBean
,
PurchaseFoodBean
>>
food
);
void
loadFood
(
List
<
BuyIngredientsBean
>
buyIngredientsBeans
);
}
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
...
...
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/contract/OrderDetailsContract.java
View file @
dfe4f9a3
...
...
@@ -34,7 +34,9 @@ public interface OrderDetailsContract {
void
buyAgain
();
void
querySnCodeSuccess
(
int
position
,
PurchaseOrderDetailsBean
.
PurchaseOrderDetailsInfoVosBean
infoVosBean
);
void
nextFood
();
void
querySnCodeSuccess
(
int
position
,
PurchaseOrderDetailsBean
.
PurchaseOrderDetailsInfoVosBean
infoVosBean
,
boolean
singerFood
);
}
//Model层定义接口,外部只需关心Model返回的数据,无需关心内部细节,即是否使用缓存
...
...
@@ -62,5 +64,13 @@ public interface OrderDetailsContract {
* @return
*/
Observable
<
BaseResult
>
buyAgainByFoodIds
(
Map
<
String
,
Object
>
map
);
/**
* 刪除sn碼
* @param map
* @return
*/
Observable
<
BaseResult
>
deleteSnCode
(
Map
<
String
,
Object
>
map
);
}
}
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/contract/WarehouseDetailsContract.java
View file @
dfe4f9a3
...
...
@@ -67,7 +67,7 @@ public interface WarehouseDetailsContract {
* @param consumeReasonDesc 消耗原因
* @param consumptionNum 消耗数量
*/
void
printConsumeOrder
(
String
consumeReasonDesc
,
int
consumptionNum
);
void
printConsumeOrder
(
List
<
String
>
snCodes
,
String
consumeReasonDesc
,
int
consumptionNum
);
/**
* 跳转到sn码页面
...
...
@@ -98,9 +98,14 @@ public interface WarehouseDetailsContract {
* 獲取庫存數量
*/
Observable
<
BaseResult
>
getWarehousingNum
(
Map
<
String
,
Object
>
map
);
/**
* 獲取庫存中的Sn
* @param foodNo 食材編號
*/
Observable
<
BaseResult
>
queryInStockSnCodes
(
String
foodNo
);
/**
* 獲取Sn列表
* 獲取
出入庫流水的
Sn列表
*/
Observable
<
BaseResult
>
querySnCodeList
(
Map
<
String
,
Object
>
map
);
...
...
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/model/OrderDetailsModel.java
View file @
dfe4f9a3
...
...
@@ -82,4 +82,9 @@ public class OrderDetailsModel extends BaseModel implements OrderDetailsContract
public
Observable
<
BaseResult
>
buyAgainByFoodIds
(
Map
<
String
,
Object
>
map
)
{
return
mRepositoryManager
.
obtainRetrofitService
(
SupplierServer
.
class
).
buyAgainByFoodIds
(
map
);
}
@Override
public
Observable
<
BaseResult
>
deleteSnCode
(
Map
<
String
,
Object
>
map
)
{
return
mRepositoryManager
.
obtainRetrofitService
(
SupplierServer
.
class
).
deleteSnCode
(
map
);
}
}
\ No newline at end of file
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/model/WarehouseDetailsModel.java
View file @
dfe4f9a3
...
...
@@ -77,6 +77,11 @@ public class WarehouseDetailsModel extends BaseModel implements WarehouseDetails
}
@Override
public
Observable
<
BaseResult
>
queryInStockSnCodes
(
String
foodNo
)
{
return
mRepositoryManager
.
obtainRetrofitService
(
SupplierServer
.
class
).
queryInStockSnCodes
(
foodNo
);
}
@Override
public
Observable
<
BaseResult
>
querySnCodeList
(
Map
<
String
,
Object
>
map
)
{
return
mRepositoryManager
.
obtainRetrofitService
(
SupplierServer
.
class
).
querySnCodeList
(
map
);
}
...
...
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/presenter/BuyIngredientsPresenter.java
View file @
dfe4f9a3
...
...
@@ -4,6 +4,7 @@ import android.app.Application;
import
com.gingersoft.gsa.cloud.common.utils.other.TextUtil
;
import
com.gingersoft.gsa.cloud.ui.bean.view.CategoryBean
;
import
com.gingersoft.supply_chain.mvp.bean.BuyIngredientsBean
;
import
com.gingersoft.supply_chain.mvp.bean.CategoryFoodTreeBean
;
import
com.gingersoft.supply_chain.mvp.bean.FoodByCategoryResultBean
;
import
com.gingersoft.supply_chain.mvp.bean.OrderCategoryBean
;
...
...
@@ -64,7 +65,8 @@ public class BuyIngredientsPresenter extends BasePresenter<BuyIngredientsContrac
*/
private
List
<
CategoryFoodTreeBean
>
categoryFoodTreeBeans
;
private
Map
<
Integer
,
List
<
QMUISection
<
CategoryBean
,
PurchaseFoodBean
>>>
foodSectionMap
=
new
HashMap
<>();
private
List
<
BuyIngredientsBean
>
buyIngredientsBeans
;
// private Map<Integer, List<QMUISection<CategoryBean, PurchaseFoodBean>>> foodSectionMap = new HashMap<>();
/**
* 是否正在加載食品中
*/
...
...
@@ -168,29 +170,29 @@ public class BuyIngredientsPresenter extends BasePresenter<BuyIngredientsContrac
public
void
getFood
(
int
parentCategoryId
)
{
List
<
QMUISection
<
CategoryBean
,
PurchaseFoodBean
>>
foodSections
=
foodSectionMap
.
get
(
parentCategoryId
);
if
(
foodSections
==
null
)
{
getFoodByCategoryId
(
parentCategoryId
);
}
else
{
mRootView
.
loadFood
(
parentCategoryId
,
foodSections
);
}
//
List<QMUISection<CategoryBean, PurchaseFoodBean>> foodSections = foodSectionMap.get(parentCategoryId);
//
if (foodSections == null) {
//
getFoodByCategoryId(parentCategoryId);
//
} else {
//
mRootView.loadFood(parentCategoryId, foodSections);
//
}
}
/**
* 根據一級分類獲取下面所有包括子分類的食品
*
* @param parentCategoryId 父分類id
*/
private
void
getFoodByCategoryId
(
int
parentCategoryId
)
{
public
void
getFoodByCategory
(
OrderCategoryBean
.
FoodCategoryTrees
categoryTrees
)
{
//先看看這個分類的食材有沒有緩存,沒有緩衝再加載
Map
<
String
,
Object
>
map
=
new
HashMap
<>(
5
);
map
.
put
(
"pageSize"
,
1000
);
map
.
put
(
"pageIndex"
,
0
);
Constant
.
addBrandId
(
map
);
Constant
.
addRestaurantId
(
map
);
map
.
put
(
"parentId"
,
parentCategoryId
);
map
.
put
(
"parentId"
,
categoryTrees
.
getId
()
);
mModel
.
getFoodByCategory
(
map
)
.
subscribeOn
(
Schedulers
.
io
())
.
doOnSubscribe
(
disposable
->
mRootView
.
showLoading
(
"獲取中..."
))
.
doOnSubscribe
(
disposable
->
mRootView
.
showLoading
(
Constant
.
GET_INFO_LOADING
))
.
subscribeOn
(
AndroidSchedulers
.
mainThread
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
doAfterNext
(
dis
->
mRootView
.
hideLoading
())
...
...
@@ -204,9 +206,9 @@ public class BuyIngredientsPresenter extends BasePresenter<BuyIngredientsContrac
savFoodToCategory
(
info
);
//這個接口是一級分類才調用,所以直接顯示所有食材,讓用戶可以滾動列表
//將食品和分類整合到一起,List<QMUISection<CategoryBean, PurchaseFoodBean>>
val
sections
=
foodToList
(
info
.
getData
());
foodSectionMap
.
put
(
parentCategoryId
,
sections
);
mRootView
.
loadFood
(
parentCategoryId
,
sections
);
//
val sections = foodToList(info.getData());
//
foodSectionMap.put(parentCategoryId, sections);
//
mRootView.loadFood(parentCategoryId, sections);
// mRootView.loadRightFoodIngredients(filterThisCategoryFood(categoryId, info.getData()));
}
else
if
(
TextUtil
.
isNotEmptyOrNullOrUndefined
(
info
.
getErrMsg
()))
{
mRootView
.
showMessage
(
info
.
getErrMsg
());
...
...
@@ -226,10 +228,10 @@ public class BuyIngredientsPresenter extends BasePresenter<BuyIngredientsContrac
public
Void
doInIOThread
(
FoodByCategoryResultBean
info
)
{
//將本次獲取到的食品存入到緩存中
for
(
CategoryFoodTreeBean
categoryFoodTreeBean
:
categoryFoodTreeBeans
)
{
if
(
categoryFoodTreeBean
.
getCategoryIds
().
contains
(
parentCategoryId
))
{
categoryFoodTreeBean
.
setFoodInfo
(
info
.
getData
());
break
;
}
//
if (categoryFoodTreeBean.getCategoryIds().contains(parentCategoryId)) {
//
categoryFoodTreeBean.setFoodInfo(info.getData());
//
break;
//
}
}
return
null
;
}
...
...
@@ -243,10 +245,12 @@ public class BuyIngredientsPresenter extends BasePresenter<BuyIngredientsContrac
*
* @return
*/
public
List
<
QMUISection
<
CategoryBean
,
PurchaseFoodBean
>>
foodToList
(
List
<
PurchaseFoodBean
>
data
)
{
public
List
<
QMUISection
<
CategoryBean
,
PurchaseFoodBean
>>
foodToList
(
OrderCategoryBean
.
FoodCategoryTrees
categoryTrees
,
List
<
PurchaseFoodBean
>
data
)
{
if
(
data
==
null
)
{
return
null
;
}
BuyIngredientsBean
buyIngredientsBean
=
new
BuyIngredientsBean
();
List
<
QMUISection
<
CategoryBean
,
PurchaseFoodBean
>>
sections
=
new
ArrayList
<>();
CategoryBean
categoryBean
=
new
CategoryBean
();
List
<
PurchaseFoodBean
>
purchaseFoodBeans
=
new
ArrayList
<>();
...
...
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/presenter/FoodIngredientsPresenter.java
View file @
dfe4f9a3
...
...
@@ -130,9 +130,9 @@ public class FoodIngredientsPresenter extends BasePresenter<FoodIngredientsContr
mModel
.
getFoodIngredientsData
(
map
)
.
subscribeOn
(
Schedulers
.
io
())
.
doOnSubscribe
(
disposable
->
mRootView
.
showLoading
(
Constant
.
GET_INFO_LOADING
))
.
doAfterTerminate
(()
->
mRootView
.
hideLoading
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribeOn
(
AndroidSchedulers
.
mainThread
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
doAfterTerminate
(()
->
mRootView
.
hideLoading
())
.
compose
(
RxLifecycleUtils
.
bindToLifecycle
(
mRootView
))
.
observeOn
(
Schedulers
.
io
())
.
subscribe
(
new
ErrorHandleSubscriber
<
FoodListInfoBean
>(
mErrorHandler
)
{
...
...
@@ -229,7 +229,7 @@ public class FoodIngredientsPresenter extends BasePresenter<FoodIngredientsContr
}
mModel
.
getFoodBySupplierId
(
map
)
.
subscribeOn
(
Schedulers
.
io
())
.
doOnSubscribe
(
disposable
->
mRootView
.
showLoading
(
"獲取中..."
))
.
doOnSubscribe
(
disposable
->
mRootView
.
showLoading
(
Constant
.
GET_INFO_LOADING
))
.
subscribeOn
(
AndroidSchedulers
.
mainThread
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
doAfterTerminate
(()
->
mRootView
.
hideLoading
())
...
...
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/presenter/OrderDetailsPresenter.java
View file @
dfe4f9a3
...
...
@@ -248,8 +248,9 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
* @param purchaseOrderDetailsInfoVosBeans 選中的食品
*/
public
void
addWarehouse
(
int
state
,
String
remark
,
double
totalAmount
,
List
<
PurchaseOrderDetailsBean
.
PurchaseOrderDetailsInfoVosBean
>
purchaseOrderDetailsInfoVosBeans
)
{
List
<
OrderWareHouseBean
.
PurchaseWarehousingOrderDetail
>
purchaseWarehousingOrderDetails
=
transformWareHoses
(
purchaseOrderDetailsInfoVosBeans
);
OrderWareHouseBean
wareHouseBean
=
getWareHouseBean
(
state
,
remark
,
totalAmount
,
purchaseWarehousingOrderDetails
);
OrderWareHouseBean
wareHouseBean
=
new
OrderWareHouseBean
();
List
<
OrderWareHouseBean
.
PurchaseWarehousingOrderDetail
>
purchaseWarehousingOrderDetails
=
transformWareHoses
(
wareHouseBean
,
purchaseOrderDetailsInfoVosBeans
);
wareHouseBean
=
getWareHouseBean
(
state
,
remark
,
totalAmount
,
wareHouseBean
,
purchaseWarehousingOrderDetails
);
if
(
wareHouseBean
==
null
)
{
return
;
}
...
...
@@ -288,7 +289,7 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
Constant
.
addBrandId
(
map
);
StringBuilder
stringBuilder
=
new
StringBuilder
();
for
(
PurchaseOrderDetailsBean
.
PurchaseOrderDetailsInfoVosBean
item
:
data
)
{
stringBuilder
.
append
(
item
.
getPurchaseFoodId
()).
append
(
","
);
stringBuilder
.
append
(
item
.
getPurchaseFoodId
()).
append
(
Constant
.
COMMA_SEPARATED
);
}
map
.
put
(
"ids"
,
stringBuilder
.
substring
(
0
,
stringBuilder
.
length
()
-
1
));
mModel
.
buyAgainByFoodIds
(
map
)
...
...
@@ -325,11 +326,10 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
/**
* 生成入庫對象
*/
private
OrderWareHouseBean
getWareHouseBean
(
int
state
,
String
remark
,
double
totalAmount
,
List
<
OrderWareHouseBean
.
PurchaseWarehousingOrderDetail
>
purchaseWarehousingOrderDetails
)
{
private
OrderWareHouseBean
getWareHouseBean
(
int
state
,
String
remark
,
double
totalAmount
,
OrderWareHouseBean
orderWareHouseBean
,
List
<
OrderWareHouseBean
.
PurchaseWarehousingOrderDetail
>
purchaseWarehousingOrderDetails
)
{
if
(
purchaseWarehousingOrderDetails
==
null
)
{
return
null
;
}
OrderWareHouseBean
orderWareHouseBean
=
new
OrderWareHouseBean
();
orderWareHouseBean
.
setStatus
(
state
);
orderWareHouseBean
.
setOrderId
(
orderId
);
...
...
@@ -348,13 +348,14 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
purchaseWarehousingOrder
.
setTotalPrice
(
totalAmount
);
orderWareHouseBean
.
setPurchaseWarehousingOrder
(
purchaseWarehousingOrder
);
orderWareHouseBean
.
setPurchaseWarehousingOrderDetailsTOS
(
purchaseWarehousingOrderDetails
);
return
orderWareHouseBean
;
}
/**
* 將訂單轉換為入庫單
*/
private
List
<
OrderWareHouseBean
.
PurchaseWarehousingOrderDetail
>
transformWareHoses
(
List
<
PurchaseOrderDetailsBean
.
PurchaseOrderDetailsInfoVosBean
>
purchaseOrderDetailsInfoVosBeans
)
{
private
List
<
OrderWareHouseBean
.
PurchaseWarehousingOrderDetail
>
transformWareHoses
(
OrderWareHouseBean
wareHouseBean
,
List
<
PurchaseOrderDetailsBean
.
PurchaseOrderDetailsInfoVosBean
>
purchaseOrderDetailsInfoVosBeans
)
{
if
(
purchaseOrderDetailsInfoVosBeans
==
null
||
purchaseOrderDetailsInfoVosBeans
.
size
()
<=
0
)
{
mRootView
.
showMessage
(
NULL_INFO_ERROR
);
return
null
;
...
...
@@ -380,18 +381,19 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
purchaseWarehousingOrderDetail
.
setPurchaseWarehousingUnit
(
wareHousingUnitBean
);
//sn碼
List
<
PurchaseFoodEncodeSn
>
snList
=
null
;
// StringBuilder snCode = new StringBuilder()
;
List
<
String
>
snCodes
=
null
;
if
(
purchaseOrderDetailsInfoVosBean
.
getPurchaseFoodEncodeSns
()
!=
null
)
{
snList
=
new
ArrayList
<>();
snCodes
=
new
ArrayList
<>();
//只遍歷出新增的
for
(
PurchaseFoodEncodeSn
purchaseFoodEncodeSn
:
purchaseOrderDetailsInfoVosBean
.
getPurchaseFoodEncodeSns
())
{
if
(
purchaseFoodEncodeSn
.
newAdd
)
{
snList
.
add
(
purchaseFoodEncodeSn
);
// snCode.append(purchaseFoodEncodeSn.getEncodeSnNo()).append(","
);
snCodes
.
add
(
purchaseFoodEncodeSn
.
getEncodeSnNo
()
);
}
}
// snCode.substring(0, snCode.length() - 1);
}
wareHouseBean
.
setEncodeFoodNos
(
snCodes
);
purchaseWarehousingOrderDetail
.
setPurchaseFoodEncodeSn
(
snList
);
purchaseWarehousingOrderDetails
.
add
(
purchaseWarehousingOrderDetail
);
}
...
...
@@ -426,9 +428,53 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
}
/**
* 是否全是待收货食材
*
* @param data 食材信息
* @return
*/
public
boolean
allWaitReceived
(
List
<
PurchaseOrderDetailsBean
.
PurchaseOrderDetailsInfoVosBean
>
data
)
{
if
(
data
!=
null
)
{
for
(
PurchaseOrderDetailsBean
.
PurchaseOrderDetailsInfoVosBean
datum
:
data
)
{
if
(
datum
.
getStatus
()
!=
PurchaseOrderDetailsBean
.
WAIT_RECEIVED
)
{
return
false
;
}
}
return
true
;
}
return
true
;
}
/**
* 刪除Sn碼
*/
public
void
deleteSn
(
String
enCodeOrderNo
,
String
encodeFoodNo
,
String
encodeSnNo
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>(
3
);
map
.
put
(
"encodeOrderNo"
,
enCodeOrderNo
);
map
.
put
(
"encodeFoodNo"
,
encodeFoodNo
);
map
.
put
(
"encodeSnNo"
,
encodeSnNo
);
mModel
.
deleteSnCode
(
map
)
.
subscribeOn
(
Schedulers
.
io
())
.
doOnSubscribe
(
disposable
->
mRootView
.
showLoading
(
Constant
.
DELETE_LOADING
))
.
subscribeOn
(
AndroidSchedulers
.
mainThread
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
doAfterTerminate
(()
->
mRootView
.
hideLoading
())
.
compose
(
RxLifecycleUtils
.
bindToLifecycle
(
mRootView
))
.
subscribe
(
new
ErrorHandleSubscriber
<
BaseResult
>(
mErrorHandler
)
{
@Override
public
void
onNext
(
@NonNull
BaseResult
info
)
{
if
(
info
.
isSuccess
())
{
mRootView
.
showMessage
(
Constant
.
DELETE_SUCCESS
);
}
}
});
}
/**
* 查詢商品sn碼
*/
public
void
querySnCodes
(
int
position
,
PurchaseOrderDetailsBean
.
PurchaseOrderDetailsInfoVosBean
infoVosBean
)
{
public
void
querySnCodes
(
int
position
,
PurchaseOrderDetailsBean
.
PurchaseOrderDetailsInfoVosBean
infoVosBean
,
boolean
singerFood
)
{
mModel
.
querySnCodes
(
infoVosBean
.
getFoodNo
(),
infoVosBean
.
getOrderNo
())
.
subscribeOn
(
Schedulers
.
io
())
.
doOnSubscribe
(
disposable
->
mRootView
.
showLoading
(
Constant
.
QUERY_LOADING
))
...
...
@@ -441,8 +487,28 @@ public class OrderDetailsPresenter extends BasePresenter<OrderDetailsContract.Mo
public
void
onNext
(
@NonNull
BaseResult
info
)
{
if
(
info
.
isSuccess
())
{
List
<
PurchaseFoodEncodeSn
>
purchaseFoodEncodeSns
=
GsonUtils
.
jsonToList
(
info
.
getData
(),
PurchaseFoodEncodeSn
.
class
);
if
(
purchaseFoodEncodeSns
!=
null
)
{
if
(
infoVosBean
.
getPurchaseFoodEncodeSns
()
==
null
)
{
infoVosBean
.
setPurchaseFoodEncodeSns
(
purchaseFoodEncodeSns
);
mRootView
.
querySnCodeSuccess
(
position
,
infoVosBean
);
}
else
{
for
(
PurchaseFoodEncodeSn
purchaseFoodEncodeSn
:
purchaseFoodEncodeSns
)
{
if
(!
infoVosBean
.
getPurchaseFoodEncodeSns
().
contains
(
purchaseFoodEncodeSn
))
{
infoVosBean
.
getPurchaseFoodEncodeSns
().
add
(
purchaseFoodEncodeSn
);
}
}
}
}
mRootView
.
querySnCodeSuccess
(
position
,
infoVosBean
,
singerFood
);
}
else
if
(!
singerFood
)
{
mRootView
.
nextFood
();
}
}
@Override
public
void
onError
(
Throwable
t
)
{
super
.
onError
(
t
);
if
(!
singerFood
)
{
mRootView
.
nextFood
();
}
}
});
...
...
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/presenter/WareHouseListPresenter.java
View file @
dfe4f9a3
...
...
@@ -123,8 +123,8 @@ public class WareHouseListPresenter extends BasePresenter<WareHouseListContract.
}
Constant
.
addRestaurantId
(
map
);
Constant
.
addBrandId
(
map
);
Constant
.
addPageSize
(
map
);
map
.
put
(
"pageIndex"
,
pageIndex
*
Constant
.
PAGE_SIZE
);
map
.
put
(
"pageSize"
,
30
);
map
.
put
(
"pageIndex"
,
pageIndex
*
30
);
mModel
.
getWarehousing
(
map
)
.
subscribeOn
(
Schedulers
.
io
())
.
doOnSubscribe
(
disposable
->
mRootView
.
showLoading
(
Constant
.
GET_INFO_LOADING
))
...
...
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/presenter/WarehouseDetailsPresenter.java
View file @
dfe4f9a3
...
...
@@ -5,6 +5,7 @@ import android.view.View;
import
com.gingersoft.gsa.cloud.common.bean.BaseResult
;
import
com.gingersoft.gsa.cloud.common.core.restaurant.RestaurantInfoManager
;
import
com.gingersoft.gsa.cloud.common.utils.CollectionUtils
;
import
com.gingersoft.gsa.cloud.common.utils.JsonUtils
;
import
com.gingersoft.gsa.cloud.common.utils.gson.GsonUtils
;
import
com.gingersoft.gsa.cloud.common.utils.other.TextUtil
;
...
...
@@ -185,13 +186,9 @@ public class WarehouseDetailsPresenter extends BasePresenter<WarehouseDetailsCon
purchaseConsumeSnBean
.
foodNo
=
purchaseWarehousingOrderDetailsVO
.
getFoodNo
();
purchaseConsumeSnBean
.
purchaseConsumeReasonId
=
consumeReasonBean
.
getId
();
purchaseConsumeSnBean
.
remarks
=
remarks
;
if
(
snCodes
!=
null
)
{
List
<
PurchaseConsumeSnBean
.
PurchaseFoodEncodeSn
>
snList
=
new
ArrayList
<>();
for
(
String
snCode
:
snCodes
)
{
snList
.
add
(
new
PurchaseConsumeSnBean
.
PurchaseFoodEncodeSn
(
snCode
));
}
purchaseConsumeSnBean
.
consumeQuantity
=
snList
.
size
();
purchaseConsumeSnBean
.
purchaseFoodEncodeSn
=
snList
;
if
(
CollectionUtils
.
isNotNullOrEmpty
(
snCodes
))
{
purchaseConsumeSnBean
.
encodeFoodNos
=
snCodes
;
purchaseConsumeSnBean
.
consumeQuantity
=
snCodes
.
size
();
}
else
{
purchaseConsumeSnBean
.
consumeQuantity
=
consumeQuantity
;
}
...
...
@@ -208,7 +205,7 @@ public class WarehouseDetailsPresenter extends BasePresenter<WarehouseDetailsCon
public
void
onNext
(
BaseResult
baseResult
)
{
if
(
baseResult
!=
null
&&
baseResult
.
isSuccess
())
{
if
(
whetherPrint
)
{
mRootView
.
printConsumeOrder
(
consumeReasonBean
.
getDescription
(),
consumeQuantity
);
mRootView
.
printConsumeOrder
(
snCodes
,
consumeReasonBean
.
getDescription
(),
consumeQuantity
);
}
else
{
//如果需要打印,則是在打印完之後查詢,如果不需要打印,現在就查詢刷新頁面
//消耗完之後,刷新列表
...
...
@@ -258,9 +255,26 @@ public class WarehouseDetailsPresenter extends BasePresenter<WarehouseDetailsCon
});
}
public
void
querySnCodeList
(
int
foodQuantity
,
String
remark
,
String
warehousingOrderDetailsIds
)
{
/**
* 查詢sn碼記錄
*
* @param infoType 數據類型 0入庫流水SN碼,1出庫流水SN碼
* @param foodQuantity 數量
* @param remark 備註
* @param warehousingOrderDetailsIds
*/
public
void
querySnCodeList
(
int
infoType
,
int
foodQuantity
,
String
remark
,
String
warehousingOrderDetailsIds
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"warehousingOrderDetailsIds"
,
warehousingOrderDetailsIds
);
//入库SN编码查询 statesSn 0
//出库SN编码查询 statesSn 1
map
.
put
(
"statesSn"
,
infoType
);
if
(
infoType
==
0
)
{
//入庫傳這個
map
.
put
(
"warehousingEncodeSnIdList"
,
warehousingOrderDetailsIds
);
}
else
{
//出庫傳這個
map
.
put
(
"consumeEncodeSnIdList"
,
warehousingOrderDetailsIds
);
}
mModel
.
querySnCodeList
(
map
)
.
subscribeOn
(
Schedulers
.
io
())
.
doOnSubscribe
(
disposable
->
mRootView
.
showLoading
(
Constant
.
QUERY_LOADING
))
...
...
@@ -279,4 +293,30 @@ public class WarehouseDetailsPresenter extends BasePresenter<WarehouseDetailsCon
});
}
/**
* 查詢sn碼記錄
*
* @param infoType 數據類型 0入庫流水SN碼,1出庫流水SN碼
* @param foodQuantity 數量
* @param remark 備註
* @param warehousingOrderDetailsIds
*/
public
void
queryInStockSnCodes
(
int
foodQuantity
,
String
remark
,
String
foodNo
)
{
mModel
.
queryInStockSnCodes
(
foodNo
)
.
subscribeOn
(
Schedulers
.
io
())
.
doOnSubscribe
(
disposable
->
mRootView
.
showLoading
(
Constant
.
QUERY_LOADING
))
.
subscribeOn
(
AndroidSchedulers
.
mainThread
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
doAfterTerminate
(()
->
mRootView
.
hideLoading
())
.
compose
(
RxLifecycleUtils
.
bindToLifecycle
(
mRootView
))
.
subscribe
(
new
ErrorHandleSubscriber
<
BaseResult
>(
mErrorHandler
)
{
@Override
public
void
onNext
(
BaseResult
baseResult
)
{
if
(
baseResult
!=
null
&&
baseResult
.
isSuccess
())
{
List
<
PurchaseFoodEncodeSn
>
purchaseFoodEncodeSns
=
GsonUtils
.
jsonToList
(
baseResult
.
getData
(),
PurchaseFoodEncodeSn
.
class
);
mRootView
.
jumpSnList
(
foodQuantity
,
remark
,
purchaseFoodEncodeSns
);
}
}
});
}
}
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/server/SupplierServer.java
View file @
dfe4f9a3
...
...
@@ -284,9 +284,13 @@ public interface SupplierServer {
@Headers
({
"Domain-Name: ricepon-purchase"
})
@GET
(
"purchaseFood/
purchaseFoodSnl
ist"
+
RetrofitUrlManager
.
IDENTIFICATION_PATH_SIZE
+
2
)
@GET
(
"purchaseFood/
warehousingEncodeSnIdL
ist"
+
RetrofitUrlManager
.
IDENTIFICATION_PATH_SIZE
+
2
)
Observable
<
BaseResult
>
querySnCodes
(
@Query
(
"encodeFoodNo"
)
String
encodeFoodNo
,
@Query
(
"encodeOrderNo"
)
String
encodeOrderNo
);
@Headers
({
"Domain-Name: ricepon-purchase"
})
@GET
(
"purchaseFood/deletesPurchaseFoodEncodeSn"
+
RetrofitUrlManager
.
IDENTIFICATION_PATH_SIZE
+
2
)
Observable
<
BaseResult
>
deleteSnCode
(
@QueryMap
Map
<
String
,
Object
>
map
);
/**
* 再來一單,通過食材ids獲取詳細信息
*
...
...
@@ -453,8 +457,21 @@ public interface SupplierServer {
@GET
(
"purchaseConsume/get/remaining/quantity"
+
RetrofitUrlManager
.
IDENTIFICATION_PATH_SIZE
+
2
)
Observable
<
BaseResult
>
getWarehousingNum
(
@QueryMap
Map
<
String
,
Object
>
map
);
/**
* 查詢庫存的sn記錄
*/
@Headers
({
"Domain-Name: ricepon-purchase"
})
@GET
(
"purchaseFood/foodEncodeDetailsSnList"
+
RetrofitUrlManager
.
IDENTIFICATION_PATH_SIZE
+
2
)
Observable
<
BaseResult
>
queryInStockSnCodes
(
@Query
(
"encodeFoodNo"
)
String
foodNo
);
/**
* 查詢入庫流水或出庫流水的sn記錄
*
* @param map
* @return
*/
@Headers
({
"Domain-Name: ricepon-purchase"
})
@GET
(
"purchaseFood/
purchaseFoodSnl
ist"
+
RetrofitUrlManager
.
IDENTIFICATION_PATH_SIZE
+
2
)
@GET
(
"purchaseFood/
outboundInventoryEncodeSnIdL
ist"
+
RetrofitUrlManager
.
IDENTIFICATION_PATH_SIZE
+
2
)
Observable
<
BaseResult
>
querySnCodeList
(
@QueryMap
Map
<
String
,
Object
>
map
);
/**
...
...
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/ui/adapter/BaseViewHolder.java
0 → 100644
View file @
dfe4f9a3
package
com
.
gingersoft
.
supply_chain
.
mvp
.
ui
.
adapter
;
import
android.graphics.Bitmap
;
import
android.graphics.drawable.Drawable
;
import
android.util.SparseArray
;
import
android.view.View
;
import
android.widget.ImageView
;
import
android.widget.TextView
;
import
androidx.databinding.DataBindingUtil
;
import
androidx.databinding.ViewDataBinding
;
import
androidx.recyclerview.widget.RecyclerView
;
/**
* 通用的RecyclerView.ViewHolder。提供了根据viewId获取View的方法。
* 提供了对View、TextView、ImageView的常用设置方法。
*/
public
class
BaseViewHolder
extends
RecyclerView
.
ViewHolder
{
private
SparseArray
<
View
>
mViews
;
public
BaseViewHolder
(
View
itemView
)
{
super
(
itemView
);
mViews
=
new
SparseArray
<>();
}
/**
* 获取item对应的ViewDataBinding对象
*
* @param <T>
* @return
*/
public
<
T
extends
ViewDataBinding
>
T
getBinding
()
{
return
DataBindingUtil
.
getBinding
(
this
.
itemView
);
}
/**
* 根据View Id 获取对应的View
*
* @param viewId
* @param <T>
* @return
*/
public
<
T
extends
View
>
T
get
(
int
viewId
)
{
View
view
=
mViews
.
get
(
viewId
);
if
(
view
==
null
)
{
view
=
this
.
itemView
.
findViewById
(
viewId
);
mViews
.
put
(
viewId
,
view
);
}
return
(
T
)
view
;
}
//******** 提供对View、TextView、ImageView的常用设置方法 ******//
public
BaseViewHolder
setText
(
int
viewId
,
CharSequence
text
)
{
TextView
tv
=
get
(
viewId
);
tv
.
setText
(
text
);
return
this
;
}
public
BaseViewHolder
setText
(
int
viewId
,
int
textRes
)
{
TextView
tv
=
get
(
viewId
);
tv
.
setText
(
textRes
);
return
this
;
}
public
BaseViewHolder
setTextColor
(
int
viewId
,
int
textColor
)
{
TextView
view
=
get
(
viewId
);
view
.
setTextColor
(
textColor
);
return
this
;
}
public
BaseViewHolder
setTextSize
(
int
viewId
,
float
size
)
{
TextView
view
=
get
(
viewId
);
view
.
setTextSize
(
size
);
return
this
;
}
public
BaseViewHolder
setImageResource
(
int
viewId
,
int
resId
)
{
ImageView
view
=
get
(
viewId
);
view
.
setImageResource
(
resId
);
return
this
;
}
public
BaseViewHolder
setImageBitmap
(
int
viewId
,
Bitmap
bitmap
)
{
ImageView
view
=
get
(
viewId
);
view
.
setImageBitmap
(
bitmap
);
return
this
;
}
public
BaseViewHolder
setImageDrawable
(
int
viewId
,
Drawable
drawable
)
{
ImageView
view
=
get
(
viewId
);
view
.
setImageDrawable
(
drawable
);
return
this
;
}
public
BaseViewHolder
setBackgroundColor
(
int
viewId
,
int
color
)
{
View
view
=
get
(
viewId
);
view
.
setBackgroundColor
(
color
);
return
this
;
}
public
BaseViewHolder
setBackgroundRes
(
int
viewId
,
int
backgroundRes
)
{
View
view
=
get
(
viewId
);
view
.
setBackgroundResource
(
backgroundRes
);
return
this
;
}
public
BaseViewHolder
setVisible
(
int
viewId
,
boolean
visible
)
{
View
view
=
get
(
viewId
);
view
.
setVisibility
(
visible
?
View
.
VISIBLE
:
View
.
GONE
);
return
this
;
}
public
BaseViewHolder
setVisible
(
int
viewId
,
int
visible
)
{
View
view
=
get
(
viewId
);
view
.
setVisibility
(
visible
);
return
this
;
}
}
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/ui/adapter/BuyIngredientsAdapter.java
View file @
dfe4f9a3
...
...
@@ -2,29 +2,18 @@ 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
;
import
android.widget.ImageView
;
import
android.widget.LinearLayout
;
import
android.widget.TextView
;
import
androidx.annotation.NonNull
;
import
com.gingersoft.gsa.cloud.common.utils.glide.GlideUtils
;
import
com.gingersoft.gsa.cloud.common.utils.other.TextUtil
;
import
com.gingersoft.gsa.cloud.ui.bean.view.CategoryBean
;
import
com.gingersoft.gsa.cloud.ui.view.section.QDSectionHeaderView
;
import
com.gingersoft.supply_chain.R
;
import
com.gingersoft.supply_chain.R2
;
import
com.gingersoft.supply_chain.mvp.bean.BuyIngredientsBean
;
import
com.gingersoft.supply_chain.mvp.bean.PurchaseFoodBean
;
import
com.google.android.material.textfield.TextInputEditText
;
import
com.qmuiteam.qmui.alpha.QMUIAlphaTextView
;
import
com.qmuiteam.qmui.layout.QMUIButton
;
import
com.qmuiteam.qmui.widget.section.QMUIDefaultStickySectionAdapter
;
import
com.qmuiteam.qmui.widget.section.QMUISection
;
import
com.qmuiteam.qmui.widget.section.QMUIStickySectionAdapter
;
import
java.util.List
;
...
...
@@ -38,54 +27,80 @@ import butterknife.ButterKnife;
* Time: 16:18
* Use: 食材列表
*/
public
class
BuyIngredientsAdapter
extends
QMUIDefaultStickySectionAdapter
<
CategoryBean
,
PurchaseFoodBean
>
{
public
class
BuyIngredientsAdapter
extends
GroupedRecyclerViewAdapter
{
private
Context
context
;
private
List
<
BuyIngredientsBean
>
buyIngredientsBeans
;
private
boolean
isSinger
=
true
;
public
BuyIngredientsAdapter
(
Context
context
,
List
<
QMUISection
<
CategoryBean
,
PurchaseFoodBean
>>
food
)
{
this
.
context
=
context
;
setData
(
food
)
;
public
BuyIngredientsAdapter
(
Context
context
,
List
<
BuyIngredientsBean
>
buyIngredientsBeans
)
{
super
(
context
)
;
this
.
buyIngredientsBeans
=
buyIngredientsBeans
;
}
public
void
setShowSingerRow
(
boolean
showType
)
{
isSinger
=
showType
;
}
/**
* 設置減少按鈕和輸入框的顯示或隱藏
*
* @param showOrHide 顯示或隱藏
*/
private
void
setSubAndNumShow
(
ItemViewHolder
itemViewHolder
,
boolean
showOrHide
)
{
itemViewHolder
.
btnFoodOperationSub
.
setVisibility
(
showOrHide
?
View
.
GONE
:
View
.
VISIBLE
);
itemViewHolder
.
edFoodIngredientNumber
.
setVisibility
(
showOrHide
?
View
.
INVISIBLE
:
View
.
VISIBLE
);
}
@NonNull
@Override
p
rotected
HeadViewHolder
onCreateSectionHeaderViewHolder
(
@NonNull
ViewGroup
viewGroup
)
{
return
new
HeadViewHolder
(
LayoutInflater
.
from
(
viewGroup
.
getContext
()).
inflate
(
R
.
layout
.
item_buy_food_ingredient_header
,
viewGroup
,
false
)
);
p
ublic
int
getGroupCount
(
)
{
return
buyIngredientsBeans
==
null
?
0
:
buyIngredientsBeans
.
size
(
);
}
public
int
getLayoutId
()
{
if
(
isSinger
)
{
return
R
.
layout
.
item_buy_food_ingredient
;
@Override
public
int
getChildrenCount
(
int
groupPosition
)
{
BuyIngredientsBean
buyIngredientsBean
=
buyIngredientsBeans
.
get
(
groupPosition
);
return
buyIngredientsBean
.
purchaseFoodList
==
null
?
0
:
buyIngredientsBean
.
purchaseFoodList
.
size
();
}
return
R
.
layout
.
item_buy_food_ingredient_double_row
;
@Override
public
boolean
hasHeader
(
int
groupPosition
)
{
return
true
;
}
public
void
setShowSingerRow
(
boolean
showType
)
{
isSinger
=
showType
;
@Override
public
boolean
hasFooter
(
int
groupPosition
)
{
return
false
;
}
@NonNull
@Override
p
rotected
ItemViewHolder
onCreateSectionItemViewHolder
(
@NonNull
ViewGroup
viewGroup
)
{
return
new
ItemViewHolder
(
LayoutInflater
.
from
(
viewGroup
.
getContext
()).
inflate
(
getLayoutId
(),
viewGroup
,
false
))
;
p
ublic
int
getHeaderLayout
(
int
viewType
)
{
return
R
.
layout
.
item_buy_food_ingredient_header
;
}
@Override
public
int
getFooterLayout
(
int
viewType
)
{
return
0
;
}
@Override
protected
void
onBindSectionHeader
(
QMUIStickySectionAdapter
.
ViewHolder
holder
,
int
position
,
QMUISection
<
CategoryBean
,
PurchaseFoodBean
>
section
)
{
super
.
onBindSectionHeader
(
holder
,
position
,
section
);
HeadViewHolder
headViewHolder
=
(
HeadViewHolder
)
holder
;
headViewHolder
.
tvHeader
.
setText
(
section
.
getHeader
().
getCategoryName
());
public
int
getChildLayout
(
int
viewType
)
{
return
getLayoutId
();
}
@Override
protected
void
onBindSectionItem
(
QMUIStickySectionAdapter
.
ViewHolder
holder
,
int
position
,
QMUISection
<
CategoryBean
,
PurchaseFoodBean
>
section
,
int
itemIndex
)
{
super
.
onBindSectionItem
(
holder
,
position
,
section
,
itemIndex
);
ItemViewHolder
itemViewHolder
=
(
ItemViewHolder
)
holder
;
PurchaseFoodBean
purchaseFoodBean
=
section
.
getItemList
().
get
(
itemIndex
);
public
void
onBindHeaderViewHolder
(
BaseViewHolder
holder
,
int
groupPosition
)
{
holder
.
setText
(
R
.
id
.
tv_buy_food_header
,
buyIngredientsBeans
.
get
(
groupPosition
).
categoryName
);
}
@Override
public
void
onBindFooterViewHolder
(
BaseViewHolder
holder
,
int
groupPosition
)
{
}
@Override
public
void
onBindChildViewHolder
(
BaseViewHolder
holder
,
int
groupPosition
,
int
childPosition
)
{
ItemViewHolder
itemViewHolder
=
(
ItemViewHolder
)
holder
;
PurchaseFoodBean
purchaseFoodBean
=
buyIngredientsBeans
.
get
(
groupPosition
).
purchaseFoodList
.
get
(
childPosition
);
itemViewHolder
.
tvSupplierName
.
setText
(
purchaseFoodBean
.
getSupplierName
());
itemViewHolder
.
ivFoodIngredientImg
.
setImageResource
(
R
.
drawable
.
img_small_default
);
if
(
TextUtil
.
isNotEmptyOrNullOrUndefined
(
purchaseFoodBean
.
getImages
()))
{
...
...
@@ -99,7 +114,7 @@ public class BuyIngredientsAdapter extends QMUIDefaultStickySectionAdapter<Categ
}
else
{
itemViewHolder
.
tvFoodItemUnit
.
setText
(
purchaseFoodBean
.
getBasicUnitName
());
}
itemViewHolder
.
tvFoodItemPrice
.
setText
(
String
.
format
(
c
ontext
.
getString
(
R
.
string
.
amount_string
),
purchaseFoodBean
.
getUnitPrice
()));
itemViewHolder
.
tvFoodItemPrice
.
setText
(
String
.
format
(
mC
ontext
.
getString
(
R
.
string
.
amount_string
),
purchaseFoodBean
.
getUnitPrice
()));
itemViewHolder
.
edFoodIngredientNumber
.
setText
(
String
.
valueOf
(
purchaseFoodBean
.
getFoodQuantity
()),
TextView
.
BufferType
.
EDITABLE
);
//如果數量小於等於0,就不顯示減號和數量
...
...
@@ -131,27 +146,19 @@ public class BuyIngredientsAdapter extends QMUIDefaultStickySectionAdapter<Categ
});
}
/**
* 設置減少按鈕和輸入框的顯示或隱藏
*
* @param showOrHide 顯示或隱藏
*/
private
void
setSubAndNumShow
(
ItemViewHolder
itemViewHolder
,
boolean
showOrHide
)
{
itemViewHolder
.
btnFoodOperationSub
.
setVisibility
(
showOrHide
?
View
.
GONE
:
View
.
VISIBLE
);
itemViewHolder
.
edFoodIngredientNumber
.
setVisibility
(
showOrHide
?
View
.
INVISIBLE
:
View
.
VISIBLE
);
public
int
getLayoutId
()
{
if
(
isSinger
)
{
return
R
.
layout
.
item_buy_food_ingredient
;
}
public
static
class
HeadViewHolder
extends
QMUIStickySectionAdapter
.
ViewHolder
{
@BindView
(
R2
.
id
.
tv_buy_food_header
)
QMUIAlphaTextView
tvHeader
;
public
HeadViewHolder
(
View
itemView
)
{
super
(
itemView
);
ButterKnife
.
bind
(
this
,
itemView
);
return
R
.
layout
.
item_buy_food_ingredient_double_row
;
}
public
void
setData
(
List
<
BuyIngredientsBean
>
buyIngredientsBeans
)
{
this
.
buyIngredientsBeans
=
buyIngredientsBeans
;
notifyDataSetChanged
();
}
public
static
class
ItemViewHolder
extends
QMUIStickySectionAdapter
.
ViewHolder
{
public
static
class
ItemViewHolder
extends
com
.
gingersoft
.
supply_chain
.
mvp
.
ui
.
adapter
.
Base
ViewHolder
{
@BindView
(
R2
.
id
.
iv_food_ingredient_img
)
ImageView
ivFoodIngredientImg
;
@BindView
(
R2
.
id
.
tv_food_item_no
)
...
...
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/ui/adapter/GroupedRecyclerViewAdapter.java
0 → 100644
View file @
dfe4f9a3
package
com
.
gingersoft
.
supply_chain
.
mvp
.
ui
.
adapter
;
import
android.content.Context
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.view.ViewParent
;
import
android.widget.FrameLayout
;
import
androidx.databinding.DataBindingUtil
;
import
androidx.databinding.ViewDataBinding
;
import
androidx.recyclerview.widget.RecyclerView
;
import
androidx.recyclerview.widget.StaggeredGridLayoutManager
;
import
com.gingersoft.supply_chain.R
;
import
com.gingersoft.supply_chain.mvp.bean.GroupStructure
;
import
java.util.ArrayList
;
/**
* 通用的分组列表Adapter。通过它可以很方便的实现列表的分组效果。
* 这个类提供了一系列的对列表的更新、删除和插入等操作的方法。
* 使用者要使用这些方法的列表进行操作,而不要直接使用RecyclerView.Adapter的方法。
* 因为当分组列表发生变化时,需要及时更新分组列表的组结构{@link GroupedRecyclerViewAdapter#mStructures}
*/
public
abstract
class
GroupedRecyclerViewAdapter
extends
RecyclerView
.
Adapter
<
RecyclerView
.
ViewHolder
>
{
public
static
final
int
TYPE_HEADER
=
R
.
integer
.
type_header
;
public
static
final
int
TYPE_FOOTER
=
R
.
integer
.
type_footer
;
public
static
final
int
TYPE_CHILD
=
R
.
integer
.
type_child
;
public
static
final
int
TYPE_EMPTY
=
R
.
integer
.
type_empty
;
private
OnHeaderClickListener
mOnHeaderClickListener
;
private
OnFooterClickListener
mOnFooterClickListener
;
private
OnChildClickListener
mOnChildClickListener
;
private
OnHeaderLongClickListener
mOnHeaderLongClickListener
;
private
OnFooterLongClickListener
mOnFooterLongClickListener
;
private
OnChildLongClickListener
mOnChildLongClickListener
;
protected
Context
mContext
;
//保存分组列表的组结构
protected
ArrayList
<
GroupStructure
>
mStructures
=
new
ArrayList
<>();
//数据是否发生变化。如果数据发生变化,要及时更新组结构。
private
boolean
isDataChanged
;
private
int
mTempPosition
;
private
boolean
mUseBinding
;
// 是否显示空布局
private
boolean
showEmptyView
=
false
;
public
GroupedRecyclerViewAdapter
(
Context
context
)
{
this
(
context
,
false
);
}
public
GroupedRecyclerViewAdapter
(
Context
context
,
boolean
useBinding
)
{
mContext
=
context
;
mUseBinding
=
useBinding
;
registerAdapterDataObserver
(
new
GroupDataObserver
());
}
@Override
public
void
onAttachedToRecyclerView
(
RecyclerView
recyclerView
)
{
super
.
onAttachedToRecyclerView
(
recyclerView
);
structureChanged
();
}
@Override
public
void
onViewAttachedToWindow
(
RecyclerView
.
ViewHolder
holder
)
{
super
.
onViewAttachedToWindow
(
holder
);
//处理StaggeredGridLayout,保证组头和组尾占满一行。
if
(
isStaggeredGridLayout
(
holder
))
{
handleLayoutIfStaggeredGridLayout
(
holder
,
holder
.
getLayoutPosition
());
}
}
private
boolean
isStaggeredGridLayout
(
RecyclerView
.
ViewHolder
holder
)
{
ViewGroup
.
LayoutParams
layoutParams
=
holder
.
itemView
.
getLayoutParams
();
if
(
layoutParams
instanceof
StaggeredGridLayoutManager
.
LayoutParams
)
{
return
true
;
}
return
false
;
}
private
void
handleLayoutIfStaggeredGridLayout
(
RecyclerView
.
ViewHolder
holder
,
int
position
)
{
if
(
isEmptyPosition
(
position
)
||
judgeType
(
position
)
==
TYPE_HEADER
||
judgeType
(
position
)
==
TYPE_FOOTER
)
{
StaggeredGridLayoutManager
.
LayoutParams
p
=
(
StaggeredGridLayoutManager
.
LayoutParams
)
holder
.
itemView
.
getLayoutParams
();
p
.
setFullSpan
(
true
);
}
}
@Override
public
RecyclerView
.
ViewHolder
onCreateViewHolder
(
ViewGroup
parent
,
int
viewType
)
{
if
(
viewType
==
TYPE_EMPTY
)
{
return
new
BaseViewHolder
(
getEmptyView
(
parent
));
}
else
{
if
(
mUseBinding
)
{
ViewDataBinding
binding
=
DataBindingUtil
.
inflate
(
LayoutInflater
.
from
(
mContext
),
getLayoutId
(
mTempPosition
,
viewType
),
parent
,
false
);
return
new
BaseViewHolder
(
binding
.
getRoot
());
}
else
{
View
view
=
LayoutInflater
.
from
(
mContext
).
inflate
(
getLayoutId
(
mTempPosition
,
viewType
),
parent
,
false
);
return
new
BaseViewHolder
(
view
);
}
}
}
@Override
public
void
onBindViewHolder
(
final
RecyclerView
.
ViewHolder
holder
,
int
position
)
{
int
type
=
judgeType
(
position
);
final
int
groupPosition
=
getGroupPositionForPosition
(
position
);
if
(
type
==
TYPE_HEADER
)
{
if
(
mOnHeaderClickListener
!=
null
)
{
holder
.
itemView
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
if
(
mOnHeaderClickListener
!=
null
)
{
ViewParent
parent
=
holder
.
itemView
.
getParent
();
int
gPosition
=
parent
instanceof
FrameLayout
?
groupPosition
:
getGroupPositionForPosition
(
holder
.
getLayoutPosition
());
if
(
gPosition
>=
0
&&
gPosition
<
mStructures
.
size
())
{
mOnHeaderClickListener
.
onHeaderClick
(
GroupedRecyclerViewAdapter
.
this
,
(
BaseViewHolder
)
holder
,
gPosition
);
}
}
}
});
}
if
(
mOnHeaderLongClickListener
!=
null
)
{
holder
.
itemView
.
setOnLongClickListener
(
new
View
.
OnLongClickListener
()
{
@Override
public
boolean
onLongClick
(
View
v
)
{
if
(
mOnHeaderLongClickListener
!=
null
)
{
ViewParent
parent
=
holder
.
itemView
.
getParent
();
int
gPosition
=
parent
instanceof
FrameLayout
?
groupPosition
:
getGroupPositionForPosition
(
holder
.
getLayoutPosition
());
if
(
gPosition
>=
0
&&
gPosition
<
mStructures
.
size
())
{
return
mOnHeaderLongClickListener
.
onHeaderLongClick
(
GroupedRecyclerViewAdapter
.
this
,
(
BaseViewHolder
)
holder
,
gPosition
);
}
}
return
false
;
}
});
}
onBindHeaderViewHolder
((
BaseViewHolder
)
holder
,
groupPosition
);
}
else
if
(
type
==
TYPE_FOOTER
)
{
if
(
mOnFooterClickListener
!=
null
)
{
holder
.
itemView
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
if
(
mOnFooterClickListener
!=
null
)
{
int
gPosition
=
getGroupPositionForPosition
(
holder
.
getLayoutPosition
());
if
(
gPosition
>=
0
&&
gPosition
<
mStructures
.
size
())
{
mOnFooterClickListener
.
onFooterClick
(
GroupedRecyclerViewAdapter
.
this
,
(
BaseViewHolder
)
holder
,
gPosition
);
}
}
}
});
}
if
(
mOnFooterLongClickListener
!=
null
)
{
holder
.
itemView
.
setOnLongClickListener
(
new
View
.
OnLongClickListener
()
{
@Override
public
boolean
onLongClick
(
View
v
)
{
if
(
mOnFooterLongClickListener
!=
null
)
{
int
gPosition
=
getGroupPositionForPosition
(
holder
.
getLayoutPosition
());
if
(
gPosition
>=
0
&&
gPosition
<
mStructures
.
size
())
{
return
mOnFooterLongClickListener
.
onFooterLongClick
(
GroupedRecyclerViewAdapter
.
this
,
(
BaseViewHolder
)
holder
,
gPosition
);
}
}
return
false
;
}
});
}
onBindFooterViewHolder
((
BaseViewHolder
)
holder
,
groupPosition
);
}
else
if
(
type
==
TYPE_CHILD
)
{
int
childPosition
=
getChildPositionForPosition
(
groupPosition
,
position
);
if
(
mOnChildClickListener
!=
null
)
{
holder
.
itemView
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
if
(
mOnChildClickListener
!=
null
)
{
int
gPosition
=
getGroupPositionForPosition
(
holder
.
getLayoutPosition
());
int
cPosition
=
getChildPositionForPosition
(
gPosition
,
holder
.
getLayoutPosition
());
if
(
gPosition
>=
0
&&
gPosition
<
mStructures
.
size
()
&&
cPosition
>=
0
&&
cPosition
<
mStructures
.
get
(
gPosition
).
getChildrenCount
())
{
mOnChildClickListener
.
onChildClick
(
GroupedRecyclerViewAdapter
.
this
,
(
BaseViewHolder
)
holder
,
gPosition
,
cPosition
);
}
}
}
});
}
if
(
mOnChildLongClickListener
!=
null
)
{
holder
.
itemView
.
setOnLongClickListener
(
new
View
.
OnLongClickListener
()
{
@Override
public
boolean
onLongClick
(
View
v
)
{
if
(
mOnChildLongClickListener
!=
null
)
{
int
gPosition
=
getGroupPositionForPosition
(
holder
.
getLayoutPosition
());
int
cPosition
=
getChildPositionForPosition
(
gPosition
,
holder
.
getLayoutPosition
());
if
(
gPosition
>=
0
&&
gPosition
<
mStructures
.
size
()
&&
cPosition
>=
0
&&
cPosition
<
mStructures
.
get
(
gPosition
).
getChildrenCount
())
{
return
mOnChildLongClickListener
.
onChildLongClick
(
GroupedRecyclerViewAdapter
.
this
,
(
BaseViewHolder
)
holder
,
gPosition
,
cPosition
);
}
}
return
false
;
}
});
}
onBindChildViewHolder
((
BaseViewHolder
)
holder
,
groupPosition
,
childPosition
);
}
}
@Override
public
int
getItemCount
()
{
if
(
isDataChanged
)
{
structureChanged
();
}
int
count
=
count
();
if
(
count
>
0
)
{
return
count
;
}
else
if
(
showEmptyView
)
{
// 显示空布局
return
1
;
}
else
{
return
0
;
}
}
public
boolean
isEmptyPosition
(
int
position
)
{
return
position
==
0
&&
showEmptyView
&&
count
()
==
0
;
}
@Override
public
int
getItemViewType
(
int
position
)
{
if
(
isEmptyPosition
(
position
))
{
// 空布局
return
TYPE_EMPTY
;
}
mTempPosition
=
position
;
int
groupPosition
=
getGroupPositionForPosition
(
position
);
int
type
=
judgeType
(
position
);
if
(
type
==
TYPE_HEADER
)
{
return
getHeaderViewType
(
groupPosition
);
}
else
if
(
type
==
TYPE_FOOTER
)
{
return
getFooterViewType
(
groupPosition
);
}
else
if
(
type
==
TYPE_CHILD
)
{
int
childPosition
=
getChildPositionForPosition
(
groupPosition
,
position
);
return
getChildViewType
(
groupPosition
,
childPosition
);
}
return
super
.
getItemViewType
(
position
);
}
public
int
getHeaderViewType
(
int
groupPosition
)
{
return
TYPE_HEADER
;
}
public
int
getFooterViewType
(
int
groupPosition
)
{
return
TYPE_FOOTER
;
}
public
int
getChildViewType
(
int
groupPosition
,
int
childPosition
)
{
return
TYPE_CHILD
;
}
private
int
getLayoutId
(
int
position
,
int
viewType
)
{
int
type
=
judgeType
(
position
);
if
(
type
==
TYPE_HEADER
)
{
return
getHeaderLayout
(
viewType
);
}
else
if
(
type
==
TYPE_FOOTER
)
{
return
getFooterLayout
(
viewType
);
}
else
if
(
type
==
TYPE_CHILD
)
{
return
getChildLayout
(
viewType
);
}
return
0
;
}
private
int
count
()
{
return
countGroupRangeItem
(
0
,
mStructures
.
size
());
}
/**
* 判断item的type 头部 尾部 和 子项
*
* @param position
* @return
*/
public
int
judgeType
(
int
position
)
{
int
itemCount
=
0
;
int
groupCount
=
mStructures
.
size
();
for
(
int
i
=
0
;
i
<
groupCount
;
i
++)
{
GroupStructure
structure
=
mStructures
.
get
(
i
);
if
(
structure
.
hasHeader
())
{
itemCount
+=
1
;
if
(
position
<
itemCount
)
{
return
TYPE_HEADER
;
}
}
itemCount
+=
structure
.
getChildrenCount
();
if
(
position
<
itemCount
)
{
return
TYPE_CHILD
;
}
if
(
structure
.
hasFooter
())
{
itemCount
+=
1
;
if
(
position
<
itemCount
)
{
return
TYPE_FOOTER
;
}
}
}
return
TYPE_EMPTY
;
}
/**
* 重置组结构列表
*/
private
void
structureChanged
()
{
mStructures
.
clear
();
int
groupCount
=
getGroupCount
();
for
(
int
i
=
0
;
i
<
groupCount
;
i
++)
{
mStructures
.
add
(
new
GroupStructure
(
hasHeader
(
i
),
hasFooter
(
i
),
getChildrenCount
(
i
)));
}
isDataChanged
=
false
;
}
/**
* 根据下标计算position所在的组(groupPosition)
*
* @param position 下标
* @return 组下标 groupPosition
*/
public
int
getGroupPositionForPosition
(
int
position
)
{
int
count
=
0
;
int
groupCount
=
mStructures
.
size
();
for
(
int
i
=
0
;
i
<
groupCount
;
i
++)
{
count
+=
countGroupItem
(
i
);
if
(
position
<
count
)
{
return
i
;
}
}
return
-
1
;
}
/**
* 根据下标计算position在组中位置(childPosition)
*
* @param groupPosition 所在的组
* @param position 下标
* @return 子项下标 childPosition
*/
public
int
getChildPositionForPosition
(
int
groupPosition
,
int
position
)
{
if
(
groupPosition
>=
0
&&
groupPosition
<
mStructures
.
size
())
{
int
itemCount
=
countGroupRangeItem
(
0
,
groupPosition
+
1
);
GroupStructure
structure
=
mStructures
.
get
(
groupPosition
);
int
p
=
structure
.
getChildrenCount
()
-
(
itemCount
-
position
)
+
(
structure
.
hasFooter
()
?
1
:
0
);
if
(
p
>=
0
)
{
return
p
;
}
}
return
-
1
;
}
/**
* 获取一个组的开始下标,这个下标可能是组头,可能是子项(如果没有组头)或者组尾(如果这个组只有组尾)
*
* @param groupPosition 组下标
* @return
*/
public
int
getPositionForGroup
(
int
groupPosition
)
{
if
(
groupPosition
>=
0
&&
groupPosition
<
mStructures
.
size
())
{
return
countGroupRangeItem
(
0
,
groupPosition
);
}
else
{
return
-
1
;
}
}
/**
* 获取一个组的组头下标 如果该组没有组头 返回-1
*
* @param groupPosition 组下标
* @return 下标
*/
public
int
getPositionForGroupHeader
(
int
groupPosition
)
{
if
(
groupPosition
>=
0
&&
groupPosition
<
mStructures
.
size
())
{
GroupStructure
structure
=
mStructures
.
get
(
groupPosition
);
if
(!
structure
.
hasHeader
())
{
return
-
1
;
}
return
countGroupRangeItem
(
0
,
groupPosition
);
}
return
-
1
;
}
/**
* 获取一个组的组尾下标 如果该组没有组尾 返回-1
*
* @param groupPosition 组下标
* @return 下标
*/
public
int
getPositionForGroupFooter
(
int
groupPosition
)
{
if
(
groupPosition
>=
0
&&
groupPosition
<
mStructures
.
size
())
{
GroupStructure
structure
=
mStructures
.
get
(
groupPosition
);
if
(!
structure
.
hasFooter
())
{
return
-
1
;
}
return
countGroupRangeItem
(
0
,
groupPosition
+
1
)
-
1
;
}
return
-
1
;
}
/**
* 获取一个组指定的子项下标 如果没有 返回-1
*
* @param groupPosition 组下标
* @param childPosition 子项的组内下标
* @return 下标
*/
public
int
getPositionForChild
(
int
groupPosition
,
int
childPosition
)
{
if
(
groupPosition
>=
0
&&
groupPosition
<
mStructures
.
size
())
{
GroupStructure
structure
=
mStructures
.
get
(
groupPosition
);
if
(
structure
.
getChildrenCount
()
>
childPosition
)
{
int
itemCount
=
countGroupRangeItem
(
0
,
groupPosition
);
return
itemCount
+
childPosition
+
(
structure
.
hasHeader
()
?
1
:
0
);
}
}
return
-
1
;
}
/**
* 计算一个组里有多少个Item(头加尾加子项)
*
* @param groupPosition
* @return
*/
public
int
countGroupItem
(
int
groupPosition
)
{
int
itemCount
=
0
;
if
(
groupPosition
>=
0
&&
groupPosition
<
mStructures
.
size
())
{
GroupStructure
structure
=
mStructures
.
get
(
groupPosition
);
if
(
structure
.
hasHeader
())
{
itemCount
+=
1
;
}
itemCount
+=
structure
.
getChildrenCount
();
if
(
structure
.
hasFooter
())
{
itemCount
+=
1
;
}
}
return
itemCount
;
}
/**
* 计算多个组的项的总和
*
* @return
*/
public
int
countGroupRangeItem
(
int
start
,
int
count
)
{
int
itemCount
=
0
;
int
size
=
mStructures
.
size
();
for
(
int
i
=
start
;
i
<
size
&&
i
<
start
+
count
;
i
++)
{
itemCount
+=
countGroupItem
(
i
);
}
return
itemCount
;
}
/**
* 设置空布局显示。默认不显示
*
* @param isShow
*/
public
void
showEmptyView
(
boolean
isShow
)
{
if
(
isShow
!=
showEmptyView
)
{
showEmptyView
=
isShow
;
notifyDataChanged
();
}
}
public
boolean
isShowEmptyView
()
{
return
showEmptyView
;
}
//****** 刷新操作 *****//
/**
* Use {@link #notifyDataChanged()} instead.
*/
@Deprecated
public
void
changeDataSet
()
{
notifyDataChanged
();
}
/**
* 通知数据列表刷新
*/
public
void
notifyDataChanged
()
{
isDataChanged
=
true
;
notifyDataSetChanged
();
}
/**
* Use {@link #notifyGroupChanged(int)} instead.
*
* @param groupPosition
*/
@Deprecated
public
void
changeGroup
(
int
groupPosition
)
{
notifyGroupChanged
(
groupPosition
);
}
/**
* 通知一组数据刷新,包括组头,组尾和子项
*
* @param groupPosition
*/
public
void
notifyGroupChanged
(
int
groupPosition
)
{
int
index
=
getPositionForGroup
(
groupPosition
);
int
itemCount
=
countGroupItem
(
groupPosition
);
if
(
index
>=
0
&&
itemCount
>
0
)
{
notifyItemRangeChanged
(
index
,
itemCount
);
}
}
/**
* Use {@link #notifyGroupRangeChanged(int, int)} instead.
*
* @param groupPosition
* @param count
*/
@Deprecated
public
void
changeRangeGroup
(
int
groupPosition
,
int
count
)
{
notifyGroupRangeChanged
(
groupPosition
,
count
);
}
/**
* 通知多组数据刷新,包括组头,组尾和子项
*
* @param groupPosition
*/
public
void
notifyGroupRangeChanged
(
int
groupPosition
,
int
count
)
{
int
index
=
getPositionForGroup
(
groupPosition
);
int
itemCount
=
0
;
if
(
groupPosition
+
count
<=
mStructures
.
size
())
{
itemCount
=
countGroupRangeItem
(
groupPosition
,
groupPosition
+
count
);
}
else
{
itemCount
=
countGroupRangeItem
(
groupPosition
,
mStructures
.
size
());
}
if
(
index
>=
0
&&
itemCount
>
0
)
{
notifyItemRangeChanged
(
index
,
itemCount
);
}
}
/**
* Use {@link #notifyHeaderChanged(int)} instead.
*
* @param groupPosition
*/
@Deprecated
public
void
changeHeader
(
int
groupPosition
)
{
notifyHeaderChanged
(
groupPosition
);
}
/**
* 通知组头刷新
*
* @param groupPosition
*/
public
void
notifyHeaderChanged
(
int
groupPosition
)
{
int
index
=
getPositionForGroupHeader
(
groupPosition
);
if
(
index
>=
0
)
{
notifyItemChanged
(
index
);
}
}
/**
* Use {@link #notifyFooterChanged(int)} instead.
*
* @param groupPosition
*/
@Deprecated
public
void
changeFooter
(
int
groupPosition
)
{
notifyFooterChanged
(
groupPosition
);
}
/**
* 通知组尾刷新
*
* @param groupPosition
*/
public
void
notifyFooterChanged
(
int
groupPosition
)
{
int
index
=
getPositionForGroupFooter
(
groupPosition
);
if
(
index
>=
0
)
{
notifyItemChanged
(
index
);
}
}
/**
* Use {@link #notifyChildChanged(int, int)} instead.
*
* @param groupPosition
* @param childPosition
*/
@Deprecated
public
void
changeChild
(
int
groupPosition
,
int
childPosition
)
{
notifyChildChanged
(
groupPosition
,
childPosition
);
}
/**
* 通知一组里的某个子项刷新
*
* @param groupPosition
* @param childPosition
*/
public
void
notifyChildChanged
(
int
groupPosition
,
int
childPosition
)
{
int
index
=
getPositionForChild
(
groupPosition
,
childPosition
);
if
(
index
>=
0
)
{
notifyItemChanged
(
index
);
}
}
/**
* Use {@link #notifyChildRangeChanged(int, int, int)} instead.
*
* @param groupPosition
* @param childPosition
* @param count
*/
@Deprecated
public
void
changeRangeChild
(
int
groupPosition
,
int
childPosition
,
int
count
)
{
notifyChildRangeChanged
(
groupPosition
,
childPosition
,
count
);
}
/**
* 通知一组里的多个子项刷新
*
* @param groupPosition
* @param childPosition
* @param count
*/
public
void
notifyChildRangeChanged
(
int
groupPosition
,
int
childPosition
,
int
count
)
{
if
(
groupPosition
<
mStructures
.
size
())
{
int
index
=
getPositionForChild
(
groupPosition
,
childPosition
);
if
(
index
>=
0
)
{
GroupStructure
structure
=
mStructures
.
get
(
groupPosition
);
if
(
structure
.
getChildrenCount
()
>=
childPosition
+
count
)
{
notifyItemRangeChanged
(
index
,
count
);
}
else
{
notifyItemRangeChanged
(
index
,
structure
.
getChildrenCount
()
-
childPosition
);
}
}
}
}
/**
* Use {@link #notifyChildrenChanged(int)} instead.
*
* @param groupPosition
*/
@Deprecated
public
void
changeChildren
(
int
groupPosition
)
{
notifyChildrenChanged
(
groupPosition
);
}
/**
* 通知一组里的所有子项刷新
*
* @param groupPosition
*/
public
void
notifyChildrenChanged
(
int
groupPosition
)
{
if
(
groupPosition
>=
0
&&
groupPosition
<
mStructures
.
size
())
{
int
index
=
getPositionForChild
(
groupPosition
,
0
);
if
(
index
>=
0
)
{
GroupStructure
structure
=
mStructures
.
get
(
groupPosition
);
notifyItemRangeChanged
(
index
,
structure
.
getChildrenCount
());
}
}
}
//****** 删除操作 *****//
/**
* Use {@link #notifyDataRemoved()} instead.
*/
@Deprecated
public
void
removeAll
()
{
notifyDataRemoved
();
}
/**
* 通知所有数据删除
*/
public
void
notifyDataRemoved
()
{
int
count
=
countGroupRangeItem
(
0
,
mStructures
.
size
());
mStructures
.
clear
();
notifyItemRangeRemoved
(
0
,
count
);
}
/**
* Use {@link #notifyGroupRemoved(int)} instead.
*/
@Deprecated
public
void
removeGroup
(
int
groupPosition
)
{
notifyGroupRemoved
(
groupPosition
);
}
/**
* 通知一组数据删除,包括组头,组尾和子项
*
* @param groupPosition
*/
public
void
notifyGroupRemoved
(
int
groupPosition
)
{
int
index
=
getPositionForGroup
(
groupPosition
);
int
itemCount
=
countGroupItem
(
groupPosition
);
if
(
index
>=
0
&&
itemCount
>
0
)
{
mStructures
.
remove
(
groupPosition
);
notifyItemRangeRemoved
(
index
,
itemCount
);
}
}
/**
* Use {@link #notifyGroupRangeRemoved(int, int)} instead.
*/
@Deprecated
public
void
removeRangeGroup
(
int
groupPosition
,
int
count
)
{
notifyGroupRangeRemoved
(
groupPosition
,
count
);
}
/**
* 通知多组数据删除,包括组头,组尾和子项
*
* @param groupPosition
*/
public
void
notifyGroupRangeRemoved
(
int
groupPosition
,
int
count
)
{
int
index
=
getPositionForGroup
(
groupPosition
);
int
itemCount
=
0
;
if
(
groupPosition
+
count
<=
mStructures
.
size
())
{
itemCount
=
countGroupRangeItem
(
groupPosition
,
groupPosition
+
count
);
}
else
{
itemCount
=
countGroupRangeItem
(
groupPosition
,
mStructures
.
size
());
}
if
(
index
>=
0
&&
itemCount
>
0
)
{
mStructures
.
remove
(
groupPosition
);
notifyItemRangeRemoved
(
index
,
itemCount
);
}
}
/**
* Use {@link #notifyHeaderRemoved(int)} instead.
*/
@Deprecated
public
void
removeHeader
(
int
groupPosition
)
{
notifyHeaderRemoved
(
groupPosition
);
}
/**
* 通知组头删除
*
* @param groupPosition
*/
public
void
notifyHeaderRemoved
(
int
groupPosition
)
{
int
index
=
getPositionForGroupHeader
(
groupPosition
);
if
(
index
>=
0
)
{
GroupStructure
structure
=
mStructures
.
get
(
groupPosition
);
structure
.
setHasHeader
(
false
);
notifyItemRemoved
(
index
);
}
}
/**
* Use {@link #notifyFooterRemoved(int)} instead.
*
* @param groupPosition
*/
@Deprecated
public
void
removeFooter
(
int
groupPosition
)
{
notifyFooterRemoved
(
groupPosition
);
}
/**
* 通知组尾删除
*
* @param groupPosition
*/
public
void
notifyFooterRemoved
(
int
groupPosition
)
{
int
index
=
getPositionForGroupFooter
(
groupPosition
);
if
(
index
>=
0
)
{
GroupStructure
structure
=
mStructures
.
get
(
groupPosition
);
structure
.
setHasFooter
(
false
);
notifyItemRemoved
(
index
);
}
}
/**
* Use {@link #notifyChildRemoved(int, int)} instead.
*
* @param groupPosition
* @param childPosition
*/
@Deprecated
public
void
removeChild
(
int
groupPosition
,
int
childPosition
)
{
notifyChildRemoved
(
groupPosition
,
childPosition
);
}
/**
* 通知一组里的某个子项删除
*
* @param groupPosition
* @param childPosition
*/
public
void
notifyChildRemoved
(
int
groupPosition
,
int
childPosition
)
{
int
index
=
getPositionForChild
(
groupPosition
,
childPosition
);
if
(
index
>=
0
)
{
GroupStructure
structure
=
mStructures
.
get
(
groupPosition
);
structure
.
setChildrenCount
(
structure
.
getChildrenCount
()
-
1
);
notifyItemRemoved
(
index
);
}
}
/**
* Use {@link #notifyChildRangeRemoved(int, int, int)} instead.
*
* @param groupPosition
* @param childPosition
* @param count
*/
@Deprecated
public
void
removeRangeChild
(
int
groupPosition
,
int
childPosition
,
int
count
)
{
notifyChildRangeRemoved
(
groupPosition
,
childPosition
,
count
);
}
/**
* 通知一组里的多个子项删除
*
* @param groupPosition
* @param childPosition
* @param count
*/
public
void
notifyChildRangeRemoved
(
int
groupPosition
,
int
childPosition
,
int
count
)
{
if
(
groupPosition
<
mStructures
.
size
())
{
int
index
=
getPositionForChild
(
groupPosition
,
childPosition
);
if
(
index
>=
0
)
{
GroupStructure
structure
=
mStructures
.
get
(
groupPosition
);
int
childCount
=
structure
.
getChildrenCount
();
int
removeCount
=
count
;
if
(
childCount
<
childPosition
+
count
)
{
removeCount
=
childCount
-
childPosition
;
}
structure
.
setChildrenCount
(
childCount
-
removeCount
);
notifyItemRangeRemoved
(
index
,
removeCount
);
}
}
}
/**
* Use {@link #notifyChildrenRemoved(int)} instead.
*
* @param groupPosition
*/
@Deprecated
public
void
removeChildren
(
int
groupPosition
)
{
notifyChildrenRemoved
(
groupPosition
);
}
/**
* 通知一组里的所有子项删除
*
* @param groupPosition
*/
public
void
notifyChildrenRemoved
(
int
groupPosition
)
{
if
(
groupPosition
<
mStructures
.
size
())
{
int
index
=
getPositionForChild
(
groupPosition
,
0
);
if
(
index
>=
0
)
{
GroupStructure
structure
=
mStructures
.
get
(
groupPosition
);
int
itemCount
=
structure
.
getChildrenCount
();
structure
.
setChildrenCount
(
0
);
notifyItemRangeRemoved
(
index
,
itemCount
);
}
}
}
//****** 插入操作 *****//
/**
* Use {@link #notifyGroupInserted(int)} instead.
*
* @param groupPosition
*/
@Deprecated
public
void
insertGroup
(
int
groupPosition
)
{
notifyGroupInserted
(
groupPosition
);
}
/**
* 通知一组数据插入
*
* @param groupPosition
*/
public
void
notifyGroupInserted
(
int
groupPosition
)
{
GroupStructure
structure
=
new
GroupStructure
(
hasHeader
(
groupPosition
),
hasFooter
(
groupPosition
),
getChildrenCount
(
groupPosition
));
if
(
groupPosition
<
mStructures
.
size
())
{
mStructures
.
add
(
groupPosition
,
structure
);
}
else
{
mStructures
.
add
(
structure
);
groupPosition
=
mStructures
.
size
()
-
1
;
}
int
index
=
countGroupRangeItem
(
0
,
groupPosition
);
int
itemCount
=
countGroupItem
(
groupPosition
);
if
(
itemCount
>
0
)
{
notifyItemRangeInserted
(
index
,
itemCount
);
}
}
/**
* Use {@link #notifyGroupRangeInserted(int, int)} instead.
*
* @param groupPosition
* @param count
*/
@Deprecated
public
void
insertRangeGroup
(
int
groupPosition
,
int
count
)
{
notifyGroupRangeInserted
(
groupPosition
,
count
);
}
/**
* 通知多组数据插入
*
* @param groupPosition
* @param count
*/
public
void
notifyGroupRangeInserted
(
int
groupPosition
,
int
count
)
{
ArrayList
<
GroupStructure
>
list
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
GroupStructure
structure
=
new
GroupStructure
(
hasHeader
(
i
),
hasFooter
(
i
),
getChildrenCount
(
i
));
list
.
add
(
structure
);
}
if
(
groupPosition
<
mStructures
.
size
())
{
mStructures
.
addAll
(
groupPosition
,
list
);
}
else
{
mStructures
.
addAll
(
list
);
groupPosition
=
mStructures
.
size
()
-
list
.
size
();
}
int
index
=
countGroupRangeItem
(
0
,
groupPosition
);
int
itemCount
=
countGroupRangeItem
(
groupPosition
,
count
);
if
(
itemCount
>
0
)
{
notifyItemRangeInserted
(
index
,
itemCount
);
}
}
/**
* Use {@link #notifyHeaderInserted(int)} instead.
*
* @param groupPosition
*/
@Deprecated
public
void
insertHeader
(
int
groupPosition
)
{
notifyHeaderInserted
(
groupPosition
);
}
/**
* 通知组头插入
*
* @param groupPosition
*/
public
void
notifyHeaderInserted
(
int
groupPosition
)
{
if
(
groupPosition
<
mStructures
.
size
()
&&
0
>
getPositionForGroupHeader
(
groupPosition
))
{
GroupStructure
structure
=
mStructures
.
get
(
groupPosition
);
structure
.
setHasHeader
(
true
);
int
index
=
countGroupRangeItem
(
0
,
groupPosition
);
notifyItemInserted
(
index
);
}
}
/**
* Use {@link #notifyFooterInserted(int)} instead.
*
* @param groupPosition
*/
@Deprecated
public
void
insertFooter
(
int
groupPosition
)
{
notifyFooterInserted
(
groupPosition
);
}
/**
* 通知组尾插入
*
* @param groupPosition
*/
public
void
notifyFooterInserted
(
int
groupPosition
)
{
if
(
groupPosition
<
mStructures
.
size
()
&&
0
>
getPositionForGroupFooter
(
groupPosition
))
{
GroupStructure
structure
=
mStructures
.
get
(
groupPosition
);
structure
.
setHasFooter
(
true
);
int
index
=
countGroupRangeItem
(
0
,
groupPosition
+
1
);
notifyItemInserted
(
index
);
}
}
/**
* Use {@link #notifyChildInserted(int, int)} instead.
*
* @param groupPosition
* @param childPosition
*/
@Deprecated
public
void
insertChild
(
int
groupPosition
,
int
childPosition
)
{
notifyChildInserted
(
groupPosition
,
childPosition
);
}
/**
* 通知一个子项到组里插入
*
* @param groupPosition
* @param childPosition
*/
public
void
notifyChildInserted
(
int
groupPosition
,
int
childPosition
)
{
if
(
groupPosition
<
mStructures
.
size
())
{
GroupStructure
structure
=
mStructures
.
get
(
groupPosition
);
int
index
=
getPositionForChild
(
groupPosition
,
childPosition
);
if
(
index
<
0
)
{
index
=
countGroupRangeItem
(
0
,
groupPosition
);
index
+=
structure
.
hasHeader
()
?
1
:
0
;
index
+=
structure
.
getChildrenCount
();
}
structure
.
setChildrenCount
(
structure
.
getChildrenCount
()
+
1
);
notifyItemInserted
(
index
);
}
}
/**
* Use {@link #notifyChildRangeInserted(int, int, int)} instead.
*
* @param groupPosition
* @param childPosition
* @param count
*/
@Deprecated
public
void
insertRangeChild
(
int
groupPosition
,
int
childPosition
,
int
count
)
{
notifyChildRangeInserted
(
groupPosition
,
childPosition
,
count
);
}
/**
* 通知一组里的多个子项插入
*
* @param groupPosition
* @param childPosition
* @param count
*/
public
void
notifyChildRangeInserted
(
int
groupPosition
,
int
childPosition
,
int
count
)
{
if
(
groupPosition
<
mStructures
.
size
())
{
int
index
=
countGroupRangeItem
(
0
,
groupPosition
);
GroupStructure
structure
=
mStructures
.
get
(
groupPosition
);
if
(
structure
.
hasHeader
())
{
index
++;
}
if
(
childPosition
<
structure
.
getChildrenCount
())
{
index
+=
childPosition
;
}
else
{
index
+=
structure
.
getChildrenCount
();
}
if
(
count
>
0
)
{
structure
.
setChildrenCount
(
structure
.
getChildrenCount
()
+
count
);
notifyItemRangeInserted
(
index
,
count
);
}
}
}
/**
* Use {@link #notifyChildrenInserted(int)} instead.
*
* @param groupPosition
*/
@Deprecated
public
void
insertChildren
(
int
groupPosition
)
{
notifyChildrenInserted
(
groupPosition
);
}
/**
* 通知一组里的所有子项插入
*
* @param groupPosition
*/
public
void
notifyChildrenInserted
(
int
groupPosition
)
{
if
(
groupPosition
<
mStructures
.
size
())
{
int
index
=
countGroupRangeItem
(
0
,
groupPosition
);
GroupStructure
structure
=
mStructures
.
get
(
groupPosition
);
if
(
structure
.
hasHeader
())
{
index
++;
}
int
itemCount
=
getChildrenCount
(
groupPosition
);
if
(
itemCount
>
0
)
{
structure
.
setChildrenCount
(
itemCount
);
notifyItemRangeInserted
(
index
,
itemCount
);
}
}
}
//****** 设置点击事件 *****//
/**
* 设置组头点击事件
*
* @param listener
*/
public
void
setOnHeaderClickListener
(
OnHeaderClickListener
listener
)
{
mOnHeaderClickListener
=
listener
;
}
/**
* 设置组尾点击事件
*
* @param listener
*/
public
void
setOnFooterClickListener
(
OnFooterClickListener
listener
)
{
mOnFooterClickListener
=
listener
;
}
/**
* 设置子项长按事件
*
* @param listener
*/
public
void
setOnChildLongClickListener
(
OnChildLongClickListener
listener
)
{
mOnChildLongClickListener
=
listener
;
}
/**
* 设置组头长按事件
*
* @param listener
*/
public
void
setOnHeaderLongClickListener
(
OnHeaderLongClickListener
listener
)
{
mOnHeaderLongClickListener
=
listener
;
}
/**
* 设置组尾长按事件
*
* @param listener
*/
public
void
setOnFooterLongClickListener
(
OnFooterLongClickListener
listener
)
{
mOnFooterLongClickListener
=
listener
;
}
/**
* 设置子项点击事件
*
* @param listener
*/
public
void
setOnChildClickListener
(
OnChildClickListener
listener
)
{
mOnChildClickListener
=
listener
;
}
public
abstract
int
getGroupCount
();
public
abstract
int
getChildrenCount
(
int
groupPosition
);
public
abstract
boolean
hasHeader
(
int
groupPosition
);
public
abstract
boolean
hasFooter
(
int
groupPosition
);
public
abstract
int
getHeaderLayout
(
int
viewType
);
public
abstract
int
getFooterLayout
(
int
viewType
);
public
abstract
int
getChildLayout
(
int
viewType
);
public
abstract
void
onBindHeaderViewHolder
(
BaseViewHolder
holder
,
int
groupPosition
);
public
abstract
void
onBindFooterViewHolder
(
BaseViewHolder
holder
,
int
groupPosition
);
public
abstract
void
onBindChildViewHolder
(
BaseViewHolder
holder
,
int
groupPosition
,
int
childPosition
);
/**
* 获取空布局
*
* @param parent
* @return
*/
public
View
getEmptyView
(
ViewGroup
parent
)
{
// View view = LayoutInflater.from(mContext).inflate(R.layout.group_adapter_default_empty_view, parent, false);
return
null
;
}
class
GroupDataObserver
extends
RecyclerView
.
AdapterDataObserver
{
@Override
public
void
onChanged
()
{
isDataChanged
=
true
;
}
@Override
public
void
onItemRangeChanged
(
int
positionStart
,
int
itemCount
)
{
isDataChanged
=
true
;
}
@Override
public
void
onItemRangeChanged
(
int
positionStart
,
int
itemCount
,
Object
payload
)
{
onItemRangeChanged
(
positionStart
,
itemCount
);
}
@Override
public
void
onItemRangeInserted
(
int
positionStart
,
int
itemCount
)
{
isDataChanged
=
true
;
}
@Override
public
void
onItemRangeRemoved
(
int
positionStart
,
int
itemCount
)
{
isDataChanged
=
true
;
}
}
public
interface
OnHeaderClickListener
{
void
onHeaderClick
(
GroupedRecyclerViewAdapter
adapter
,
BaseViewHolder
holder
,
int
groupPosition
);
}
public
interface
OnFooterClickListener
{
void
onFooterClick
(
GroupedRecyclerViewAdapter
adapter
,
BaseViewHolder
holder
,
int
groupPosition
);
}
public
interface
OnChildClickListener
{
void
onChildClick
(
GroupedRecyclerViewAdapter
adapter
,
BaseViewHolder
holder
,
int
groupPosition
,
int
childPosition
);
}
public
interface
OnHeaderLongClickListener
{
boolean
onHeaderLongClick
(
GroupedRecyclerViewAdapter
adapter
,
BaseViewHolder
holder
,
int
groupPosition
);
}
public
interface
OnFooterLongClickListener
{
boolean
onFooterLongClick
(
GroupedRecyclerViewAdapter
adapter
,
BaseViewHolder
holder
,
int
groupPosition
);
}
public
interface
OnChildLongClickListener
{
boolean
onChildLongClick
(
GroupedRecyclerViewAdapter
adapter
,
BaseViewHolder
holder
,
int
groupPosition
,
int
childPosition
);
}
}
\ No newline at end of file
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/ui/adapter/OldBuyIngredientsAdapter.java
0 → 100644
View file @
dfe4f9a3
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
;
import
android.widget.ImageView
;
import
android.widget.LinearLayout
;
import
android.widget.TextView
;
import
androidx.annotation.NonNull
;
import
com.gingersoft.gsa.cloud.common.utils.glide.GlideUtils
;
import
com.gingersoft.gsa.cloud.common.utils.other.TextUtil
;
import
com.gingersoft.gsa.cloud.ui.bean.view.CategoryBean
;
import
com.gingersoft.gsa.cloud.ui.view.section.QDSectionHeaderView
;
import
com.gingersoft.supply_chain.R
;
import
com.gingersoft.supply_chain.R2
;
import
com.gingersoft.supply_chain.mvp.bean.PurchaseFoodBean
;
import
com.google.android.material.textfield.TextInputEditText
;
import
com.qmuiteam.qmui.alpha.QMUIAlphaTextView
;
import
com.qmuiteam.qmui.layout.QMUIButton
;
import
com.qmuiteam.qmui.widget.section.QMUIDefaultStickySectionAdapter
;
import
com.qmuiteam.qmui.widget.section.QMUISection
;
import
com.qmuiteam.qmui.widget.section.QMUIStickySectionAdapter
;
import
java.util.List
;
import
butterknife.BindView
;
import
butterknife.ButterKnife
;
/**
* @author 宇航.
* User: admin
* Date: 2021/3/11
* Time: 16:18
* Use: 食材列表
*/
public
class
OldBuyIngredientsAdapter
extends
QMUIDefaultStickySectionAdapter
<
CategoryBean
,
PurchaseFoodBean
>
{
private
Context
context
;
private
boolean
isSinger
=
true
;
public
OldBuyIngredientsAdapter
(
Context
context
,
List
<
QMUISection
<
CategoryBean
,
PurchaseFoodBean
>>
food
)
{
this
.
context
=
context
;
setData
(
food
);
}
@NonNull
@Override
protected
HeadViewHolder
onCreateSectionHeaderViewHolder
(
@NonNull
ViewGroup
viewGroup
)
{
return
new
HeadViewHolder
(
LayoutInflater
.
from
(
viewGroup
.
getContext
()).
inflate
(
R
.
layout
.
item_buy_food_ingredient_header
,
viewGroup
,
false
));
}
public
int
getLayoutId
()
{
if
(
isSinger
)
{
return
R
.
layout
.
item_buy_food_ingredient
;
}
return
R
.
layout
.
item_buy_food_ingredient_double_row
;
}
public
void
setShowSingerRow
(
boolean
showType
)
{
isSinger
=
showType
;
}
@NonNull
@Override
protected
ItemViewHolder
onCreateSectionItemViewHolder
(
@NonNull
ViewGroup
viewGroup
)
{
return
new
ItemViewHolder
(
LayoutInflater
.
from
(
viewGroup
.
getContext
()).
inflate
(
getLayoutId
(),
viewGroup
,
false
));
}
@Override
protected
void
onBindSectionHeader
(
QMUIStickySectionAdapter
.
ViewHolder
holder
,
int
position
,
QMUISection
<
CategoryBean
,
PurchaseFoodBean
>
section
)
{
super
.
onBindSectionHeader
(
holder
,
position
,
section
);
HeadViewHolder
headViewHolder
=
(
HeadViewHolder
)
holder
;
headViewHolder
.
tvHeader
.
setText
(
section
.
getHeader
().
getCategoryName
());
}
@Override
protected
void
onBindSectionItem
(
QMUIStickySectionAdapter
.
ViewHolder
holder
,
int
position
,
QMUISection
<
CategoryBean
,
PurchaseFoodBean
>
section
,
int
itemIndex
)
{
super
.
onBindSectionItem
(
holder
,
position
,
section
,
itemIndex
);
ItemViewHolder
itemViewHolder
=
(
ItemViewHolder
)
holder
;
PurchaseFoodBean
purchaseFoodBean
=
section
.
getItemList
().
get
(
itemIndex
);
itemViewHolder
.
tvSupplierName
.
setText
(
purchaseFoodBean
.
getSupplierName
());
itemViewHolder
.
ivFoodIngredientImg
.
setImageResource
(
R
.
drawable
.
img_small_default
);
if
(
TextUtil
.
isNotEmptyOrNullOrUndefined
(
purchaseFoodBean
.
getImages
()))
{
GlideUtils
.
display
(
itemViewHolder
.
ivFoodIngredientImg
.
getContext
(),
itemViewHolder
.
ivFoodIngredientImg
,
purchaseFoodBean
.
getImages
());
}
itemViewHolder
.
tvFoodItemNo
.
setText
(
purchaseFoodBean
.
getFoodNo
());
itemViewHolder
.
tvFoodItemName
.
setText
(
purchaseFoodBean
.
getName
());
//如果有包裝描述就顯示包裝描述,沒有包裝描述顯示基本單位
if
(
TextUtil
.
isNotEmptyOrNullOrUndefined
(
purchaseFoodBean
.
getPackingDescription
()))
{
itemViewHolder
.
tvFoodItemUnit
.
setText
(
purchaseFoodBean
.
getPackingDescription
());
}
else
{
itemViewHolder
.
tvFoodItemUnit
.
setText
(
purchaseFoodBean
.
getBasicUnitName
());
}
itemViewHolder
.
tvFoodItemPrice
.
setText
(
String
.
format
(
context
.
getString
(
R
.
string
.
amount_string
),
purchaseFoodBean
.
getUnitPrice
()));
itemViewHolder
.
edFoodIngredientNumber
.
setText
(
String
.
valueOf
(
purchaseFoodBean
.
getFoodQuantity
()),
TextView
.
BufferType
.
EDITABLE
);
//如果數量小於等於0,就不顯示減號和數量
setSubAndNumShow
(
itemViewHolder
,
purchaseFoodBean
.
getFoodQuantity
()
<=
0
);
//編輯數量
itemViewHolder
.
btnFoodOperationSub
.
setOnClickListener
(
v
->
{
//食材數量減少
if
(
purchaseFoodBean
.
getFoodQuantity
()
>
0
)
{
purchaseFoodBean
.
setFoodQuantity
(
purchaseFoodBean
.
getFoodQuantity
()
-
1
);
itemViewHolder
.
edFoodIngredientNumber
.
setText
(
String
.
valueOf
(
purchaseFoodBean
.
getFoodQuantity
()));
}
setSubAndNumShow
(
itemViewHolder
,
purchaseFoodBean
.
getFoodQuantity
()
<=
0
);
});
itemViewHolder
.
btnFoodOperationAdd
.
setOnClickListener
(
v
->
{
//食材數量增加
purchaseFoodBean
.
setFoodQuantity
(
purchaseFoodBean
.
getFoodQuantity
()
+
1
);
itemViewHolder
.
edFoodIngredientNumber
.
setText
(
String
.
valueOf
(
purchaseFoodBean
.
getFoodQuantity
()));
setSubAndNumShow
(
itemViewHolder
,
false
);
});
//輸入框焦點監聽
itemViewHolder
.
edFoodIngredientNumber
.
setOnFocusChangeListener
((
v
,
hasFocus
)
->
{
Editable
text
=
itemViewHolder
.
edFoodIngredientNumber
.
getText
();
if
(!
hasFocus
)
{
//當失去焦點時,如果沒有食品數量了,就隱藏減號和輸入框
if
(
TextUtil
.
isEmptyOrNullOrUndefined
(
text
)
||
Integer
.
parseInt
(
text
.
toString
())
==
0
)
{
setSubAndNumShow
(
itemViewHolder
,
false
);
}
}
});
}
/**
* 設置減少按鈕和輸入框的顯示或隱藏
*
* @param showOrHide 顯示或隱藏
*/
private
void
setSubAndNumShow
(
ItemViewHolder
itemViewHolder
,
boolean
showOrHide
)
{
itemViewHolder
.
btnFoodOperationSub
.
setVisibility
(
showOrHide
?
View
.
GONE
:
View
.
VISIBLE
);
itemViewHolder
.
edFoodIngredientNumber
.
setVisibility
(
showOrHide
?
View
.
INVISIBLE
:
View
.
VISIBLE
);
}
public
static
class
HeadViewHolder
extends
QMUIStickySectionAdapter
.
ViewHolder
{
@BindView
(
R2
.
id
.
tv_buy_food_header
)
QMUIAlphaTextView
tvHeader
;
public
HeadViewHolder
(
View
itemView
)
{
super
(
itemView
);
ButterKnife
.
bind
(
this
,
itemView
);
}
}
public
static
class
ItemViewHolder
extends
QMUIStickySectionAdapter
.
ViewHolder
{
@BindView
(
R2
.
id
.
iv_food_ingredient_img
)
ImageView
ivFoodIngredientImg
;
@BindView
(
R2
.
id
.
tv_food_item_no
)
TextView
tvFoodItemNo
;
@BindView
(
R2
.
id
.
tv_food_item_supplier_name
)
TextView
tvSupplierName
;
@BindView
(
R2
.
id
.
tv_food_item_name
)
TextView
tvFoodItemName
;
@BindView
(
R2
.
id
.
tv_food_item_unit
)
TextView
tvFoodItemUnit
;
@BindView
(
R2
.
id
.
tv_food_item_price
)
TextView
tvFoodItemPrice
;
@BindView
(
R2
.
id
.
btn_food_operation_sub
)
QMUIButton
btnFoodOperationSub
;
@BindView
(
R2
.
id
.
ed_food_ingredient_number
)
TextInputEditText
edFoodIngredientNumber
;
@BindView
(
R2
.
id
.
btn_food_operation_add
)
QMUIButton
btnFoodOperationAdd
;
public
ItemViewHolder
(
View
itemView
)
{
super
(
itemView
);
ButterKnife
.
bind
(
this
,
itemView
);
}
}
}
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/ui/adapter/SnCodesAdapter.java
View file @
dfe4f9a3
...
...
@@ -35,7 +35,7 @@ public class SnCodesAdapter extends BaseQuickAdapter<PurchaseFoodEncodeSn, BaseV
viewHolder
.
setBackgroundColor
(
R
.
id
.
layout_sn_item
,
colorRes
);
setTextColor
(
viewHolder
,
getColor
(
getContext
(),
R
.
color
.
color_3c
));
viewHolder
.
setText
(
R
.
id
.
tv_serial_number
,
String
.
valueOf
(
viewHolder
.
getAdapterPosition
()));
viewHolder
.
setText
(
R
.
id
.
tv_serial_number
,
String
.
valueOf
(
viewHolder
.
getAdapterPosition
()
+
1
));
viewHolder
.
setText
(
R
.
id
.
tv_sn_code
,
String
.
valueOf
(
purchaseFoodEncodeSn
.
getEncodeSnNo
()));
viewHolder
.
setText
(
R
.
id
.
tv_operator
,
String
.
valueOf
(
purchaseFoodEncodeSn
.
userName
));
viewHolder
.
setText
(
R
.
id
.
tv_time
,
TimeUtils
.
getStringByFormat
(
purchaseFoodEncodeSn
.
updateTime
,
TimeUtils
.
DATE_FORMAT_DATE
));
...
...
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/ui/fragment/food/BuyIngredientsFragment.java
View file @
dfe4f9a3
package
com
.
gingersoft
.
supply_chain
.
mvp
.
ui
.
fragment
.
food
;
import
android.os.Bundle
;
import
android.util.Log
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
...
...
@@ -20,22 +19,23 @@ 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
;
import
com.gingersoft.supply_chain.di.component.DaggerBuyIngredientsComponent
;
import
com.gingersoft.supply_chain.mvp.bean.BuyIngredientsBean
;
import
com.gingersoft.supply_chain.mvp.bean.OrderCategoryBean
;
import
com.gingersoft.supply_chain.mvp.bean.PurchaseFoodBean
;
import
com.gingersoft.supply_chain.mvp.contract.BuyIngredientsContract
;
import
com.gingersoft.supply_chain.mvp.presenter.BuyIngredientsPresenter
;
import
com.gingersoft.supply_chain.mvp.ui.adapter.BuyIngredientsAdapter
;
import
com.gingersoft.supply_chain.mvp.ui.adapter.OldBuyIngredientsAdapter
;
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.GroupedGridLayoutManager
;
import
com.gingersoft.supply_chain.mvp.ui.widget.ShowSecondCategoryPopup
;
import
com.gingersoft.supply_chain.mvp.utils.ViewUtils
;
import
com.jess.arms.di.component.AppComponent
;
...
...
@@ -50,7 +50,6 @@ 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
;
...
...
@@ -87,11 +86,11 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien
RecyclerView
rvSecondCategory
;
private
SecondCategoryAdapter
secondCategoryAdapter
;
@BindView
(
R2
.
id
.
section_food_ingredients
)
QMUIStickySectionLayout
sectionFood
;
//
@BindView(R2.id.section_food_ingredients)
//
QMUIStickySectionLayout sectionFood;
private
BuyIngredientsAdapter
adapter
;
//
@BindView(R2.id.rv_food_ingredients)
//
RecyclerView rvFoodIngredients;
@BindView
(
R2
.
id
.
rv_food_ingredients
)
RecyclerView
rvFoodIngredients
;
@BindView
(
R2
.
id
.
srl_supplier
)
LinearLayout
srlSupplier
;
@BindView
(
R2
.
id
.
btn_new_food_ingredient
)
...
...
@@ -232,7 +231,7 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien
adapter
.
setShowSingerRow
(
isSinger
);
btnSwitchRow
.
setImageResource
(
isSinger
?
R
.
drawable
.
ic_single_row
:
R
.
drawable
.
ic_double_row
);
sectionFood
.
setAdapter
(
adapter
);
rvFoodIngredients
.
setAdapter
(
adapter
);
}
private
int
lastIndex
=
0
;
...
...
@@ -246,47 +245,17 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien
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
();
rvFoodIngredients
.
setLayoutManager
(
linearLayoutManager
);
// rvFoodIngredients.getRecyclerView().clearOnScrollListeners();
//
// rvFoodIngredients.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();
int
sectionIndex
=
adapter
.
getSectionIndex
(
firstVisibleItemPosition
);
// //手指往上滑動,獲取下一個分類數據
// //記錄當前滑動到哪個header,如果和上次不一致,頂部的分類就切換選中
// if (!mPresenter.isLoadFood()) {
...
...
@@ -308,27 +277,58 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien
// }
// }
// }
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
;
}
}
}
});
// }
// }
//
//
// @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
)
{
...
...
@@ -408,7 +408,7 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien
ViewUtils
.
moveToCenterByVertical
(
rvFirstCategory
,
position
);
loadSecondCategory
(
firstLevelCategoryAdapter
.
getData
().
get
(
position
).
getFoodCategoryTrees
());
//獲取當前分類所有食材
mPresenter
.
getFood
(
firstLevelCategoryAdapter
.
getItem
(
position
).
getId
(
));
mPresenter
.
getFood
ByCategory
(
firstLevelCategoryAdapter
.
getItem
(
position
));
});
//默認選中第0個分類
firstLevelCategoryAdapter
.
getOnItemClickListener
().
onItemClick
(
firstLevelCategoryAdapter
,
null
,
0
);
...
...
@@ -424,7 +424,7 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien
public
void
loadRightFoodIngredients
(
List
<
PurchaseFoodBean
>
purchaseFoodListVOS
)
{
// 點擊一二三級分類,都是清空當前頁面所有食材,然後顯示當前級別分類下的食材
// 滑動則是判斷底部,一直累加數據
sectionFood
.
setLayoutManager
(
new
LinearLayoutManager
(
requireContext
()));
rvFoodIngredients
.
setLayoutManager
(
new
LinearLayoutManager
(
requireContext
()));
}
@Override
...
...
@@ -460,41 +460,19 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien
/**
* 加載食品,找到這些食品最近的上一個分類,將數據添加到這個分類下面,如果沒有,就添加到最頂部
*
* @param categoryId 當前分類id
* @param food 食品
*/
@Override
public
void
loadFood
(
int
categoryId
,
List
<
QMUISection
<
CategoryBean
,
PurchaseFoodBean
>>
food
)
{
public
void
loadFood
(
List
<
BuyIngredientsBean
>
buyIngredientsBeans
)
{
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
);
adapter
=
new
BuyIngredientsAdapter
(
requireContext
(),
buyIngredientsBeans
);
rvFoodIngredients
.
setAdapter
(
adapter
);
setLayoutManager
();
// mPresenter.setLoadFood(false);
}
else
{
// if (isTailOrHead == 2) {
adapter
.
setData
(
food
);
adapter
.
setData
(
buyIngredientsBeans
);
// } else {
// List<QMUISection<CategoryBean, PurchaseFoodBean>> currentData = CollectionUtils.deepCopy(adapter.getCurrentData());
// if (isTailOrHead == 0) {
...
...
@@ -510,14 +488,8 @@ public class BuyIngredientsFragment extends BaseSupplyChainFragment<BuyIngredien
@NotNull
private
GridLayoutManager
getDoubleRowManager
()
{
val
gridLayoutManager
=
new
GridLayoutManager
(
requireContext
(),
2
);
gridLayoutManager
.
setSpanSizeLookup
(
new
GridLayoutManager
.
SpanSizeLookup
()
{
@Override
public
int
getSpanSize
(
int
position
)
{
return
adapter
.
getItemIndex
(
position
)
<
0
?
gridLayoutManager
.
getSpanCount
()
:
1
;
}
});
private
GroupedGridLayoutManager
getDoubleRowManager
()
{
val
gridLayoutManager
=
new
GroupedGridLayoutManager
(
requireContext
(),
2
,
adapter
);
return
gridLayoutManager
;
}
}
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/ui/fragment/order/OrderDetailsFragment.java
View file @
dfe4f9a3
...
...
@@ -54,6 +54,7 @@ import com.gingersoft.supply_chain.mvp.ui.fragment.BaseSupplyChainFragment;
import
com.gingersoft.supply_chain.mvp.ui.widget.ChooseUnitPopup
;
import
com.gingersoft.supply_chain.mvp.ui.widget.PurchaseListMorePopup
;
import
com.gingersoft.supply_chain.mvp.ui.widget.ScanSnPopup
;
import
com.gingersoft.supply_chain.mvp.ui.widget.ScanSnView
;
import
com.gingersoft.supply_chain.mvp.utils.SelectPicture
;
import
com.google.android.material.checkbox.MaterialCheckBox
;
import
com.jess.arms.di.component.AppComponent
;
...
...
@@ -63,6 +64,7 @@ import com.lxj.xpopup.core.BasePopupView;
import
com.lxj.xpopup.core.ImageViewerPopupView
;
import
com.lxj.xpopup.enums.PopupPosition
;
import
com.lxj.xpopup.interfaces.OnSelectListener
;
import
com.lxj.xpopup.interfaces.XPopupCallback
;
import
com.lxj.xpopup.interfaces.XPopupImageLoader
;
import
com.qmuiteam.qmui.alpha.QMUIAlphaTextView
;
import
com.qmuiteam.qmui.util.QMUIDisplayHelper
;
...
...
@@ -71,6 +73,7 @@ import com.yalantis.ucrop.UCrop;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.stream.Collectors
;
...
...
@@ -126,7 +129,11 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr
ImageAdapter
imageAdapter
;
private
int
typesOfFood
=
0
;
private
double
totalAmount
=
0
;
/**
* 記錄全選當前遍歷到的下標,因為有sn食材,需要去異步查詢
*/
private
int
currentFoodIndex
=
0
;
private
boolean
checkState
=
false
;
// private int orderState = PurchaseOrderDetailsBean.WAIT_RECEIVED;
private
final
static
String
ORDER_DETAILS_ORDER_ID
=
"orderId"
;
private
final
static
String
ORDER_STATE
=
"orderState"
;
...
...
@@ -229,6 +236,10 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr
mPresenter
.
buyAgainByFoodIds
(
orderDetailsFoodAdapter
.
getData
());
}
else
if
(
position
==
1
)
{
//刪除訂單
if
(
orderDetailsFoodAdapter
!=
null
&&
!
mPresenter
.
allWaitReceived
(
orderDetailsFoodAdapter
.
getData
()))
{
showMessage
(
"有已收货食材,不可删除订单"
);
return
;
}
AppDialog
.
getInstance
().
showWaringDialog
(
mContext
,
"是否刪除訂單"
,
(
view1
,
dialog
)
->
mPresenter
.
deleteOrder
());
}
else
if
(
position
==
2
)
{
//部分收貨
...
...
@@ -278,15 +289,12 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr
if
(
buttonView
.
isPressed
())
{
//重新計算總價
totalAmount
=
0
;
typesOfFood
=
isChecked
?
orderDetailsFoodAdapter
.
getData
().
size
()
:
0
;
typesOfFood
=
0
;
//修改所有食品的選中狀態,計算所有實付金額
for
(
PurchaseOrderDetailsBean
.
PurchaseOrderDetailsInfoVosBean
datum
:
orderDetailsFoodAdapter
.
getData
())
{
datum
.
setChecked
(
isChecked
);
if
(
isChecked
)
{
DeputyUnitBean
unit
=
datum
.
getShowUnit
();
totalAmount
=
MoneyUtil
.
sum
(
totalAmount
,
MoneyUtil
.
priceCalculation
(
unit
.
getDeputyValue
(),
unit
.
getUnitPrice
()));
}
}
currentFoodIndex
=
0
;
checkState
=
isChecked
;
//遍歷去執行全選,
checkAllForEach
();
orderDetailsFoodAdapter
.
notifyDataSetChanged
();
setTotalAmount
();
setTypesOfFood
();
...
...
@@ -294,6 +302,37 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr
});
}
private
void
checkAllForEach
()
{
int
itemCount
=
orderDetailsFoodAdapter
.
getItemCount
();
if
(
currentFoodIndex
>=
itemCount
)
{
//沒有更多食品了,判斷是否全選
cbOrderDetailsAllSelected
.
setChecked
(
typesOfFood
==
itemCount
);
setTypesOfFood
();
}
for
(
int
i
=
currentFoodIndex
;
i
<
itemCount
;
i
++)
{
PurchaseOrderDetailsBean
.
PurchaseOrderDetailsInfoVosBean
datum
=
orderDetailsFoodAdapter
.
getItem
(
i
);
//如果是sn,判斷是否需要去查詢已經保存的sn碼。
if
(
datum
.
getFoodMarkSn
()
==
PurchaseFoodBean
.
HAS_SN
&&
checkState
&&
datum
.
getStatus
()
!=
PurchaseOrderDetailsBean
.
COMPLETE_RECEIVED
)
{
isNeedQuerySn
(
orderDetailsFoodAdapter
.
getItemPosition
(
datum
),
datum
,
false
);
currentFoodIndex
=
i
;
break
;
}
else
{
datum
.
setChecked
(
checkState
);
if
(
checkState
)
{
typesOfFood
++;
DeputyUnitBean
unit
=
datum
.
getShowUnit
();
totalAmount
=
MoneyUtil
.
sum
(
totalAmount
,
MoneyUtil
.
priceCalculation
(
unit
.
getDeputyValue
(),
unit
.
getUnitPrice
()));
}
}
}
}
@Override
public
void
nextFood
()
{
currentFoodIndex
++;
checkAllForEach
();
}
@Override
public
void
uploadPicSuccess
(
String
imgUrl
)
{
if
(
imageAdapter
==
null
)
{
...
...
@@ -325,8 +364,8 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr
}
@Override
public
void
querySnCodeSuccess
(
int
position
,
PurchaseOrderDetailsBean
.
PurchaseOrderDetailsInfoVosBean
infoVosBean
)
{
showScanPopup
(
position
,
infoVosBean
);
public
void
querySnCodeSuccess
(
int
position
,
PurchaseOrderDetailsBean
.
PurchaseOrderDetailsInfoVosBean
infoVosBean
,
boolean
singerFood
)
{
showScanPopup
(
position
,
infoVosBean
,
singerFood
);
}
public
static
class
ImageLoader
implements
XPopupImageLoader
{
...
...
@@ -371,13 +410,7 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr
if
(
infoVosBean
.
isChecked
())
{
setFoodCheckState
(
adapter
,
position
,
infoVosBean
);
}
else
{
if
(
infoVosBean
.
getStatus
()
==
PurchaseOrderDetailsBean
.
WAIT_RECEIVED
)
{
//沒收過貨的
showScanPopup
(
position
,
infoVosBean
);
}
else
{
//收過貨的,需要查詢sn碼
mPresenter
.
querySnCodes
(
position
,
infoVosBean
);
}
isNeedQuerySn
(
position
,
infoVosBean
,
true
);
}
}
else
{
//不是sn食材,選中
...
...
@@ -419,50 +452,95 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr
}
/**
* 是否需要查詢sn碼
*
* @param position 下標
* @param infoVosBean 食材信息
*/
private
void
isNeedQuerySn
(
int
position
,
PurchaseOrderDetailsBean
.
PurchaseOrderDetailsInfoVosBean
infoVosBean
,
boolean
singerFood
)
{
if
(
infoVosBean
.
getStatus
()
==
PurchaseOrderDetailsBean
.
WAIT_RECEIVED
)
{
//沒收過貨的
showScanPopup
(
position
,
infoVosBean
,
singerFood
);
}
else
{
//收過貨的,需要查詢sn碼
mPresenter
.
querySnCodes
(
position
,
infoVosBean
,
singerFood
);
}
}
/**
* 顯示掃碼popupwindow
*
* @param position 下標
* @param infoVosBean 食品信息
* @param singerFood 是否是對單個食品操作
*/
private
void
showScanPopup
(
int
position
,
PurchaseOrderDetailsBean
.
PurchaseOrderDetailsInfoVosBean
infoVosBean
)
{
List
<
PurchaseFoodEncodeSn
>
purchaseFoodEncodeSns1
=
infoVosBean
.
getPurchaseFoodEncodeSns
();
List
<
String
>
snCodes
=
null
;
//將之前錄入的sn碼遍歷出來
if
(
purchaseFoodEncodeSns1
!=
null
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
N
)
{
snCodes
=
purchaseFoodEncodeSns1
.
stream
().
map
(
PurchaseFoodEncodeSn:
:
getEncodeSnNo
).
collect
(
Collectors
.
toList
());
}
else
{
snCodes
=
new
ArrayList
<>();
for
(
PurchaseFoodEncodeSn
purchaseFoodEncodeSn
:
purchaseFoodEncodeSns1
)
{
snCodes
.
add
(
purchaseFoodEncodeSn
.
getEncodeSnNo
());
private
void
showScanPopup
(
int
position
,
PurchaseOrderDetailsBean
.
PurchaseOrderDetailsInfoVosBean
infoVosBean
,
boolean
singerFood
)
{
List
<
PurchaseFoodEncodeSn
>
foodEncodeSns
=
infoVosBean
.
getPurchaseFoodEncodeSns
();
ScanSnPopup
scanSnPopup
=
new
ScanSnPopup
(
this
,
infoVosBean
.
getName
(),
CollectionUtils
.
deepCopy
(
foodEncodeSns
),
infoVosBean
.
getStatus
()
!=
PurchaseOrderDetailsBean
.
COMPLETE_RECEIVED
)
.
setOnDeleteListener
((
snCode
,
snPosition
)
->
{
if
(
foodEncodeSns
!=
null
)
{
for
(
PurchaseFoodEncodeSn
foodEncodeSn
:
foodEncodeSns
)
{
if
(
foodEncodeSn
.
getEncodeSnNo
().
equals
(
snCode
))
{
if
(!
foodEncodeSn
.
newAdd
)
{
mPresenter
.
deleteSn
(
infoVosBean
.
getOrderNo
(),
infoVosBean
.
getFoodNo
(),
foodEncodeSn
.
getEncodeSnNo
());
foodEncodeSns
.
remove
(
foodEncodeSn
);
}
return
;
}
}
}
ScanSnPopup
scanSnPopup
=
new
ScanSnPopup
(
this
,
infoVosBean
.
getName
(),
CollectionUtils
.
deepCopy
(
snCodes
));
List
<
String
>
finalSnCodes
=
snCodes
;
scanSnPopup
.
setOnScanResultListener
(
scanResult
->
{
})
.
setMinCodeSize
((
int
)
infoVosBean
.
getShowUnit
().
getDeputyValue
())
.
setOnScanResultListener
((
popup
,
scanResult
)
->
{
//當前食材infoVosBean裡面有個sn碼集合,將scanResult添加進去
if
(
scanResult
!=
null
&&
scanResult
.
size
()
>
0
)
{
List
<
PurchaseFoodEncodeSn
>
purchaseFoodEncodeSns
=
new
ArrayList
<>(
scanResult
.
size
());
int
newAddSize
=
0
;
for
(
String
s
:
scanResult
)
{
PurchaseFoodEncodeSn
purchaseFoodEncodeSn
=
new
PurchaseFoodEncodeSn
();
purchaseFoodEncodeSn
.
setEncodeFoodNo
(
infoVosBean
.
getFoodNo
());
purchaseFoodEncodeSn
.
setEncodeOrderNo
(
infoVosBean
.
getOrderNo
());
purchaseFoodEncodeSn
.
setEncodeSnNo
(
s
);
if
(
finalSnCodes
==
null
||
!
finalSnCodes
.
contains
(
s
))
{
//过滤出新增的
List
<
PurchaseFoodEncodeSn
>
newAddSnCodes
=
new
ArrayList
<>(
scanResult
.
size
());
for
(
PurchaseFoodEncodeSn
purchaseFoodEncodeSn
:
scanResult
)
{
if
(
purchaseFoodEncodeSn
.
newAdd
)
{
//判斷這個snCode是不是已經收過貨了,沒收過貨,新增的就為true
purchaseFoodEncodeSn
.
newAdd
=
true
;
PurchaseFoodEncodeSn
newSnCodeBean
=
new
PurchaseFoodEncodeSn
();
newSnCodeBean
.
setEncodeFoodNo
(
infoVosBean
.
getFoodNo
());
newSnCodeBean
.
setEncodeOrderNo
(
infoVosBean
.
getOrderNo
());
newSnCodeBean
.
setEncodeSnNo
(
purchaseFoodEncodeSn
.
getEncodeSnNo
());
newSnCodeBean
.
newAdd
=
true
;
newAddSnCodes
.
add
(
newSnCodeBean
);
}
}
if
(
CollectionUtils
.
isNotNullOrEmpty
(
foodEncodeSns
))
{
//扫描完后的所有sn和之前的sn比较,如果之前的sn没了,说明删除了,就从食品对象中移除掉
Iterator
<
PurchaseFoodEncodeSn
>
iterator
=
foodEncodeSns
.
iterator
();
while
(
iterator
.
hasNext
())
{
PurchaseFoodEncodeSn
next
=
iterator
.
next
();
if
(!
scanResult
.
contains
(
next
))
{
//将不存在的移除掉
iterator
.
remove
();
}
}
}
//添加到食品中去
if
(
foodEncodeSns
!=
null
)
{
foodEncodeSns
.
addAll
(
newAddSnCodes
);
}
else
{
infoVosBean
.
setPurchaseFoodEncodeSns
(
newAddSnCodes
);
}
int
newAddSize
=
0
;
//在這裡遍歷,防止用戶多次添加,卻沒有點擊收貨
for
(
PurchaseFoodEncodeSn
purchaseFoodEncodeSn
:
infoVosBean
.
getPurchaseFoodEncodeSns
())
{
if
(
purchaseFoodEncodeSn
.
newAdd
)
{
newAddSize
++;
}
purchaseFoodEncodeSns
.
add
(
purchaseFoodEncodeSn
);
}
//本次收貨數量=新增掃sn碼數量
DeputyUnitBean
showUnit
=
infoVosBean
.
getShowUnit
();
if
(
newAddSize
<
showUnit
.
getDeputyValue
())
{
showMessage
(
"新增SN数量必须和入库数一致"
);
return
;
}
showUnit
.
setDeputyValue
(
newAddSize
);
infoVosBean
.
setPurchaseFoodEncodeSns
(
purchaseFoodEncodeSns
);
setFoodCheckState
(
orderDetailsFoodAdapter
,
position
,
infoVosBean
);
scanSnP
opup
.
dismiss
();
p
opup
.
dismiss
();
}
else
{
showMessage
(
"請掃描食材sn碼"
);
}
...
...
@@ -471,6 +549,9 @@ public class OrderDetailsFragment extends BaseSupplyChainFragment<OrderDetailsPr
.
hasShadowBg
(
false
)
.
asCustom
(
scanSnPopup
)
.
show
();
if
(!
singerFood
)
{
scanSnPopup
.
setOnDismissListener
(
this
::
nextFood
);
}
}
/**
...
...
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/ui/fragment/order/SendMsgFragment.java
View file @
dfe4f9a3
...
...
@@ -106,8 +106,7 @@ public class SendMsgFragment extends BaseSupplyChainFragment<SendMsgPresenter> i
//發送
mPresenter
.
sendMsg
();
}
else
if
(
viewId
==
R
.
id
.
btn_supplier_cancel
)
{
// popTo(PurchaseListFragment.class, true);
killMyself
();
backToOrderList
();
}
else
if
(
viewId
==
R
.
id
.
qmui_preview
)
{
//預覽
String
sendUrl
=
mPresenter
.
getSendUrl
();
...
...
@@ -163,16 +162,26 @@ public class SendMsgFragment extends BaseSupplyChainFragment<SendMsgPresenter> i
@Override
public
void
backToOrderList
()
{
startWithPopTo
(
PurchaseListFragment
.
newInstance
(),
PurchaseListFragment
.
class
,
true
);
List
<
Fragment
>
fragments
=
requireActivity
().
getSupportFragmentManager
().
getFragments
();
for
(
Fragment
fragment
:
fragments
)
{
if
(
fragment
instanceof
PurchaseListFragment
)
{
//有訂單列表
popTo
(
PurchaseListFragment
.
class
,
false
);
return
;
}
}
//沒有訂單列表
startWithPop
(
PurchaseListFragment
.
newInstance
());
// startWithPopTo(PurchaseListFragment.newInstance(), this, false);
}
private
boolean
isSend
=
false
;
@Override
public
void
killMyself
()
{
backToOrderList
();
}
private
boolean
isSend
=
false
;
@Override
public
void
onResume
()
{
super
.
onResume
();
...
...
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/ui/fragment/warehouse/WarehouseDetailsFragment.java
View file @
dfe4f9a3
...
...
@@ -3,7 +3,6 @@ package com.gingersoft.supply_chain.mvp.ui.fragment.warehouse;
import
android.animation.LayoutTransition
;
import
android.graphics.Bitmap
;
import
android.os.Bundle
;
import
android.util.Log
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
...
...
@@ -19,11 +18,10 @@ import androidx.print.PrintHelper;
import
androidx.recyclerview.widget.RecyclerView
;
import
androidx.viewpager2.widget.ViewPager2
;
import
com.chad.library.adapter.base.BaseQuickAdapter
;
import
com.chad.library.adapter.base.listener.OnItemChildClickListener
;
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.CollectionUtils
;
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
;
...
...
@@ -37,7 +35,6 @@ import com.gingersoft.supply_chain.mvp.bean.OutboundOrderBean;
import
com.gingersoft.supply_chain.mvp.bean.PurchaseFoodBean
;
import
com.gingersoft.supply_chain.mvp.bean.PurchaseFoodEncodeSn
;
import
com.gingersoft.supply_chain.mvp.bean.PurchaseWarehousingOrderDetailsVO
;
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
;
...
...
@@ -61,7 +58,6 @@ import butterknife.OnClick;
/**
* Description: 入庫詳情
*
* @author admin
*/
public
class
WarehouseDetailsFragment
extends
BaseSupplyChainFragment
<
WarehouseDetailsPresenter
>
implements
WarehouseDetailsContract
.
View
,
View
.
OnClickListener
{
...
...
@@ -143,8 +139,6 @@ public class WarehouseDetailsFragment extends BaseSupplyChainFragment<WarehouseD
Bundle
arguments
=
getArguments
();
smartRefreshLayout
.
setPrimaryColorsId
(
R
.
color
.
trans
,
R
.
color
.
black
);
loadService
=
LoadSir
.
getDefault
().
register
(
smartRefreshLayout
);
// smartRefreshLayout.setEnableHeaderTranslationContent(false).
// setEnableFooterTranslationContent(false);
LayoutTransition
layoutTransition
=
new
LayoutTransition
();
layoutTransition
.
enableTransitionType
(
LayoutTransition
.
CHANGING
);
layoutRoot
.
setLayoutTransition
(
layoutTransition
);
...
...
@@ -235,7 +229,6 @@ public class WarehouseDetailsFragment extends BaseSupplyChainFragment<WarehouseD
}
}
@Override
public
void
loadAdapter
(
List
<
WarehouseDetailsBean
>
warehouseDetailsBeans
)
{
smartRefreshLayout
.
finishRefresh
();
...
...
@@ -256,7 +249,7 @@ public class WarehouseDetailsFragment extends BaseSupplyChainFragment<WarehouseD
if
(
view
.
getId
()
==
R
.
id
.
tv_warehouse_details_food_num
)
{
WarehouseDetailsBean
item
=
wareHousingDetailsAdapter
.
getItem
(
position
);
//查詢消耗,收貨Sn碼詳情
mPresenter
.
querySnCodeList
(
item
.
getFoodQuantity
(),
""
,
item
.
getWarehousingOrderDetailsIds
());
mPresenter
.
querySnCodeList
(
vpWarehouseViewpager
.
getCurrentItem
(),
item
.
getFoodQuantity
(),
""
,
item
.
getWarehousingOrderDetailsIds
());
}
}
});
...
...
@@ -300,15 +293,33 @@ public class WarehouseDetailsFragment extends BaseSupplyChainFragment<WarehouseD
return
;
}
//初始化掃碼view
scanSnView
=
new
ScanSnView
(
this
,
null
,
(
isAdd
,
snCode
,
currentSnCodeNumber
)
->
inventoryConsumptionView
.
setConsumptionNumber
(
currentSnCodeNumber
),
scanResult
->
{
scanSnView
=
new
ScanSnView
(
this
,
null
,
(
popup
,
scanResult
)
->
{
if
(
scanResult
.
isEmpty
())
{
showMessage
(
"請掃碼sn碼"
);
showMessage
(
"請掃碼SN碼"
);
return
;
}
if
(
scanResult
.
size
()
!=
inventoryConsumptionView
.
getConsumptionNum
())
{
showMessage
(
"SN碼數量和消耗庫存數必須保持一致"
);
return
;
}
inventory
(
consumeReasonBeans
,
scanResult
,
inventoryConsumptionView
.
getIsPrint
());
List
<
String
>
snCodes
=
new
ArrayList
<>();
for
(
PurchaseFoodEncodeSn
purchaseFoodEncodeSn
:
scanResult
)
{
snCodes
.
add
(
purchaseFoodEncodeSn
.
getEncodeSnNo
());
}
inventory
(
consumeReasonBeans
,
snCodes
,
inventoryConsumptionView
.
getIsPrint
());
}).
setOnCancelListener
(()
->
{
//取消
showList
(
View
.
VISIBLE
);
}).
init
();
scanSnView
.
setOnSingerResultListener
((
isAdd
,
snCode
,
currentSnCodeNumber
)
->
{
//inventoryConsumptionView.setConsumptionNumber(currentSnCodeNumber)
//添加或移除某個sn碼
scanSnView
.
setConfirmBtnState
();
});
inventoryConsumptionView
.
setOnNumberChangeListener
(
num
->
{
//輸入數量發生變化時
scanSnView
.
setMinCodeSize
(
num
);
scanSnView
.
setConfirmBtnState
();
});
//設置LayoutParam
LinearLayout
.
LayoutParams
layoutParams
=
new
LinearLayout
.
LayoutParams
(
LinearLayout
.
LayoutParams
.
MATCH_PARENT
,
LinearLayout
.
LayoutParams
.
MATCH_PARENT
);
...
...
@@ -331,18 +342,20 @@ public class WarehouseDetailsFragment extends BaseSupplyChainFragment<WarehouseD
layoutRoot
.
removeView
(
scanSnView
);
inventoryConsumptionView
=
null
;
scanSnView
=
null
;
smartRefreshLayout
.
setEnableRefresh
(
true
);
smartRefreshLayout
.
setEnableLoadMore
(
true
);
}
/**
* 消耗方法
*
* @param consumeReasonBeans
* @param snCodes
* @param whetherPrint
* @param consumeReasonBeans
消耗原因
* @param snCodes
snCode集合
* @param whetherPrint
是否打印
*/
private
void
inventory
(
List
<
ConsumeReasonBean
>
consumeReasonBeans
,
List
<
String
>
snCodes
,
boolean
whetherPrint
)
{
//獲取用戶輸入的消耗數量
int
consumptionNum
=
inventoryConsumptionView
.
getConsumptionNum
();
int
consumptionNum
=
inventoryConsumptionView
.
getConsumptionNum
AndTip
();
if
(
consumptionNum
==
-
1
)
{
return
;
}
...
...
@@ -352,11 +365,8 @@ public class WarehouseDetailsFragment extends BaseSupplyChainFragment<WarehouseD
}
@Override
public
void
printConsumeOrder
(
String
consumeReasonDesc
,
int
consumptionNum
)
{
if
(
inventoryConsumptionView
.
getIsPrint
())
{
//打印
onPrintPdf
(
consumeReasonDesc
,
inventoryConsumptionView
.
getRemark
(),
consumptionNum
);
}
public
void
printConsumeOrder
(
List
<
String
>
snCodes
,
String
consumeReasonDesc
,
int
consumptionNum
)
{
onPrintPdf
(
snCodes
,
consumeReasonDesc
,
inventoryConsumptionView
.
getRemark
(),
consumptionNum
);
}
@Override
...
...
@@ -364,7 +374,7 @@ public class WarehouseDetailsFragment extends BaseSupplyChainFragment<WarehouseD
start
(
SnCodeListFragment
.
newInstance
(
purchaseWarehousingOrderDetailsVO
.
getName
(),
remark
,
foodQuantity
,
sns
));
}
private
void
onPrintPdf
(
String
consumptionReason
,
String
remarks
,
int
foodNum
)
{
private
void
onPrintPdf
(
List
<
String
>
snCodes
,
String
consumptionReason
,
String
remarks
,
int
foodNum
)
{
PrintHelper
printHelper
=
new
PrintHelper
(
requireContext
());
boolean
b
=
PrintHelper
.
systemSupportsPrint
();
if
(
b
)
{
...
...
@@ -373,10 +383,10 @@ public class WarehouseDetailsFragment extends BaseSupplyChainFragment<WarehouseD
//設置打印方向
//橫向 PrintHelper.ORIENTATION_LANDSCAPE
//縱向 PrintHelper.ORIENTATION_PORTRAIT
printHelper
.
setOrientation
(
PrintHelper
.
ORIENTATION_
LANDSCAPE
);
printHelper
.
setOrientation
(
PrintHelper
.
ORIENTATION_
PORTRAIT
);
//設置打印顏色
printHelper
.
setColorMode
(
PrintHelper
.
COLOR_MODE_MONOCHROME
);
printHelper
.
printBitmap
(
String
.
format
(
getString
(
R
.
string
.
str_restaurant_outbound_order
),
purchaseWarehousingOrderDetailsVO
.
getName
()),
generatePrintBitmap
(
consumptionReason
,
remarks
,
foodNum
),
()
->
{
printHelper
.
printBitmap
(
String
.
format
(
getString
(
R
.
string
.
str_restaurant_outbound_order
),
purchaseWarehousingOrderDetailsVO
.
getName
()),
generatePrintBitmap
(
snCodes
,
consumptionReason
,
remarks
,
foodNum
),
()
->
{
//打印完成回調
getPageInfo
();
//重新獲取庫存數量
...
...
@@ -388,13 +398,14 @@ public class WarehouseDetailsFragment extends BaseSupplyChainFragment<WarehouseD
}
}
private
Bitmap
generatePrintBitmap
(
String
consumptionReason
,
String
remarks
,
int
foodNum
)
{
private
Bitmap
generatePrintBitmap
(
List
<
String
>
snCodes
,
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
);
TextView
tvSnCodes
=
view
.
findViewById
(
R
.
id
.
tv_print_sn
);
restaurantName
.
setText
(
String
.
format
(
getString
(
R
.
string
.
str_restaurant_outbound_order
),
RestaurantInfoManager
.
newInstance
().
getRestaurantName
()));
tvDate
.
setText
(
TimeUtils
.
getCurrentDate
(
TimeUtils
.
DEFAULT_DATE_FORMAT_YMDHM
));
...
...
@@ -408,7 +419,12 @@ public class WarehouseDetailsFragment extends BaseSupplyChainFragment<WarehouseD
outboundOrderBeans
.
add
(
new
OutboundOrderBean
(
"金額"
,
String
.
valueOf
(
MoneyUtil
.
priceCalculation
(
purchaseWarehousingOrderDetailsVO
.
getFoodPrice
(),
foodNum
))));
outboundOrderBeans
.
add
(
new
OutboundOrderBean
(
"消耗原因"
,
consumptionReason
));
outboundOrderBeans
.
add
(
new
OutboundOrderBean
(
"備註"
,
remarks
));
if
(
CollectionUtils
.
isNotNullOrEmpty
(
snCodes
))
{
//sn碼不為空
tvSnCodes
.
setText
(
String
.
format
(
getString
(
R
.
string
.
str_sn_codes
),
CollectionUtils
.
listToCommaString
(
snCodes
)));
}
else
{
tvSnCodes
.
setVisibility
(
View
.
GONE
);
}
OutboundOrderAdapter
outboundOrderAdapter
=
new
OutboundOrderAdapter
(
outboundOrderBeans
);
rvInfo
.
setAdapter
(
outboundOrderAdapter
);
return
LayoutToBitmapUtils
.
getBitmapByView
(
requireContext
(),
view
);
...
...
@@ -425,6 +441,9 @@ public class WarehouseDetailsFragment extends BaseSupplyChainFragment<WarehouseD
layoutTitle
.
setVisibility
(
visible
);
if
(
visible
==
View
.
VISIBLE
)
{
removeInventoryView
();
}
else
{
smartRefreshLayout
.
setEnableRefresh
(
false
);
smartRefreshLayout
.
setEnableLoadMore
(
false
);
}
}
...
...
@@ -444,7 +463,7 @@ public class WarehouseDetailsFragment extends BaseSupplyChainFragment<WarehouseD
tvWarehouseInventoryNumber
.
setText
(
String
.
valueOf
(
num
));
}
@OnClick
({
R2
.
id
.
tv_warehousing_record
,
R2
.
id
.
tv_outbound_record
})
@OnClick
({
R2
.
id
.
tv_warehousing_record
,
R2
.
id
.
tv_outbound_record
,
R2
.
id
.
tv_warehouse_inventory_number
})
@Override
public
void
onClick
(
View
v
)
{
if
(
v
.
getId
()
==
R
.
id
.
tv_warehousing_record
)
{
...
...
@@ -457,6 +476,11 @@ public class WarehouseDetailsFragment extends BaseSupplyChainFragment<WarehouseD
vpWarehouseViewpager
.
setCurrentItem
(
OUT_STOCK_TYPE
);
//查詢出庫
getOutStockDetails
();
}
else
if
(
v
.
getId
()
==
R
.
id
.
tv_warehouse_inventory_number
)
{
if
(
purchaseWarehousingOrderDetailsVO
.
getFoodMarkSn
()
==
PurchaseFoodBean
.
HAS_SN
)
{
//是sn食材,查詢庫中剩餘的sn碼
mPresenter
.
queryInStockSnCodes
(
purchaseWarehousingOrderDetailsVO
.
getFoodNum
(),
""
,
purchaseWarehousingOrderDetailsVO
.
getFoodNo
());
}
}
}
}
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/ui/widget/GroupedGridLayoutManager.java
0 → 100644
View file @
dfe4f9a3
package
com
.
gingersoft
.
supply_chain
.
mvp
.
ui
.
widget
;
import
android.content.Context
;
import
android.util.AttributeSet
;
import
androidx.recyclerview.widget.GridLayoutManager
;
import
com.gingersoft.supply_chain.mvp.ui.adapter.GroupedRecyclerViewAdapter
;
/**
* 为分组列表提供的GridLayoutManager。
* 因为分组列表如果要使用GridLayoutManager实现网格布局。要保证组的头部和尾部是要单独占用一行的。
* 否则组的头、尾可能会跟子项混着一起,造成布局混乱。
*/
public
class
GroupedGridLayoutManager
extends
GridLayoutManager
{
private
GroupedRecyclerViewAdapter
mAdapter
;
public
GroupedGridLayoutManager
(
Context
context
,
int
spanCount
,
GroupedRecyclerViewAdapter
adapter
)
{
super
(
context
,
spanCount
);
mAdapter
=
adapter
;
setSpanSizeLookup
();
}
public
GroupedGridLayoutManager
(
Context
context
,
int
spanCount
,
int
orientation
,
boolean
reverseLayout
,
GroupedRecyclerViewAdapter
adapter
)
{
super
(
context
,
spanCount
,
orientation
,
reverseLayout
);
this
.
mAdapter
=
adapter
;
setSpanSizeLookup
();
}
public
GroupedGridLayoutManager
(
Context
context
,
AttributeSet
attrs
,
int
defStyleAttr
,
int
defStyleRes
,
GroupedRecyclerViewAdapter
adapter
)
{
super
(
context
,
attrs
,
defStyleAttr
,
defStyleRes
);
this
.
mAdapter
=
adapter
;
setSpanSizeLookup
();
}
private
void
setSpanSizeLookup
()
{
super
.
setSpanSizeLookup
(
new
SpanSizeLookup
()
{
@Override
public
int
getSpanSize
(
int
position
)
{
int
count
=
getSpanCount
();
if
(
mAdapter
!=
null
)
{
int
type
=
mAdapter
.
judgeType
(
position
);
//只对子项做Grid效果
if
(
type
==
GroupedRecyclerViewAdapter
.
TYPE_CHILD
)
{
int
groupPosition
=
mAdapter
.
getGroupPositionForPosition
(
position
);
int
childPosition
=
mAdapter
.
getChildPositionForPosition
(
groupPosition
,
position
);
return
getChildSpanSize
(
groupPosition
,
childPosition
);
}
}
return
count
;
}
});
}
/**
* 提供这个方法可以使外部改变子项的SpanSize。
* 这个方法的作用跟{@link SpanSizeLookup#getSpanSize(int)}一样。
* @param groupPosition
* @param childPosition
* @return
*/
public
int
getChildSpanSize
(
int
groupPosition
,
int
childPosition
)
{
return
1
;
}
@Override
public
void
setSpanSizeLookup
(
SpanSizeLookup
spanSizeLookup
)
{
}
}
\ No newline at end of file
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/ui/widget/InventoryConsumptionView.java
View file @
dfe4f9a3
...
...
@@ -57,6 +57,7 @@ public class InventoryConsumptionView extends FrameLayout {
private
OnConfirmClickListener
onConfirmClickListener
;
private
ScanSnView
.
OnCancelListener
onCancelListener
;
private
ConsumptionReasonAdapter
consumptionReasonAdapter
;
private
OnNumberChangeListener
onNumberChangeListener
;
public
InventoryConsumptionView
(
@NonNull
Context
context
,
List
<
ConsumeReasonBean
>
consumeReasonBeans
,
int
maxConsumption
)
{
super
(
context
);
...
...
@@ -110,6 +111,9 @@ public class InventoryConsumptionView extends FrameLayout {
if
(
i
>
maxConsumption
)
{
edInput
.
setError
(
"不能超過當前庫存數量:"
+
maxConsumption
);
}
if
(
onNumberChangeListener
!=
null
)
{
onNumberChangeListener
.
onNumberChange
(
i
);
}
}
catch
(
NumberFormatException
e
)
{
e
.
printStackTrace
();
}
...
...
@@ -132,6 +136,11 @@ public class InventoryConsumptionView extends FrameLayout {
return
this
;
}
public
InventoryConsumptionView
setOnNumberChangeListener
(
OnNumberChangeListener
onNumberChangeListener
)
{
this
.
onNumberChangeListener
=
onNumberChangeListener
;
return
this
;
}
public
String
getRemark
()
{
return
edRemarks
.
getText
().
toString
();
}
...
...
@@ -150,11 +159,11 @@ public class InventoryConsumptionView extends FrameLayout {
}
/**
* 獲取消耗數量
* 獲取消耗數量
並提示
*
* @return 輸入的數量
*/
public
int
getConsumptionNum
()
{
public
int
getConsumptionNum
AndTip
()
{
String
s
=
edInput
.
getText
().
toString
();
try
{
int
i
=
Integer
.
parseInt
(
s
);
...
...
@@ -178,6 +187,20 @@ public class InventoryConsumptionView extends FrameLayout {
}
}
/**
* 獲取消耗數量
*
* @return 輸入的數量
*/
public
int
getConsumptionNum
()
{
String
s
=
edInput
.
getText
().
toString
();
try
{
return
Integer
.
parseInt
(
s
);
}
catch
(
NumberFormatException
e
)
{
return
-
1
;
}
}
public
void
setConsumptionNumber
(
int
consumptionNumber
)
{
edInput
.
setText
(
String
.
valueOf
(
consumptionNumber
));
}
...
...
@@ -192,4 +215,8 @@ public class InventoryConsumptionView extends FrameLayout {
*/
void
onConfirm
(
int
consumptionNum
,
int
reasonIndex
,
String
remarks
);
}
public
interface
OnNumberChangeListener
{
void
onNumberChange
(
int
num
);
}
}
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/ui/widget/ScanSnPopup.java
View file @
dfe4f9a3
...
...
@@ -2,6 +2,7 @@ package com.gingersoft.supply_chain.mvp.ui.widget;
import
android.annotation.SuppressLint
;
import
android.widget.LinearLayout
;
import
android.widget.PopupWindow
;
import
android.widget.TextView
;
import
androidx.annotation.NonNull
;
...
...
@@ -9,6 +10,7 @@ import androidx.fragment.app.Fragment;
import
com.gingersoft.supply_chain.R
;
import
com.gingersoft.supply_chain.R2
;
import
com.gingersoft.supply_chain.mvp.bean.PurchaseFoodEncodeSn
;
import
com.jess.arms.utils.DeviceUtils
;
import
com.lxj.xpopup.core.BottomPopupView
;
...
...
@@ -28,8 +30,9 @@ import butterknife.ButterKnife;
public
class
ScanSnPopup
extends
BottomPopupView
{
private
final
String
foodName
;
private
final
List
<
String
>
snCodes
;
private
final
List
<
PurchaseFoodEncodeSn
>
snCodes
;
private
final
Fragment
fragment
;
private
final
boolean
operable
;
@BindView
(
R2
.
id
.
tv_food_Ingredients_name
)
TextView
tvFoodIngredientsName
;
@BindView
(
R2
.
id
.
tv_food_inbound_quantity
)
...
...
@@ -37,15 +40,26 @@ public class ScanSnPopup extends BottomPopupView {
@BindView
(
R2
.
id
.
layout_scan_sn
)
LinearLayout
rootLayout
;
private
OnScanResultListener
onScanResultListener
;
private
PopupWindow
.
OnDismissListener
onDismissListener
;
private
ScanSnView
.
OnDeleteSnCodeListener
onDeleteListener
;
/**
* 最大掃碼數量
*/
private
int
maxCodeSize
=
-
1
;
/**
* 最少掃碼數量
*/
private
int
minCodeSize
=
0
;
public
ScanSnPopup
(
@NonNull
Fragment
fragment
,
String
foodName
,
List
<
String
>
snCodes
)
{
public
ScanSnPopup
(
@NonNull
Fragment
fragment
,
String
foodName
,
List
<
PurchaseFoodEncodeSn
>
purchaseFoodEncodeSns
,
boolean
operable
)
{
super
(
fragment
.
requireContext
());
if
(
snCode
s
==
null
)
{
snCode
s
=
new
ArrayList
<>();
if
(
purchaseFoodEncodeSn
s
==
null
)
{
purchaseFoodEncodeSn
s
=
new
ArrayList
<>();
}
this
.
foodName
=
foodName
;
this
.
snCodes
=
snCode
s
;
this
.
snCodes
=
purchaseFoodEncodeSn
s
;
this
.
fragment
=
fragment
;
this
.
operable
=
operable
;
addInnerContent
();
}
...
...
@@ -66,28 +80,66 @@ public class ScanSnPopup extends BottomPopupView {
ButterKnife
.
bind
(
this
);
tvFoodIngredientsName
.
setText
(
foodName
);
tvFoodInboundQuantity
.
setText
(
String
.
valueOf
(
snCodes
.
size
()));
rootLayout
.
addView
(
new
ScanSnView
(
fragment
,
snCodes
,
(
isAdd
,
snCode
,
currentSnCodeNumber
)
->
{
if
(
operable
)
{
rootLayout
.
addView
(
new
ScanSnView
(
fragment
,
snCodes
,
(
popup
,
scanResult
)
->
onScanResultListener
.
onScanResult
(
ScanSnPopup
.
this
,
scanResult
))
.
setOnDeleteSnCodeListener
(
onDeleteListener
)
.
setOnCancelListener
(
this
::
dismiss
)
.
setMinCodeSize
(
minCodeSize
)
.
setMaxCodeSize
(
maxCodeSize
)
.
setOnSingerResultListener
((
isAdd
,
snCode
,
currentSnCodeNumber
)
->
{
//每掃描出一個調用
tvFoodInboundQuantity
.
setText
(
String
.
valueOf
(
currentSnCodeNumber
));
},
onScanResultListener
).
setOnCancelListener
(
this
::
dismiss
),
new
LinearLayout
.
LayoutParams
(
LinearLayout
.
LayoutParams
.
MATCH_PARENT
,
LinearLayout
.
LayoutParams
.
MATCH_PARENT
));
}).
init
()
,
new
LinearLayout
.
LayoutParams
(
LinearLayout
.
LayoutParams
.
MATCH_PARENT
,
LinearLayout
.
LayoutParams
.
MATCH_PARENT
));
}
else
{
rootLayout
.
addView
(
new
ShowSnView
(
getContext
(),
snCodes
));
}
}
@Override
protected
int
getMaxHeight
()
{
return
(
int
)
(
DeviceUtils
.
getScreenHeight
(
getContext
())
/
2
);
public
ScanSnPopup
setMaxCodeSize
(
int
maxCodeSize
)
{
this
.
maxCodeSize
=
maxCodeSize
;
return
this
;
}
public
ScanSnPopup
setMinCodeSize
(
int
minCodeSize
)
{
this
.
minCodeSize
=
minCodeSize
;
return
this
;
}
@Override
protected
int
get
Popup
Height
()
{
protected
int
get
Max
Height
()
{
return
(
int
)
(
DeviceUtils
.
getScreenHeight
(
getContext
())
/
2
);
}
// @Override
// protected int getPopupHeight() {
// return (int) (DeviceUtils.getScreenHeight(getContext()) / 2);
// }
public
interface
OnScanResultListener
{
/**
* 掃完碼確認之後回調
*
* @param scanResult 本次掃碼結果
*/
void
onScanResult
(
List
<
String
>
scanResult
);
void
onScanResult
(
ScanSnPopup
popup
,
List
<
PurchaseFoodEncodeSn
>
scanResult
);
}
public
ScanSnPopup
setOnDeleteListener
(
ScanSnView
.
OnDeleteSnCodeListener
onDeleteListener
)
{
this
.
onDeleteListener
=
onDeleteListener
;
return
this
;
}
public
ScanSnPopup
setOnDismissListener
(
PopupWindow
.
OnDismissListener
onDismissListener
)
{
this
.
onDismissListener
=
onDismissListener
;
return
this
;
}
@Override
protected
void
onDismiss
()
{
super
.
onDismiss
();
if
(
onDismissListener
!=
null
)
{
onDismissListener
.
onDismiss
();
}
}
}
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/ui/widget/ScanSnView.java
View file @
dfe4f9a3
...
...
@@ -25,6 +25,8 @@ import com.gingersoft.gsa.cloud.component.ComponentName;
import
com.gingersoft.gsa.cloud.ui.utils.AppDialog
;
import
com.gingersoft.supply_chain.R
;
import
com.gingersoft.supply_chain.R2
;
import
com.gingersoft.supply_chain.mvp.bean.PurchaseConsumeSnBean
;
import
com.gingersoft.supply_chain.mvp.bean.PurchaseFoodEncodeSn
;
import
com.lxj.xpopup.interfaces.OnCancelListener
;
import
com.qmuiteam.qmui.alpha.QMUIAlphaButton
;
import
com.qmuiteam.qmui.alpha.QMUIAlphaImageButton
;
...
...
@@ -50,7 +52,7 @@ import me.yokeyword.fragmentation.SupportHelper;
*/
public
class
ScanSnView
extends
FrameLayout
{
private
List
<
String
>
snCode
s
;
private
List
<
PurchaseFoodEncodeSn
>
purchaseFoodEncodeSn
s
;
private
ScanSnPopup
.
OnScanResultListener
onScanResultListener
;
@BindView
(
R2
.
id
.
rv_sn_code
)
...
...
@@ -69,35 +71,57 @@ public class ScanSnView extends FrameLayout {
private
OnCancelListener
onCancelListener
;
private
OnSingerResultListener
onSingerResultListener
;
/**
* 初始時snCode的數量,點擊取消時,如果現有的sn數量和剛開始的一樣多,就不提示
*/
private
int
initCodeSize
=
0
;
/**
* 新增的sn码数量
*/
private
int
newCodeSize
=
0
;
private
OnDeleteSnCodeListener
onDeleteSnCodeListener
;
/**
* 最大掃碼數量
*/
private
int
maxCodeSize
=
-
1
;
/**
* 最少掃碼數量
*/
private
int
minCodeSize
=
0
;
public
ScanSnView
(
Fragment
fragment
,
List
<
String
>
snCodes
,
OnSingerResultListener
onSingerResultListener
,
ScanSnPopup
.
OnScanResultListener
onScanResultListener
)
{
public
ScanSnView
(
Fragment
fragment
,
List
<
PurchaseFoodEncodeSn
>
purchaseFoodEncodeSns
,
ScanSnPopup
.
OnScanResultListener
onScanResultListener
)
{
super
(
fragment
.
requireContext
());
this
.
snCodes
=
snCodes
;
if
(
purchaseFoodEncodeSns
==
null
)
{
this
.
purchaseFoodEncodeSns
=
new
ArrayList
<>();
}
else
{
this
.
purchaseFoodEncodeSns
=
purchaseFoodEncodeSns
;
}
initCodeSize
=
this
.
purchaseFoodEncodeSns
.
size
();
for
(
PurchaseFoodEncodeSn
purchaseFoodEncodeSn
:
purchaseFoodEncodeSns
)
{
if
(
purchaseFoodEncodeSn
.
newAdd
)
{
newCodeSize
++;
}
}
this
.
onScanResultListener
=
onScanResultListener
;
this
.
fragment
=
fragment
;
this
.
onSingerResultListener
=
onSingerResultListener
;
init
();
}
public
ScanSnView
(
Context
context
)
{
this
(
context
,
null
);
}
public
ScanSnView
(
Context
context
,
@Nullable
AttributeSet
attrs
)
{
this
(
context
,
attrs
,
-
1
);
public
ScanSnView
setMaxCodeSize
(
int
maxCodeSize
)
{
this
.
maxCodeSize
=
maxCodeSize
;
return
this
;
}
public
ScanSnView
(
Context
context
,
@Nullable
AttributeSet
attrs
,
int
defStyleAttr
)
{
super
(
context
,
attrs
,
defStyleAttr
)
;
init
()
;
public
ScanSnView
setMinCodeSize
(
int
minCodeSize
)
{
this
.
minCodeSize
=
minCodeSize
;
return
this
;
}
p
rivate
void
init
()
{
p
ublic
ScanSnView
init
()
{
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
);
//初始化adapter
SnCodeAdapter
adapter
=
new
SnCodeAdapter
(
R
.
layout
.
item_sn_code
,
purchaseFoodEncodeSns
);
setConfirmBtnState
(
);
rvSnCode
.
setAdapter
(
adapter
);
//掃描sn媽
btnScanSn
.
setOnClickListener
(
v
->
...
...
@@ -115,8 +139,7 @@ public class ScanSnView extends FrameLayout {
if
(
adapter
.
getData
().
contains
(
snCode
))
{
ToastUtils
.
show
(
getContext
(),
"商品已存在,不能重複添加"
);
}
else
{
adapter
.
addData
(
snCode
);
onSingerResultListener
.
onScanValue
(
true
,
snCode
,
adapter
.
getItemCount
());
addSnCode
(
adapter
,
snCode
);
}
}
});
...
...
@@ -129,6 +152,7 @@ public class ScanSnView extends FrameLayout {
//隐藏软键盘
SupportHelper
.
hideSoftInput
(
v
);
commitSnCode
(
adapter
);
setConfirmBtnState
();
}
return
false
;
});
...
...
@@ -136,15 +160,17 @@ public class ScanSnView extends FrameLayout {
tvSubmitSn
.
setOnClickListener
(
v
->
{
//提交輸入框中的sn碼
commitSnCode
(
adapter
);
setConfirmBtnState
();
});
btnFoodIngredientsConfirm
.
setOnClickListener
(
v
->
{
//保存本次掃描的所有sn碼
onScanResultListener
.
onScanResult
(
adapter
.
getData
());
//校驗掃描數量和規定的數量是不是一致的,
onScanResultListener
.
onScanResult
(
null
,
adapter
.
getData
());
});
btnFoodIngredientsCancel
.
setOnClickListener
(
v
->
{
if
(
adapter
.
getData
().
size
()
>
0
)
{
if
(
adapter
.
getData
().
size
()
!=
initCodeSize
)
{
AppDialog
.
getInstance
().
showWaringDialog
(
getContext
(),
"關閉後不會保存SN碼記錄"
,
(
view
,
dialog
)
->
{
dialog
.
dismiss
();
onCancelListener
.
onCancel
();
...
...
@@ -156,10 +182,26 @@ public class ScanSnView extends FrameLayout {
adapter
.
setOnItemChildClickListener
((
adapter1
,
view
,
position
)
->
{
if
(
view
.
getId
()
==
R
.
id
.
iv_sn_code_delete
)
{
onSingerResultListener
.
onScanValue
(
false
,
adapter
.
getItem
(
position
),
adapter
.
getItemCount
());
if
(
onDeleteSnCodeListener
!=
null
)
{
onDeleteSnCodeListener
.
onDelete
(
adapter
.
getItem
(
position
),
position
);
}
if
(
adapter
.
getItem
(
position
).
newAdd
)
{
newCodeSize
--;
}
adapter1
.
removeAt
(
position
);
setConfirmBtnState
();
}
});
addView
(
rootView
);
return
this
;
}
public
void
setConfirmBtnState
()
{
if
(
minCodeSize
>
0
&&
newCodeSize
==
minCodeSize
)
{
btnFoodIngredientsConfirm
.
setBackground
(
ContextCompat
.
getDrawable
(
getContext
(),
R
.
drawable
.
shape_app_btn
));
}
else
{
btnFoodIngredientsConfirm
.
setBackground
(
ContextCompat
.
getDrawable
(
getContext
(),
R
.
drawable
.
shape_btn_unclick
));
}
}
private
void
commitSnCode
(
SnCodeAdapter
adapter
)
{
...
...
@@ -168,43 +210,68 @@ public class ScanSnView extends FrameLayout {
ToastUtils
.
show
(
getContext
(),
"商品已存在,不能重複添加"
);
}
else
{
String
snCode
=
edInputSn
.
getText
().
toString
();
adapter
.
addData
(
snCode
);
edInputSn
.
setText
(
""
);
onSingerResultListener
.
onScanValue
(
true
,
snCode
,
adapter
.
getItemCount
());
addSnCode
(
adapter
,
snCode
);
}
}
else
{
ToastUtils
.
show
(
getContext
(),
"請輸入SN碼"
);
}
}
/**
* 添加sn码
*/
private
void
addSnCode
(
SnCodeAdapter
adapter
,
String
snCode
)
{
PurchaseFoodEncodeSn
purchaseFoodEncodeSn
=
new
PurchaseFoodEncodeSn
(
snCode
);
purchaseFoodEncodeSn
.
newAdd
=
true
;
adapter
.
addData
(
purchaseFoodEncodeSn
);
newCodeSize
++;
edInputSn
.
setText
(
""
);
setConfirmBtnState
();
onSingerResultListener
.
onScanValue
(
true
,
purchaseFoodEncodeSn
,
adapter
.
getItemCount
());
}
public
ScanSnView
setOnCancelListener
(
OnCancelListener
onCancelListener
)
{
this
.
onCancelListener
=
onCancelListener
;
return
this
;
}
public
ScanSnView
setOnDeleteSnCodeListener
(
OnDeleteSnCodeListener
onDeleteSnCodeListener
)
{
this
.
onDeleteSnCodeListener
=
onDeleteSnCodeListener
;
return
this
;
}
public
ScanSnView
setOnSingerResultListener
(
OnSingerResultListener
onSingerResultListener
)
{
this
.
onSingerResultListener
=
onSingerResultListener
;
return
this
;
}
public
interface
OnSingerResultListener
{
/**
* @param isAdd true為新增,false為刪除
* @param snCode sn碼
* @param currentSnCodeNumber 當前有多少個sn碼
*/
void
onScanValue
(
boolean
isAdd
,
String
snCode
,
int
currentSnCodeNumber
);
void
onScanValue
(
boolean
isAdd
,
PurchaseFoodEncodeSn
snCode
,
int
currentSnCodeNumber
);
}
public
interface
OnDeleteSnCodeListener
{
void
onDelete
(
PurchaseFoodEncodeSn
snCode
,
int
position
);
}
public
interface
OnCancelListener
{
void
onCancel
();
}
p
rivate
static
class
SnCodeAdapter
extends
BaseQuickAdapter
<
String
,
BaseViewHolder
>
{
p
ublic
static
class
SnCodeAdapter
extends
BaseQuickAdapter
<
PurchaseFoodEncodeSn
,
BaseViewHolder
>
{
public
SnCodeAdapter
(
int
layoutResId
,
@org
.
jetbrains
.
annotations
.
Nullable
List
<
String
>
data
)
{
public
SnCodeAdapter
(
int
layoutResId
,
@org
.
jetbrains
.
annotations
.
Nullable
List
<
PurchaseFoodEncodeSn
>
data
)
{
super
(
layoutResId
,
data
);
addChildClickViewIds
(
R
.
id
.
iv_sn_code_delete
);
}
@Override
protected
void
convert
(
@NotNull
BaseViewHolder
viewHolder
,
String
s
)
{
viewHolder
.
setText
(
R
.
id
.
tv_sn_code
,
s
);
protected
void
convert
(
@NotNull
BaseViewHolder
viewHolder
,
PurchaseFoodEncodeSn
s
)
{
viewHolder
.
setText
(
R
.
id
.
tv_sn_code
,
String
.
valueOf
(
s
.
getEncodeSnNo
())
);
viewHolder
.
setTextColor
(
R
.
id
.
tv_sn_code
,
ContextCompat
.
getColor
(
getContext
(),
R
.
color
.
color_3c
));
viewHolder
.
setTextColor
(
R
.
id
.
tv_serial_number
,
ContextCompat
.
getColor
(
getContext
(),
R
.
color
.
color_3c
));
viewHolder
.
setGone
(
R
.
id
.
iv_sn_code_delete
,
false
);
...
...
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/ui/widget/ShowSnView.java
0 → 100644
View file @
dfe4f9a3
package
com
.
gingersoft
.
supply_chain
.
mvp
.
ui
.
widget
;
import
android.content.Context
;
import
android.util.AttributeSet
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.inputmethod.EditorInfo
;
import
android.widget.EditText
;
import
android.widget.FrameLayout
;
import
androidx.annotation.Nullable
;
import
androidx.core.content.ContextCompat
;
import
androidx.fragment.app.Fragment
;
import
androidx.recyclerview.widget.RecyclerView
;
import
com.billy.cc.core.component.CC
;
import
com.chad.library.adapter.base.BaseQuickAdapter
;
import
com.chad.library.adapter.base.viewholder.BaseViewHolder
;
import
com.gingersoft.gsa.cloud.common.utils.XPermissionUtils
;
import
com.gingersoft.gsa.cloud.common.utils.other.TextUtil
;
import
com.gingersoft.gsa.cloud.common.utils.toast.ToastUtils
;
import
com.gingersoft.gsa.cloud.component.ComponentName
;
import
com.gingersoft.gsa.cloud.ui.utils.AppDialog
;
import
com.gingersoft.supply_chain.R
;
import
com.gingersoft.supply_chain.R2
;
import
com.gingersoft.supply_chain.mvp.bean.PurchaseFoodEncodeSn
;
import
com.qmuiteam.qmui.alpha.QMUIAlphaButton
;
import
com.qmuiteam.qmui.alpha.QMUIAlphaImageButton
;
import
com.qmuiteam.qmui.alpha.QMUIAlphaTextView
;
import
org.jetbrains.annotations.NotNull
;
import
java.util.List
;
import
butterknife.BindView
;
import
butterknife.ButterKnife
;
import
cn.bingoogolapple.qrcode.core.BarcodeType
;
import
me.yokeyword.fragmentation.SupportHelper
;
/**
* @author 宇航.
* User: admin
* Date: 2021/3/18
* Time: 17:23
* Use: 掃描sn碼
*/
public
class
ShowSnView
extends
FrameLayout
{
private
List
<
PurchaseFoodEncodeSn
>
snCodes
;
@BindView
(
R2
.
id
.
rv_sn_code
)
RecyclerView
rvSnCode
;
public
ShowSnView
(
Context
context
,
List
<
PurchaseFoodEncodeSn
>
snCodes
)
{
super
(
context
);
this
.
snCodes
=
snCodes
;
init
();
}
private
void
init
()
{
View
rootView
=
LayoutInflater
.
from
(
getContext
()).
inflate
(
R
.
layout
.
layout_show_sn
,
this
,
false
);
ButterKnife
.
bind
(
this
,
rootView
);
//初始化adapter
ScanSnView
.
SnCodeAdapter
adapter
=
new
ScanSnView
.
SnCodeAdapter
(
R
.
layout
.
item_show_sn_code
,
snCodes
);
rvSnCode
.
setAdapter
(
adapter
);
addView
(
rootView
);
}
}
component-supply-chain/src/main/java/com/gingersoft/supply_chain/mvp/ui/widget/StickyHeaderLayout.java
0 → 100644
View file @
dfe4f9a3
package
com
.
gingersoft
.
supply_chain
.
mvp
.
ui
.
widget
;
import
android.content.Context
;
import
android.util.AttributeSet
;
import
android.util.SparseArray
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.FrameLayout
;
import
androidx.annotation.AttrRes
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
androidx.recyclerview.widget.GridLayoutManager
;
import
androidx.recyclerview.widget.LinearLayoutManager
;
import
androidx.recyclerview.widget.RecyclerView
;
import
androidx.recyclerview.widget.StaggeredGridLayoutManager
;
import
com.chad.library.adapter.base.viewholder.BaseViewHolder
;
import
com.gingersoft.supply_chain.mvp.ui.adapter.GroupedRecyclerViewAdapter
;
import
java.lang.reflect.Method
;
/**
* Depiction:头部吸顶布局。只要用StickyHeaderLayout包裹{@link RecyclerView},
* 并且使用{@link GroupedRecyclerViewAdapter},就可以实现列表头部吸顶功能。
* StickyHeaderLayout只能包裹RecyclerView,而且只能包裹一个RecyclerView。
* <p>
* Author:donkingliang QQ:1043214265
* Dat:2017/11/14
*/
public
class
StickyHeaderLayout
extends
FrameLayout
{
private
Context
mContext
;
private
RecyclerView
mRecyclerView
;
//吸顶容器,用于承载吸顶布局。
private
FrameLayout
mStickyLayout
;
//保存吸顶布局的缓存池。它以列表组头的viewType为key,ViewHolder为value对吸顶布局进行保存和回收复用。
private
final
SparseArray
<
BaseViewHolder
>
mStickyViews
=
new
SparseArray
<>();
//用于在吸顶布局中保存viewType的key。
private
final
int
VIEW_TAG_TYPE
=
-
101
;
//用于在吸顶布局中保存ViewHolder的key。
private
final
int
VIEW_TAG_HOLDER
=
-
102
;
//记录当前吸顶的组。
private
int
mCurrentStickyGroup
=
-
1
;
//是否吸顶。
private
boolean
isSticky
=
true
;
//是否已经注册了adapter刷新监听
private
boolean
isRegisterDataObserver
=
false
;
public
StickyHeaderLayout
(
@NonNull
Context
context
)
{
super
(
context
);
mContext
=
context
;
}
public
StickyHeaderLayout
(
@NonNull
Context
context
,
@Nullable
AttributeSet
attrs
)
{
super
(
context
,
attrs
);
mContext
=
context
;
}
public
StickyHeaderLayout
(
@NonNull
Context
context
,
@Nullable
AttributeSet
attrs
,
@AttrRes
int
defStyleAttr
)
{
super
(
context
,
attrs
,
defStyleAttr
);
mContext
=
context
;
}
@Override
public
void
addView
(
View
child
,
int
index
,
ViewGroup
.
LayoutParams
params
)
{
if
(
getChildCount
()
>
0
||
!(
child
instanceof
RecyclerView
))
{
//外界只能向StickyHeaderLayout添加一个RecyclerView,而且只能添加RecyclerView。
throw
new
IllegalArgumentException
(
"StickyHeaderLayout can host only one direct child --> RecyclerView"
);
}
super
.
addView
(
child
,
index
,
params
);
mRecyclerView
=
(
RecyclerView
)
child
;
addOnScrollListener
();
addStickyLayout
();
}
/**
* 添加滚动监听
*/
private
void
addOnScrollListener
()
{
mRecyclerView
.
addOnScrollListener
(
new
RecyclerView
.
OnScrollListener
()
{
@Override
public
void
onScrolled
(
RecyclerView
recyclerView
,
int
dx
,
int
dy
)
{
// 在滚动的时候,需要不断的更新吸顶布局。
if
(
isSticky
)
{
updateStickyView
(
false
);
}
}
});
}
/**
* 添加吸顶容器
*/
private
void
addStickyLayout
()
{
mStickyLayout
=
new
FrameLayout
(
mContext
);
LayoutParams
lp
=
new
LayoutParams
(
FrameLayout
.
LayoutParams
.
MATCH_PARENT
,
FrameLayout
.
LayoutParams
.
WRAP_CONTENT
);
mStickyLayout
.
setLayoutParams
(
lp
);
super
.
addView
(
mStickyLayout
,
1
,
lp
);
}
/**
* 强制更新吸顶布局。
*/
public
void
updateStickyView
()
{
updateStickyView
(
true
);
}
/**
* 更新吸顶布局。
*
* @param imperative 是否强制更新。
*/
private
void
updateStickyView
(
boolean
imperative
)
{
RecyclerView
.
Adapter
adapter
=
mRecyclerView
.
getAdapter
();
//只有RecyclerView的adapter是GroupedRecyclerViewAdapter的时候,才会添加吸顶布局。
if
(
adapter
instanceof
GroupedRecyclerViewAdapter
)
{
GroupedRecyclerViewAdapter
gAdapter
=
(
GroupedRecyclerViewAdapter
)
adapter
;
registerAdapterDataObserver
(
gAdapter
);
//获取列表显示的第一个项。
int
firstVisibleItem
=
getFirstVisibleItem
();
//通过显示的第一个项的position获取它所在的组。
int
groupPosition
=
gAdapter
.
getGroupPositionForPosition
(
firstVisibleItem
);
//如果当前吸顶的组头不是我们要吸顶的组头,就更新吸顶布局。这样做可以避免频繁的更新吸顶布局。
if
(
imperative
||
mCurrentStickyGroup
!=
groupPosition
)
{
mCurrentStickyGroup
=
groupPosition
;
//通过groupPosition获取当前组的组头position。这个组头就是我们需要吸顶的布局。
int
groupHeaderPosition
=
gAdapter
.
getPositionForGroupHeader
(
groupPosition
);
if
(
groupHeaderPosition
!=
-
1
)
{
//获取吸顶布局的viewType。
int
viewType
=
gAdapter
.
getItemViewType
(
groupHeaderPosition
);
//如果当前的吸顶布局的类型和我们需要的一样,就直接获取它的ViewHolder,否则就回收。
BaseViewHolder
holder
=
recycleStickyView
(
viewType
);
//标志holder是否是从当前吸顶布局取出来的。
boolean
flag
=
holder
!=
null
;
if
(
holder
==
null
)
{
//从缓存池中获取吸顶布局。
holder
=
getStickyViewByType
(
viewType
);
}
if
(
holder
==
null
)
{
//如果没有从缓存池中获取到吸顶布局,则通过GroupedRecyclerViewAdapter创建。
holder
=
(
BaseViewHolder
)
gAdapter
.
onCreateViewHolder
(
mStickyLayout
,
viewType
);
holder
.
itemView
.
setTag
(
VIEW_TAG_TYPE
,
viewType
);
holder
.
itemView
.
setTag
(
VIEW_TAG_HOLDER
,
holder
);
}
//通过GroupedRecyclerViewAdapter更新吸顶布局的数据。
//这样可以保证吸顶布局的显示效果跟列表中的组头保持一致。
gAdapter
.
onBindViewHolder
(
holder
,
groupHeaderPosition
);
//如果holder不是从当前吸顶布局取出来的,就需要把吸顶布局添加到容器里。
if
(!
flag
)
{
mStickyLayout
.
addView
(
holder
.
itemView
);
}
}
else
{
//如果当前组没有组头,则不显示吸顶布局。
//回收旧的吸顶布局。
recycle
();
}
}
if
(
mRecyclerView
.
computeVerticalScrollOffset
()
==
0
){
// 滑动到顶部
recycle
();
}
//这是是处理第一次打开时,吸顶布局已经添加到StickyLayout,但StickyLayout的高依然为0的情况。
if
(
mStickyLayout
.
getChildCount
()
>
0
&&
mStickyLayout
.
getHeight
()
==
0
)
{
mStickyLayout
.
requestLayout
();
}
//设置mStickyLayout的Y偏移量。
mStickyLayout
.
setTranslationY
(
calculateOffset
(
gAdapter
,
firstVisibleItem
,
groupPosition
+
1
));
}
}
/**
* 注册adapter刷新监听
*/
private
void
registerAdapterDataObserver
(
GroupedRecyclerViewAdapter
adapter
)
{
if
(!
isRegisterDataObserver
)
{
isRegisterDataObserver
=
true
;
adapter
.
registerAdapterDataObserver
(
new
RecyclerView
.
AdapterDataObserver
()
{
@Override
public
void
onChanged
()
{
updateStickyViewDelayed
();
}
@Override
public
void
onItemRangeChanged
(
int
positionStart
,
int
itemCount
)
{
updateStickyViewDelayed
();
}
@Override
public
void
onItemRangeInserted
(
int
positionStart
,
int
itemCount
)
{
updateStickyViewDelayed
();
}
@Override
public
void
onItemRangeRemoved
(
int
positionStart
,
int
itemCount
)
{
updateStickyViewDelayed
();
}
});
}
}
private
void
updateStickyViewDelayed
()
{
postDelayed
(
new
Runnable
()
{
@Override
public
void
run
()
{
updateStickyView
(
true
);
}
},
64
);
}
/**
* 判断是否需要先回收吸顶布局,如果要回收,则回收吸顶布局并返回null。
* 如果不回收,则返回吸顶布局的ViewHolder。
* 这样做可以避免频繁的添加和移除吸顶布局。
*
* @param viewType
* @return
*/
private
BaseViewHolder
recycleStickyView
(
int
viewType
)
{
if
(
mStickyLayout
.
getChildCount
()
>
0
)
{
View
view
=
mStickyLayout
.
getChildAt
(
0
);
int
type
=
(
int
)
view
.
getTag
(
VIEW_TAG_TYPE
);
if
(
type
==
viewType
)
{
return
(
BaseViewHolder
)
view
.
getTag
(
VIEW_TAG_HOLDER
);
}
else
{
recycle
();
}
}
return
null
;
}
/**
* 回收并移除吸顶布局
*/
private
void
recycle
()
{
mCurrentStickyGroup
=
-
1
;
if
(
mStickyLayout
.
getChildCount
()
>
0
)
{
View
view
=
mStickyLayout
.
getChildAt
(
0
);
mStickyViews
.
put
((
int
)
(
view
.
getTag
(
VIEW_TAG_TYPE
)),
(
BaseViewHolder
)
(
view
.
getTag
(
VIEW_TAG_HOLDER
)));
mStickyLayout
.
removeAllViews
();
}
}
/**
* 从缓存池中获取吸顶布局
*
* @param viewType 吸顶布局的viewType
* @return
*/
private
BaseViewHolder
getStickyViewByType
(
int
viewType
)
{
return
mStickyViews
.
get
(
viewType
);
}
/**
* 计算StickyLayout的偏移量。因为如果下一个组的组头顶到了StickyLayout,
* 就要把StickyLayout顶上去,直到下一个组的组头变成吸顶布局。否则会发生两个组头重叠的情况。
*
* @param gAdapter
* @param firstVisibleItem 当前列表显示的第一个项。
* @param groupPosition 下一个组的组下标。
* @return 返回偏移量。
*/
private
float
calculateOffset
(
GroupedRecyclerViewAdapter
gAdapter
,
int
firstVisibleItem
,
int
groupPosition
)
{
int
groupHeaderPosition
=
gAdapter
.
getPositionForGroupHeader
(
groupPosition
);
if
(
groupHeaderPosition
!=
-
1
)
{
int
index
=
groupHeaderPosition
-
firstVisibleItem
;
if
(
mRecyclerView
.
getChildCount
()
>
index
)
{
//获取下一个组的组头的itemView。
View
view
=
mRecyclerView
.
getChildAt
(
index
);
float
off
=
view
.
getY
()
-
mStickyLayout
.
getHeight
();
if
(
off
<
0
)
{
return
off
;
}
}
}
return
0
;
}
/**
* 获取当前第一个显示的item .
*/
private
int
getFirstVisibleItem
()
{
int
firstVisibleItem
=
-
1
;
RecyclerView
.
LayoutManager
layout
=
mRecyclerView
.
getLayoutManager
();
if
(
layout
!=
null
)
{
if
(
layout
instanceof
GridLayoutManager
)
{
firstVisibleItem
=
((
GridLayoutManager
)
layout
).
findFirstVisibleItemPosition
();
}
else
if
(
layout
instanceof
LinearLayoutManager
)
{
firstVisibleItem
=
((
LinearLayoutManager
)
layout
).
findFirstVisibleItemPosition
();
}
else
if
(
layout
instanceof
StaggeredGridLayoutManager
)
{
int
[]
firstPositions
=
new
int
[((
StaggeredGridLayoutManager
)
layout
).
getSpanCount
()];
((
StaggeredGridLayoutManager
)
layout
).
findFirstVisibleItemPositions
(
firstPositions
);
firstVisibleItem
=
getMin
(
firstPositions
);
}
}
return
firstVisibleItem
;
}
private
int
getMin
(
int
[]
arr
)
{
int
min
=
arr
[
0
];
for
(
int
x
=
1
;
x
<
arr
.
length
;
x
++)
{
if
(
arr
[
x
]
<
min
)
min
=
arr
[
x
];
}
return
min
;
}
/**
* 是否吸顶
*
* @return
*/
public
boolean
isSticky
()
{
return
isSticky
;
}
/**
* 设置是否吸顶。
*
* @param sticky
*/
public
void
setSticky
(
boolean
sticky
)
{
if
(
isSticky
!=
sticky
)
{
isSticky
=
sticky
;
if
(
mStickyLayout
!=
null
)
{
if
(
isSticky
)
{
mStickyLayout
.
setVisibility
(
VISIBLE
);
updateStickyView
(
false
);
}
else
{
recycle
();
mStickyLayout
.
setVisibility
(
GONE
);
}
}
}
}
@Override
protected
int
computeVerticalScrollOffset
()
{
if
(
mRecyclerView
!=
null
)
{
try
{
Method
method
=
View
.
class
.
getDeclaredMethod
(
"computeVerticalScrollOffset"
);
method
.
setAccessible
(
true
);
return
(
int
)
method
.
invoke
(
mRecyclerView
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
return
super
.
computeVerticalScrollOffset
();
}
@Override
protected
int
computeVerticalScrollRange
()
{
if
(
mRecyclerView
!=
null
)
{
try
{
Method
method
=
View
.
class
.
getDeclaredMethod
(
"computeVerticalScrollRange"
);
method
.
setAccessible
(
true
);
return
(
int
)
method
.
invoke
(
mRecyclerView
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
return
super
.
computeVerticalScrollRange
();
}
@Override
protected
int
computeVerticalScrollExtent
()
{
if
(
mRecyclerView
!=
null
)
{
try
{
Method
method
=
View
.
class
.
getDeclaredMethod
(
"computeVerticalScrollExtent"
);
method
.
setAccessible
(
true
);
return
(
int
)
method
.
invoke
(
mRecyclerView
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
return
super
.
computeVerticalScrollExtent
();
}
@Override
public
void
scrollBy
(
int
x
,
int
y
)
{
if
(
mRecyclerView
!=
null
)
{
mRecyclerView
.
scrollBy
(
x
,
y
);
}
else
{
super
.
scrollBy
(
x
,
y
);
}
}
@Override
public
void
scrollTo
(
int
x
,
int
y
)
{
if
(
mRecyclerView
!=
null
)
{
mRecyclerView
.
scrollTo
(
x
,
y
);
}
else
{
super
.
scrollTo
(
x
,
y
);
}
}
}
component-supply-chain/src/main/res/layout/fragment_buy_ingredients.xml
View file @
dfe4f9a3
...
...
@@ -172,19 +172,20 @@
android:layout_height=
"match_parent"
app:layout_behavior=
"@string/appbar_scrolling_view_behavior"
>
<com.qmuiteam.qmui.widget.section.QMUIStickySectionLayout
android:id=
"@+id/section_food_ingredients"
<com.gingersoft.supply_chain.mvp.ui.widget.StickyHeaderLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/
>
android:layout_height=
"match_parent"
>
</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"
/>
<!-- <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" />-->
</com.gingersoft.supply_chain.mvp.ui.widget.StickyHeaderLayout>
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
...
...
component-supply-chain/src/main/res/layout/fragment_warehouse_details.xml
View file @
dfe4f9a3
...
...
@@ -150,12 +150,6 @@
app:srlEnablePreviewInEditMode=
"true"
app:srlPrimaryColor=
"@color/trans"
>
<androidx.core.widget.NestedScrollView
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:fillViewport=
"true"
app:layout_behavior=
"@string/appbar_scrolling_view_behavior"
>
<!-- scrollview在代碼中要添加多個子view,所以多用一個LinearLayout包裹起來-->
<LinearLayout
android:id=
"@+id/layout_warehousing_root"
android:layout_width=
"match_parent"
...
...
@@ -170,8 +164,5 @@
android:layout_marginTop=
"@dimen/dp_10"
app:layout_behavior=
"@string/appbar_scrolling_view_behavior"
/>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
component-supply-chain/src/main/res/layout/item_show_sn_code.xml
0 → 100644
View file @
dfe4f9a3
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+id/layout_sn_code"
android:layout_width=
"match_parent"
android:layout_height=
"@dimen/dp_38"
android:background=
"@color/theme_color"
android:orientation=
"horizontal"
>
<TextView
android:id=
"@+id/tv_serial_number"
android:layout_width=
"0dp"
android:layout_height=
"match_parent"
android:layout_weight=
"0.21"
android:gravity=
"center"
android:text=
"@string/str_serial_number"
android:textColor=
"@color/white"
/>
<include
layout=
"@layout/include_vertical_color_e8_dividing_line"
/>
<TextView
android:id=
"@+id/tv_sn_code"
android:layout_width=
"0dp"
android:layout_height=
"match_parent"
android:layout_weight=
"0.55"
android:gravity=
"center"
android:text=
"@string/str_sn_code"
android:textColor=
"@color/white"
/>
<include
layout=
"@layout/include_vertical_color_e8_dividing_line"
/>
<FrameLayout
android:layout_width=
"@dimen/dp_0"
android:layout_height=
"match_parent"
android:layout_weight=
"0.24"
android:visibility=
"gone"
>
<ImageView
android:id=
"@+id/iv_sn_code_delete"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:src=
"@drawable/ic_delete"
android:visibility=
"gone"
/>
<TextView
android:id=
"@+id/it_sn_code_operating"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:text=
"@string/str_operating"
android:textColor=
"@color/white"
/>
</FrameLayout>
</LinearLayout>
\ No newline at end of file
component-supply-chain/src/main/res/layout/layout_print_consume.xml
View file @
dfe4f9a3
...
...
@@ -66,4 +66,15 @@
android:text=
"製單人:"
android:textColor=
"@color/theme_333_color"
android:textSize=
"@dimen/dp_14"
/>
<TextView
android:id=
"@+id/tv_print_sn"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"@dimen/dp_10"
android:layout_marginLeft=
"@dimen/dp_5"
android:text=
"@string/str_sn_codes"
android:textColor=
"@color/theme_333_color"
android:textSize=
"@dimen/dp_14"
/>
</LinearLayout>
\ No newline at end of file
component-supply-chain/src/main/res/layout/layout_show_sn.xml
0 → 100644
View file @
dfe4f9a3
<?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"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
>
<include
layout=
"@layout/item_show_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"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
app:layoutManager=
"androidx.recyclerview.widget.LinearLayoutManager"
/>
<View
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
</FrameLayout>
</LinearLayout>
\ No newline at end of file
component-supply-chain/src/main/res/values/strings.xml
View file @
dfe4f9a3
...
...
@@ -33,5 +33,5 @@
<string
name=
"str_no"
>
NO:%1$s
</string>
<string
name=
"str_prepared"
>
製單人:%1$s
</string>
<string
name=
"str_device_not_print"
>
您的設備不支持打印
</string>
<string
name=
"str_sn_codes"
>
SN嗎:%1$s
</string>
</resources>
\ No newline at end of file
component-supply-chain/src/main/res/values/values.xml
View file @
dfe4f9a3
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item
name=
"type_header"
type=
"integer"
/>
<item
name=
"type_footer"
type=
"integer"
/>
<item
name=
"type_child"
type=
"integer"
/>
<item
name=
"type_empty"
type=
"integer"
/>
</resources>
\ No newline at end of file
library-common/src/main/java/com/gingersoft/gsa/cloud/common/utils/CollectionUtils.java
View file @
dfe4f9a3
...
...
@@ -28,28 +28,39 @@ public class CollectionUtils {
}
/**
* 判断集合是否为null或者0个元素
*
* @param c
* @return
*/
public
static
boolean
isNotNullOrEmpty
(
Collection
c
)
{
return
!(
null
==
c
||
c
.
isEmpty
());
}
/**
* 调换集合中两个指定位置的元素, 若两个元素位置中间还有其他元素,需要实现中间元素的前移或后移的操作。
*
* @param list 集合
* @param oldPosition 需要调换的元素
* @param newPosition 被调换的元素
* @param <T>
*/
public
static
<
T
>
void
swap1
(
List
<
T
>
list
,
int
oldPosition
,
int
newPosition
){
if
(
null
==
list
)
{
public
static
<
T
>
void
swap1
(
List
<
T
>
list
,
int
oldPosition
,
int
newPosition
)
{
if
(
null
==
list
)
{
throw
new
IllegalStateException
(
"The list can not be empty..."
);
}
T
tempElement
=
list
.
get
(
oldPosition
);
// 向前移动,前面的元素需要向后移动
if
(
oldPosition
<
newPosition
)
{
for
(
int
i
=
oldPosition
;
i
<
newPosition
;
i
++)
{
if
(
oldPosition
<
newPosition
)
{
for
(
int
i
=
oldPosition
;
i
<
newPosition
;
i
++)
{
list
.
set
(
i
,
list
.
get
(
i
+
1
));
}
list
.
set
(
newPosition
,
tempElement
);
}
// 向后移动,后面的元素需要向前移动
if
(
oldPosition
>
newPosition
)
{
for
(
int
i
=
oldPosition
;
i
>
newPosition
;
i
--)
{
if
(
oldPosition
>
newPosition
)
{
for
(
int
i
=
oldPosition
;
i
>
newPosition
;
i
--)
{
list
.
set
(
i
,
list
.
get
(
i
-
1
));
}
list
.
set
(
newPosition
,
tempElement
);
...
...
@@ -58,6 +69,7 @@ public class CollectionUtils {
/**
* 调换集合中两个指定位置的元素, 若两个元素位置中间还有其他元素,需要实现中间元素的前移或后移的操作。
*
* @param list 集合
* @param oldPosition 需要调换的元素
* @param newPosition 被调换的元素
...
...
@@ -85,6 +97,7 @@ public class CollectionUtils {
/**
* 深拷貝一個list集合,改變當前集合不影響之前的集合數據
*
* @param src
* @param <E>
* @return
...
...
@@ -108,6 +121,7 @@ public class CollectionUtils {
/**
* 过滤List中为null的元素
*
* @param oldList
* @param <T>
* @return
...
...
@@ -115,7 +129,7 @@ public class CollectionUtils {
public
static
<
T
>
List
<
T
>
removeNull
(
List
<?
extends
T
>
oldList
)
{
// 临时集合
List
<
T
>
listTemp
=
new
ArrayList
();
for
(
int
i
=
0
;
i
<
oldList
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
oldList
.
size
();
i
++)
{
// 保存不为空的元素
if
(
oldList
.
get
(
i
)
!=
null
)
{
listTemp
.
add
(
oldList
.
get
(
i
));
...
...
@@ -123,4 +137,21 @@ public class CollectionUtils {
}
return
listTemp
;
}
/**
* 将list转换为带有,逗號的字符串
*/
public
static
String
listToCommaString
(
List
<
String
>
list
)
{
StringBuilder
sb
=
new
StringBuilder
();
if
(
list
!=
null
&&
list
.
size
()
>
0
)
{
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
if
(
i
<
list
.
size
()
-
1
)
{
sb
.
append
(
list
.
get
(
i
)
+
","
);
}
else
{
sb
.
append
(
list
.
get
(
i
));
}
}
}
return
sb
.
toString
();
}
}
library-database/src/main/java/com/gingersoft/gsa/cloud/database/bean/PrinterDeviceBean.java
View file @
dfe4f9a3
...
...
@@ -70,6 +70,8 @@ public class PrinterDeviceBean implements Serializable {
private
int
foodIsBold
;
//食品是否加粗 0預設 1是 2否
public
final
static
String
DEFAULT_FONT_SIZE
=
"0"
;
public
final
static
String
PRESET
=
"預設"
;
private
String
foodFont
;
//食品字體大小 0預設
private
int
foodIsItalic
;
//食品是否斜體 0預設 1是 2否
...
...
library-ui/src/main/res/layout/print_dot_matrix_kitchen.xml
View file @
dfe4f9a3
<?xml version="1.0" encoding="utf-8"?>
<
Linear
Layout
xmlns:android=
"http://schemas.android.com/apk/res/android"
<
androidx.constraintlayout.widget.Constraint
Layout
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,66 +14,43 @@
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
tools:text=
"頭單"
/>
android:text=
"頭單"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
<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:textSize=
"@dimen/sp_42"
android:textStyle=
"bold"
tools:text=
"外賣19"
/>
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/tv_kitchen_print_first_order"
/>
<View
android:layout_width=
"0dp"
android:layout_height=
"match_parent"
android:layout_weight=
"1"
/>
<!--預留-->
<TextView
android:id=
"@+id/tv_order_reserved"
style=
"@style/Print_kitchen_table_number_text_style"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
tools:text=
"預存"
android:textStyle=
"bold"
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>
android:visibility=
"gone"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/tv_kitchen_print_first_order"
/>
<TextView
android:id=
"@+id/tv_food_time"
style=
"@style/Print_
dot_matrix_normal
"
style=
"@style/Print_
eighteen_text
"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:visibility=
"visible"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/tv_kitchen_print_table_number"
tools:text=
"盡快送達"
/>
<!--落單時間-->
...
...
@@ -81,21 +58,23 @@
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_time_text"
style=
"@style/Print_
dot_matrix_normal
"
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_time"
style=
"@style/Print_
dot_matrix_normal
"
style=
"@style/Print_
eighteen_text
"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
tools
:text=
"01-04 19:32"
/>
android
:text=
"01-04 19:32"
/>
</LinearLayout>
<!--開台時間-->
...
...
@@ -103,21 +82,23 @@
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_opening_time_text"
style=
"@style/Print_
dot_matrix_normal
"
style=
"@style/Print_
eighteen_text
"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"開檯
:
"
/>
android:text=
"開檯
:
"
/>
<TextView
android:id=
"@+id/tv_opening_time"
style=
"@style/Print_
dot_matrix_normal
"
style=
"@style/Print_
eighteen_text
"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
tools
:text=
"01-20 12:00"
/>
android
:text=
"01-20 12:00"
/>
</LinearLayout>
<!--人數,廚房-->
...
...
@@ -126,56 +107,84 @@
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"@dimen/dp_5"
android:orientation=
"horizontal"
>
android:orientation=
"horizontal"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/ll_opening_table_time"
>
<TextView
android:id=
"@+id/tv_people_text"
style=
"@style/Print_
dot_matrix_normal
"
style=
"@style/Print_
eighteen_text
"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"人數
:
"
android:text=
"人數
:
"
android:visibility=
"visible"
/>
<TextView
android:id=
"@+id/tv_people"
style=
"@style/Print_
dot_matrix_normal
"
style=
"@style/Print_
eighteen_text
"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginRight=
"@dimen/dp_20"
android:visibility=
"visible"
tools:text=
"0"
/>
android:text=
"0"
android:visibility=
"visible"
/>
<TextView
android:id=
"@+id/tv_kitchen_location_text"
style=
"@style/Print_
dot_matrix_normal
"
style=
"@style/Print_
eighteen_text
"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"廚房:"
android:layout_marginLeft=
"@dimen/dp_20"
android:text=
"廚房:"
android:visibility=
"visible"
/>
<TextView
android:id=
"@+id/tv_kitchen_location"
style=
"@style/Print_
dot_matrix_normal
"
style=
"@style/Print_
eighteen_text
"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:
visibility=
"visible
"
tools:text=
"K1
"
/>
android:
text=
"
"
android:visibility=
"visible
"
/>
</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"
style=
"@style/Print_eighteen_text"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"單號:"
/>
<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"
>
android:orientation=
"horizontal"
app:layout_constraintLeft_toLeftOf=
"@+id/ll_order"
app:layout_constraintTop_toBottomOf=
"@+id/ll_order"
>
<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"
/>
...
...
@@ -193,21 +202,23 @@
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_waiter_text"
style=
"@style/Print_
dot_matrix_normal
"
style=
"@style/Print_
eighteen_text
"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"服務員
:
"
/>
android:text=
"服務員
:
"
/>
<TextView
android:id=
"@+id/tv_waiter"
style=
"@style/Print_
dot_matrix_normal
"
style=
"@style/Print_
eighteen_text
"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
tools
:text=
"GSPOS"
/>
android
:text=
"GSPOS"
/>
</LinearLayout>
<TextView
...
...
@@ -217,20 +228,16 @@
android:layout_marginTop=
"@dimen/dp_5"
android:maxLines=
"1"
android:text=
"————————————————————————————————————————————"
android:textSize=
"@dimen/sp_18"
/>
<!-- <androidx.recyclerview.widget.RecyclerView-->
<!-- android:id="@+id/rv_kitchen_food"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:visibility="visible"-->
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:layout_constraintTop_toBottomOf="@+id/line_kitchen_info"/>-->
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/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"
/>
...
...
@@ -239,6 +246,7 @@
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"
...
...
@@ -246,20 +254,14 @@
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/ll_kitchen_food"
/>
<!-- <TextView-->
<!-- android:id="@+id/tv_kitchen_print_table_number2"-->
<!-- 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="19"-->
<!-- android:textSize="@dimen/dp_48"-->
<!-- android:textStyle="bold" />-->
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"horizontal"
>
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"
>
<TextView
android:id=
"@+id/tv_prj_page_index"
...
...
@@ -277,9 +279,9 @@
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:gravity=
"center"
android:text=
"外賣19"
android:textSize=
"@dimen/sp_42"
android:textStyle=
"bold"
tools:text=
"外賣19"
/>
android:textStyle=
"bold"
/>
<TextView
android:id=
"@+id/tv_kitchen_print_quantity"
...
...
@@ -290,254 +292,4 @@
android:textSize=
"@dimen/sp_28"
tools:text=
"統計數量"
/>
</LinearLayout>
<!-- <LinearLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:orientation="vertical"-->
<!-- android:paddingBottom="@dimen/dp_10"-->
<!-- android:visibility="gone"-->
<!-- app:layout_constraintTop_toBottomOf="@+id/tv_kitchen_print_table_number">-->
<!-- <LinearLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:orientation="horizontal">-->
<!-- <LinearLayout-->
<!-- android:id="@+id/ll_left_layout"-->
<!-- android:layout_width="0dp"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_weight="1"-->
<!-- android:orientation="horizontal">-->
<!-- <TextView-->
<!-- android:id="@+id/tv_order_time_text"-->
<!-- style="@style/Print_text_style"-->
<!-- 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_time"-->
<!-- style="@style/Print_text_style"-->
<!-- 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" />-->
<!-- </LinearLayout>-->
<!-- <LinearLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:orientation="horizontal">-->
<!-- <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/dp_40" />-->
<!-- </LinearLayout>-->
<!-- <LinearLayout-->
<!-- android:id="@+id/layout_take_code"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- 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:textSize="@dimen/dp_20"-->
<!-- android:visibility="gone" />-->
<!-- <TextView-->
<!-- android:id="@+id/tv_take_code"-->
<!-- style="@style/Print_text_style"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:textSize="@dimen/dp_20"-->
<!-- android:visibility="gone" />-->
<!-- </LinearLayout>-->
<!-- <LinearLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:orientation="horizontal">-->
<!-- <TextView-->
<!-- android:id="@+id/tv_order_time_text"-->
<!-- style="@style/Print_text_style"-->
<!-- 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_time"-->
<!-- style="@style/Print_text_style"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:text="01-04 19:32"-->
<!-- android:textSize="@dimen/dp_28" />-->
<!-- </LinearLayout>-->
<!-- <TextView-->
<!-- android:id="@+id/tv_food_time"-->
<!-- style="@style/Print_text_style"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:textSize="@dimen/dp_28"-->
<!-- android:visibility="gone"-->
<!-- tools:text="盡快送達" />-->
<!-- <LinearLayout-->
<!-- android:id="@+id/layout_opening_table_time"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:orientation="horizontal">-->
<!-- <TextView-->
<!-- android:id="@+id/tv_opening_time_text"-->
<!-- style="@style/Print_text_style"-->
<!-- 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_opening_time"-->
<!-- style="@style/Print_text_style"-->
<!-- 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" />-->
<!-- </LinearLayout>-->
<!-- <LinearLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:gravity="center_vertical"-->
<!-- android:orientation="horizontal">-->
<!-- <TextView-->
<!-- android:id="@+id/tv_kitchen_location"-->
<!-- style="@style/Print_text_style"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginRight="@dimen/dp_20"-->
<!-- android:text="K1 廚房" />-->
<!-- <TextView-->
<!-- android:id="@+id/tv_operator"-->
<!-- style="@style/Print_text_style"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:text="gsadmin" />-->
<!-- </LinearLayout>-->
<!-- <LinearLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:orientation="horizontal">-->
<!-- <TextView-->
<!-- android:id="@+id/tv_people_text"-->
<!-- style="@style/Print_text_style"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:text="人數:"-->
<!-- android:textColor="@color/black"-->
<!-- android:textSize="@dimen/sp_18"-->
<!-- android:visibility="visible" />-->
<!-- <TextView-->
<!-- android:id="@+id/tv_people"-->
<!-- style="@style/Print_text_style"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:text="1000"-->
<!-- android:textColor="@color/black"-->
<!-- android:textSize="@dimen/sp_18"-->
<!-- android:visibility="visible" />-->
<!-- </LinearLayout>-->
<!-- <TextView-->
<!-- android:id="@+id/line_kitchen_info"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- 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="visible" />-->
<!-- <LinearLayout-->
<!-- android:id="@+id/layout_kitchen_food"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginTop="@dimen/dp_10"-->
<!-- android:orientation="vertical" />-->
<!-- <TextView-->
<!-- android:id="@+id/tv_kitchen_print_table_number2"-->
<!-- 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="19"-->
<!-- android:textSize="@dimen/dp_48"-->
<!-- android:textStyle="bold" />-->
<!-- <RelativeLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginTop="@dimen/dp_20"-->
<!-- android:orientation="horizontal">-->
<!-- <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"-->
<!-- tools:text="1/2" />-->
<!-- <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"-->
<!-- tools:text="統計數量" />-->
<!-- </RelativeLayout>-->
<!-- </LinearLayout>-->
</LinearLayout>
\ No newline at end of file
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
library-ui/src/main/res/layout/print_kitchen.xml
View file @
dfe4f9a3
...
...
@@ -45,7 +45,7 @@
<TextView
android:id=
"@+id/tv_food_time"
style=
"@style/Print_
eighteen_text
"
style=
"@style/Print_
dot_matrix_normal
"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:visibility=
"visible"
...
...
@@ -64,14 +64,14 @@
<TextView
android:id=
"@+id/tv_order_time_text"
style=
"@style/Print_
eighteen_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_time"
style=
"@style/Print_
eighteen_text
"
style=
"@style/Print_
dot_matrix_normal
"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"01-04 19:32"
/>
...
...
@@ -88,14 +88,14 @@
<TextView
android:id=
"@+id/tv_opening_time_text"
style=
"@style/Print_
eighteen_text
"
style=
"@style/Print_
dot_matrix_normal
"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"開檯:"
/>
<TextView
android:id=
"@+id/tv_opening_time"
style=
"@style/Print_
eighteen_text
"
style=
"@style/Print_
dot_matrix_normal
"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"01-20 12:00"
/>
...
...
@@ -113,7 +113,7 @@
<TextView
android:id=
"@+id/tv_people_text"
style=
"@style/Print_
eighteen_text
"
style=
"@style/Print_
dot_matrix_normal
"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"人數:"
...
...
@@ -121,7 +121,7 @@
<TextView
android:id=
"@+id/tv_people"
style=
"@style/Print_
eighteen_text
"
style=
"@style/Print_
dot_matrix_normal
"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"0"
...
...
@@ -129,7 +129,7 @@
<TextView
android:id=
"@+id/tv_kitchen_location_text"
style=
"@style/Print_
eighteen_text
"
style=
"@style/Print_
dot_matrix_normal
"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginLeft=
"@dimen/dp_20"
...
...
@@ -138,7 +138,7 @@
<TextView
android:id=
"@+id/tv_kitchen_location"
style=
"@style/Print_
eighteen_text
"
style=
"@style/Print_
dot_matrix_normal
"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
""
...
...
@@ -156,7 +156,7 @@
<TextView
android:id=
"@+id/tv_order_num_text"
style=
"@style/Print_
eighteen_text
"
style=
"@style/Print_
dot_matrix_normal
"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"單號:"
/>
...
...
@@ -208,14 +208,14 @@
<TextView
android:id=
"@+id/tv_waiter_text"
style=
"@style/Print_
eighteen_text
"
style=
"@style/Print_
dot_matrix_normal
"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"服務員:"
/>
<TextView
android:id=
"@+id/tv_waiter"
style=
"@style/Print_
eighteen_text
"
style=
"@style/Print_
dot_matrix_normal
"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"GSPOS"
/>
...
...
library-ui/src/main/res/values/style.xml
View file @
dfe4f9a3
...
...
@@ -35,6 +35,7 @@
<item
name=
"android:includeFontPadding"
>
false
</item>
</style>
<style
name=
"Print_thermal_printing_normal"
parent=
"@style/Print_twenty_four_text"
/>
<style
name=
"Print_dot_matrix_normal"
parent=
"@style/Print_twenty_six_text"
/>
</resources>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment