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
d315d8ac
Commit
d315d8ac
authored
Feb 24, 2021
by
Wyh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1、針式打印prj重複問題 2、打印進度
parent
a4496333
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
59 additions
and
97 deletions
+59
-97
component-print/build.gradle
+1
-0
component-print/src/main/java/com/joe/print/mvp/print/EpsonPrint.java
+23
-17
component-print/src/main/java/com/joe/print/mvp/print/PrinterRoot.java
+14
-7
component-print/src/main/java/com/joe/print/mvp/print/service/PrjService.java
+3
-5
component-print/src/main/java/com/joe/print/mvp/ui/view/PrinterLoadingDialog.java
+17
-67
config.gradle
+1
-1
No files found.
component-print/build.gradle
View file @
d315d8ac
...
...
@@ -52,5 +52,6 @@ dependencies {
releaseImplementation
rootProject
.
ext
.
dependencies
[
"canary-release"
]
testImplementation
rootProject
.
ext
.
dependencies
[
"canary-release"
]
testImplementation
rootProject
.
ext
.
dependencies
[
"junit"
]
implementation
rootProject
.
ext
.
dependencies
[
"lottie"
]
implementation
files
(
'libs/ePOS2.jar'
)
}
component-print/src/main/java/com/joe/print/mvp/print/EpsonPrint.java
View file @
d315d8ac
...
...
@@ -287,7 +287,7 @@ public class EpsonPrint implements ReceiveListener {
}
private
void
printData
(
String
ip
,
Bitmap
bitmap
)
{
PrinterPlugins
.
getOnPrinterFlowHandler
().
connectionBefore
(
"針式打印機開始連接"
,
ip
,
0
,
0
,
0
);
PrinterPlugins
.
getOnPrinterFlowHandler
().
onPrinterDataBefore
(
0
,
0
,
"針式打印機"
,
ip
);
mPrinter
.
clearCommandBuffer
();
Log
.
d
(
"eee"
,
"針式打印機創建數據中,任務數:"
+
bitmaps
.
size
());
if
(!
createPrintData
(
bitmap
))
{
...
...
@@ -301,32 +301,31 @@ public class EpsonPrint implements ReceiveListener {
}
//連接打印機
connectByIp
(
ip
,
mPrinter
.
getStatus
());
if
(
mPrinter
==
null
)
{
Log
.
d
(
"eee"
,
"針式打印機為空"
);
//連接失敗
updatePrintState
(
PrintSocketHolder
.
ERROR_7
);
PrinterPlugins
.
getOnPrinterFlowHandler
().
connectionError
(
new
ConnectException
(
"針式打印機連接失敗"
+
ip
));
isPrint
=
false
;
return
;
}
//獲取打印機狀態
PrinterStatusInfo
statusInfo
=
mPrinter
.
getStatus
();
Log
.
d
(
"eee"
,
"針式打印機:"
+
"紙張狀態:"
+
statusInfo
.
getPaper
()
+
"連接狀態:"
+
statusInfo
.
getConnection
()
+
",任務數:"
+
bitmaps
.
size
());
if
(
statusInfo
.
getPaper
()
==
2
)
{
//沒紙了
updatePrintState
(
PrintSocketHolder
.
ERROR_11
);
PrinterPlugins
.
getOnPrinterFlowHandler
().
connectionError
(
new
Exception
(
"針式打印機缺紙,打印失敗"
+
ip
));
isPrint
=
false
;
return
;
}
else
if
(
statusInfo
.
getConnection
()
!=
1
)
{
if
(
statusInfo
.
getConnection
()
!=
1
)
{
//未連接到打印機
updatePrintState
(
PrintSocketHolder
.
ERROR_7
);
PrinterPlugins
.
getOnPrinterFlowHandler
().
connectionError
(
new
ConnectException
(
"針式打印機連接失敗"
+
ip
));
isPrint
=
false
;
return
;
}
else
if
(
statusInfo
.
getPaper
()
!=
0
)
{
//紙張不正常
if
(
statusInfo
.
getPaper
()
==
2
)
{
//沒紙了
updatePrintState
(
PrintSocketHolder
.
ERROR_11
);
PrinterPlugins
.
getOnPrinterFlowHandler
().
connectionError
(
new
Exception
(
"針式打印機缺紙,打印失敗"
+
ip
));
}
else
{
//紙張狀態異常
updatePrintState
(
PrintSocketHolder
.
ERROR_11
);
PrinterPlugins
.
getOnPrinterFlowHandler
().
connectionError
(
new
Exception
(
"針式打印機紙張異常,請重啟打印機"
+
ip
));
}
isPrint
=
false
;
return
;
}
try
{
mPrinter
.
sendData
(
Printer
.
PARAM_DEFAULT
);
isPrint
=
false
;
PrinterPlugins
.
getOnPrinterFlowHandler
().
onPrintSuccess
();
Log
.
d
(
"eee"
,
"針式打印機打印成功"
+
",任務數:"
+
bitmaps
.
size
());
}
catch
(
Exception
e
)
{
...
...
@@ -407,6 +406,13 @@ public class EpsonPrint implements ReceiveListener {
}
}
/**
* 打印結果回調
* @param printer 打印類
* @param i 打印結果
* @param printerStatusInfo 打印機狀態
* @param s
*/
@Override
public
void
onPtrReceive
(
Printer
printer
,
int
i
,
PrinterStatusInfo
printerStatusInfo
,
String
s
)
{
this
.
mPrinter
=
printer
;
...
...
component-print/src/main/java/com/joe/print/mvp/print/PrinterRoot.java
View file @
d315d8ac
...
...
@@ -9,6 +9,7 @@ import android.os.Build;
import
android.os.IBinder
;
import
android.os.RemoteException
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
android.util.SparseArray
;
import
android.view.Gravity
;
import
android.view.View
;
...
...
@@ -74,6 +75,8 @@ import com.joe.print.mvp.ui.view.BillTypeView;
import
com.joe.print.mvp.ui.view.BillView
;
import
com.joe.print.mvp.ui.view.PrintFoodView
;
import
com.sunmi.peripheral.printer.InnerResultCallbcak
;
import
com.xuexiang.rxutil2.rxjava.RxJavaUtils
;
import
com.xuexiang.rxutil2.rxjava.task.RxIOTask
;
import
java.io.IOException
;
import
java.util.ArrayList
;
...
...
@@ -333,14 +336,17 @@ public abstract class PrinterRoot<T extends PrintContent> implements PrintSocket
if
((
printerDeviceBean
.
getPrinterName
()
!=
null
&&
printerDeviceBean
.
getPrinterName
().
toLowerCase
().
contains
(
"EPSON"
.
toLowerCase
())))
{
if
(
printerDeviceBean
.
getModel
()
!=
null
)
{
if
(
printerDeviceBean
.
getModel
().
toLowerCase
().
contains
(
"TM-U220B"
.
toLowerCase
()))
{
ThreadPoolManager
.
getInstence
().
putExecutableTasks
(()
->
{
EpsonPrint
mPrinter
=
new
EpsonPrint
();
mPrinter
.
initializeObject
(
GsaCloudApplication
.
getAppContext
(),
PrinterRoot
.
this
,
PrinterRoot
.
this
);
for
(
int
j
=
0
;
j
<
bitmaps
.
size
();
j
++)
{
mPrinter
.
putPrintData
(
printerDeviceBean
.
getIp
(),
bitmaps
.
get
(
j
),
""
);
}
RxJavaUtils
.
doInIOThread
(
new
RxIOTask
<
Object
>(
0
)
{
@Override
public
Void
doInIOThread
(
Object
o
)
{
EpsonPrint
mPrinter
=
new
EpsonPrint
();
mPrinter
.
initializeObject
(
GsaCloudApplication
.
getAppContext
(),
PrinterRoot
.
this
,
PrinterRoot
.
this
);
for
(
int
j
=
0
;
j
<
bitmaps
.
size
();
j
++)
{
mPrinter
.
putPrintData
(
printerDeviceBean
.
getIp
(),
bitmaps
.
get
(
j
),
""
);
}
);
return
null
;
}
});
return
;
}
}
...
...
@@ -434,6 +440,7 @@ public abstract class PrinterRoot<T extends PrintContent> implements PrintSocket
@Override
public
void
onResult
(
int
errorCode
)
{
Log
.
e
(
"eee"
,
"打印結果:"
+
errorCode
);
switch
(
errorCode
)
{
case
PrintSocketHolder
.
ERROR_0
:
PrinterPlugins
.
getOnPrinterFlowHandler
().
onPrintSuccess
();
...
...
component-print/src/main/java/com/joe/print/mvp/print/service/PrjService.java
View file @
d315d8ac
...
...
@@ -512,14 +512,12 @@ public class PrjService extends Service implements ReceiveListener {
List
<
Map
<
String
,
Bitmap
>>
bitmapMaps
=
generatePrintMaps
(
key
,
beans
,
printerDeviceBean
);
//將打印的圖片保存到手機中
hookPrinterBitmap
(
bitmapMaps
,
beans
);
//獲取prj的id集合
String
epsonIds
=
getPrintIds
(
bitmapMaps
);
EpsonPrint
mPrinter
=
EpsonPrint
.
getInstance
();
boolean
initResult
=
EpsonPrint
.
getInstance
().
initializeObject
(
this
,
this
,
errorCode
->
updatePrjState
(
errorCode
,
epsonIds
));
boolean
initResult
=
EpsonPrint
.
getInstance
().
initializeObject
(
this
,
this
,
errorCode
->
updatePrjState
(
errorCode
,
getPrintIds
(
bitmapMaps
)
));
if
(!
initResult
)
{
//初始化打印機失敗
updatePrjState
(
UpdateBean
.
FAIL_EPSON_INIT
,
epsonIds
);
updatePrjState
(
UpdateBean
.
FAIL_EPSON_INIT
,
getPrintIds
(
bitmapMaps
)
);
return
;
}
PrinterPlugins
.
getOnPrinterFlowHandler
().
connectionBefore
(
"針式打印機"
+
bitmapMaps
.
size
(),
printerDeviceBean
.
getIp
(),
printerDeviceBean
.
getPort
(),
0
,
0
);
...
...
@@ -744,7 +742,7 @@ public class PrjService extends Service implements ReceiveListener {
updatePrjSuccess
(
ids
);
}
else
{
//打印失敗
updatePrj
Failure
(
ids
);
updatePrj
State
(
i
,
ids
);
PrinterPlugins
.
getOnPrinterFlowHandler
().
onPrintError
(
null
,
i
);
}
}
...
...
component-print/src/main/java/com/joe/print/mvp/ui/view/PrinterLoadingDialog.java
View file @
d315d8ac
...
...
@@ -5,23 +5,19 @@ import android.content.Context;
import
android.graphics.drawable.Drawable
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.os.Looper
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.LinearLayout
;
import
android.widget.TextView
;
import
androidx.annotation.NonNull
;
import
androidx.core.content.ContextCompat
;
import
com.airbnb.lottie.LottieAnimationView
;
import
com.gingersoft.gsa.cloud.pay.pos.hywebpos.constant.HywebActionStatusCode
;
import
com.gingersoft.gsa.cloud.ui.widget.dialog.BaseRetryDialog
;
import
com.joe.print.R
;
import
com.qmuiteam.qmui.layout.QMUILinearLayout
;
import
com.qmuiteam.qmui.util.QMUIDisplayHelper
;
import
butterknife.BindDrawable
;
/**
* 作者:ELEGANT_BIN
* 版本:1.6.0
...
...
@@ -56,6 +52,10 @@ public class PrinterLoadingDialog extends BaseRetryDialog {
super
(
context
,
R
.
style
.
MyDialogTheme2
);
mContext
=
context
;
mRadius
=
QMUIDisplayHelper
.
dp2px
(
mContext
,
8
);
drawables
=
new
Drawable
[
3
];
drawables
[
0
]
=
getDrawableByResId
(
R
.
drawable
.
print_grey_point
);
drawables
[
1
]
=
getDrawableByResId
(
R
.
drawable
.
print_green_point
);
drawables
[
2
]
=
getDrawableByResId
(
R
.
drawable
.
print_red_point
);
}
@Override
...
...
@@ -92,13 +92,13 @@ public class PrinterLoadingDialog extends BaseRetryDialog {
tv_printing
=
view
.
findViewById
(
R
.
id
.
tv_printing
);
tv_print_result
=
view
.
findViewById
(
R
.
id
.
tv_print_result
);
textViews
=
new
TextView
[]{
tv_generate_print_data
,
tv_connecting
,
tv_printing
,
tv_print_result
};
ll_container
.
setRadiusAndShadow
(
mRadius
,
QMUIDisplayHelper
.
dp2px
(
mContext
,
mShadowElevationDp
),
mShadowAlpha
);
printLottieView
.
setAnimation
(
R
.
raw
.
printer_loading3
);
printLottieView
.
loop
(
true
);
printLottieView
.
setRepeatCount
(
ValueAnimator
.
INFINITE
);
// printLottieView.addAnimatorUpdateListener((animation) -> {
// // Do something.动画状态监听回调
//
// });
printLottieView
.
playAnimation
();
//播放动画
// //progress范围0~1f,设置动画进度
...
...
@@ -109,73 +109,23 @@ public class PrinterLoadingDialog extends BaseRetryDialog {
return
view
;
}
private
Drawable
[]
drawables
;
private
TextView
[]
textViews
;
public
void
setStep
(
int
step
,
int
status
)
{
tv_generate_print_data
.
post
(
new
Runnable
()
{
@Override
public
void
run
()
{
switch
(
step
)
{
case
1
:
if
(
status
==
PrinterLoadingDialog
.
status_success
)
{
tv_generate_print_data
.
setCompoundDrawables
(
null
,
getDrawableByResId
(
R
.
drawable
.
print_green_point
),
null
,
null
);
}
else
if
(
status
==
PrinterLoadingDialog
.
status_error
)
{
tv_generate_print_data
.
setCompoundDrawables
(
null
,
getDrawableByResId
(
R
.
drawable
.
print_red_point
),
null
,
null
);
}
else
{
tv_generate_print_data
.
setCompoundDrawables
(
null
,
getDrawableByResId
(
R
.
drawable
.
print_grey_point
),
null
,
null
);
}
break
;
case
2
:
if
(
status
==
PrinterLoadingDialog
.
status_success
)
{
tv_connecting
.
setCompoundDrawables
(
null
,
getDrawableByResId
(
R
.
drawable
.
print_green_point
),
null
,
null
);
}
else
if
(
status
==
PrinterLoadingDialog
.
status_error
)
{
tv_connecting
.
setCompoundDrawables
(
null
,
getDrawableByResId
(
R
.
drawable
.
print_red_point
),
null
,
null
);
}
else
{
tv_connecting
.
setCompoundDrawables
(
null
,
getDrawableByResId
(
R
.
drawable
.
print_grey_point
),
null
,
null
);
}
break
;
case
3
:
if
(
status
==
PrinterLoadingDialog
.
status_success
)
{
tv_printing
.
setCompoundDrawables
(
null
,
getDrawableByResId
(
R
.
drawable
.
print_green_point
),
null
,
null
);
}
else
if
(
status
==
PrinterLoadingDialog
.
status_error
)
{
tv_printing
.
setCompoundDrawables
(
null
,
getDrawableByResId
(
R
.
drawable
.
print_red_point
),
null
,
null
);
}
else
{
tv_printing
.
setCompoundDrawables
(
null
,
getDrawableByResId
(
R
.
drawable
.
print_grey_point
),
null
,
null
);
}
break
;
case
4
:
if
(
status
==
PrinterLoadingDialog
.
status_success
)
{
tv_print_result
.
setCompoundDrawables
(
null
,
getDrawableByResId
(
R
.
drawable
.
print_green_point
),
null
,
null
);
}
else
if
(
status
==
PrinterLoadingDialog
.
status_error
)
{
tv_print_result
.
setCompoundDrawables
(
null
,
getDrawableByResId
(
R
.
drawable
.
print_red_point
),
null
,
null
);
}
else
{
tv_print_result
.
setCompoundDrawables
(
null
,
getDrawableByResId
(
R
.
drawable
.
print_grey_point
),
null
,
null
);
}
break
;
default
:
break
;
}
}
});
tv_generate_print_data
.
post
(()
->
setCompoundDrawableByStatus
(
status
,
textViews
[
step
-
1
]));
}
private
Drawable
getDrawableByResId
(
int
resId
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
return
mContext
.
getDrawable
(
resId
);
}
return
mContext
.
getResources
().
getDrawable
(
resId
);
}
private
void
setCompoundDrawableByStatus
(
int
status
,
TextView
textView
)
{
textView
.
setCompoundDrawablesWithIntrinsicBounds
(
textView
.
getCompoundDrawables
()[
0
],
drawables
[
status
],
textView
.
getCompoundDrawables
()[
2
],
textView
.
getCompoundDrawables
()[
0
]);
protected
int
getContentViewLayoutId
()
{
return
R
.
layout
.
print_dialog_loading
;
}
private
OnClickListener
onClickListener
;
public
void
setOnClickListener
(
OnClickListener
onClickListener
)
{
this
.
onClickListener
=
onClickListener
;
private
Drawable
getDrawableByResId
(
int
resId
)
{
return
ContextCompat
.
getDrawable
(
mContext
,
resId
);
}
p
ublic
interface
OnClickListener
{
// void onItemClick(FoodReason item, int position, int deleteNumber)
;
p
rotected
int
getContentViewLayoutId
()
{
return
R
.
layout
.
print_dialog_loading
;
}
}
config.gradle
View file @
d315d8ac
...
...
@@ -66,7 +66,7 @@ ext {
"paginate"
:
"com.github.markomilos:paginate:0.5.1"
,
"vlayout"
:
"com.alibaba.android:vlayout:1.1.0@aar"
,
"loadsir"
:
"com.kingja.loadsir:loadsir:1.3.8"
,
"lottie"
:
"com.airbnb.android:lottie:
2.7.0
"
,
"lottie"
:
"com.airbnb.android:lottie:
3.6.1
"
,
//rx1
"rxandroid"
:
"io.reactivex:rxandroid:1.2.1"
,
...
...
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