Commit 3b0dd154 authored by 王雷's avatar 王雷

修改打印

parent 9bd85c78
...@@ -47,14 +47,14 @@ gradlePublish { ...@@ -47,14 +47,14 @@ gradlePublish {
releaseRepository { releaseRepository {
url = "https://hub.zmcms.cn/repository/maven-releases/" url = "https://hub.zmcms.cn/repository/maven-releases/"
userName = "wangwei" userName = "wanglei1"
password = "caihong520" password = "woshiwanglei123"
} }
snapshotRepository { snapshotRepository {
url = "https://hub.zmcms.cn/repository/maven-snapshots/" url = "https://hub.zmcms.cn/repository/maven-snapshots/"
userName = "wangwei" userName = "wanglei1"
password = "caihong520" password = "woshiwanglei123"
} }
} }
...@@ -19,7 +19,7 @@ buildscript { ...@@ -19,7 +19,7 @@ buildscript {
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.6.0' classpath 'com.android.tools.build:gradle:3.5.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
# http://www.gradle.org/docs/current/userguide/build_environment.html # http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process. # Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings. # The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode. # When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit # This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
......
...@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME ...@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
...@@ -51,7 +51,7 @@ repositories { ...@@ -51,7 +51,7 @@ repositories {
} }
group 'com.qmai.android.print' group 'com.qmai.android.print'
version '1.1.6-SNAPSHOT' version '1.1.7-SNAPSHOT'
gradlePublish { gradlePublish {
...@@ -61,14 +61,14 @@ gradlePublish { ...@@ -61,14 +61,14 @@ gradlePublish {
releaseRepository { releaseRepository {
url = "https://hub.zmcms.cn/repository/maven-releases/" url = "https://hub.zmcms.cn/repository/maven-releases/"
userName = "wangwei" userName = "wanglei1"
password = "caihong520" password = "woshiwanglei123"
} }
snapshotRepository { snapshotRepository {
url = "https://hub.zmcms.cn/repository/maven-snapshots/" url = "https://hub.zmcms.cn/repository/maven-snapshots/"
userName = "wangwei" userName = "wanglei1"
password = "caihong520" password = "woshiwanglei123"
} }
} }
...@@ -6,6 +6,7 @@ import android.util.Log ...@@ -6,6 +6,7 @@ import android.util.Log
import zs.qimai.com.printer2.callback.PrintConnOrDisCallBack import zs.qimai.com.printer2.callback.PrintConnOrDisCallBack
import zs.qimai.com.printer2.manager.DeviceManager.Companion.BT import zs.qimai.com.printer2.manager.DeviceManager.Companion.BT
import zs.qimai.com.printer2.manager.DeviceManager.Companion.USB import zs.qimai.com.printer2.manager.DeviceManager.Companion.USB
import java.util.concurrent.CopyOnWriteArrayList
/***** /*****
* 打印设备管理 * 打印设备管理
...@@ -15,9 +16,9 @@ import zs.qimai.com.printer2.manager.DeviceManager.Companion.USB ...@@ -15,9 +16,9 @@ import zs.qimai.com.printer2.manager.DeviceManager.Companion.USB
class DeviceManagerUtils { class DeviceManagerUtils {
private val TAG = "DeviceManagerUtils" private val TAG = "DeviceManagerUtils"
private var mCallBacklist: ArrayList<PrintConnOrDisCallBack> = ArrayList() private var mCallBacklist: CopyOnWriteArrayList<PrintConnOrDisCallBack> = CopyOnWriteArrayList()
var lists: java.util.ArrayList<DeviceManager> = java.util.ArrayList() var lists: CopyOnWriteArrayList<DeviceManager> = CopyOnWriteArrayList()
internal fun addDevice(deviceManager: DeviceManager?) { internal fun addDevice(deviceManager: DeviceManager?) {
deviceManager?.let { deviceManager?.let {
...@@ -51,6 +52,7 @@ class DeviceManagerUtils { ...@@ -51,6 +52,7 @@ class DeviceManagerUtils {
if (it.usbDevice == device) { if (it.usbDevice == device) {
//closePort()会清除所有配置项,并调用removeDevice() //closePort()会清除所有配置项,并调用removeDevice()
it.closePort() it.closePort()
return@forEach
// notifyRemoveObserver(it) // notifyRemoveObserver(it)
//lists.remove(it) //lists.remove(it)
} }
......
...@@ -5,7 +5,6 @@ import android.util.Log ...@@ -5,7 +5,6 @@ import android.util.Log
import zs.qimai.com.printer2.callback.UsbPrintConnCallBack import zs.qimai.com.printer2.callback.UsbPrintConnCallBack
import zs.qimai.com.printer2.printStatus.PrintStatusCallBack import zs.qimai.com.printer2.printStatus.PrintStatusCallBack
import zs.qimai.com.printer2.printStatus.PrinterStatusUtils import zs.qimai.com.printer2.printStatus.PrinterStatusUtils
import zs.qimai.com.printer2.utils.PrintManagerUtils.Companion.PRINT_MODE_NOT_SUPPORT
import zs.qimai.com.printer2.utils.PrintManagerUtils.Companion.USB_CONN_FAILED import zs.qimai.com.printer2.utils.PrintManagerUtils.Companion.USB_CONN_FAILED
import zs.qimai.com.printer2.utils.PrintManagerUtils.Companion.USB_DEVICE_INFO_NOT_FOUND import zs.qimai.com.printer2.utils.PrintManagerUtils.Companion.USB_DEVICE_INFO_NOT_FOUND
...@@ -49,17 +48,10 @@ class UsbDeviceManager(override var mType: Int = USB) : DeviceManager() { ...@@ -49,17 +48,10 @@ class UsbDeviceManager(override var mType: Int = USB) : DeviceManager() {
PrinterStatusUtils(this).apply { PrinterStatusUtils(this).apply {
mPrintStatusCallBack = object : PrintStatusCallBack { mPrintStatusCallBack = object : PrintStatusCallBack {
override fun searchResult(status: Int?) { override fun searchResult(status: Int?) {
if (status == null) { mPrintMode = status ?: DeviceManager.ESC
mUsbPrintConnCallBack?.onConnFailed( mStatus = true
PRINT_MODE_NOT_SUPPORT, DeviceManagerUtils.getInstance().addDevice(this@UsbDeviceManager)
"获取不到该打印机支持的模式" mUsbPrintConnCallBack?.onConnSucess(this@UsbDeviceManager)
)
} else {
mPrintMode = status
mStatus = true
DeviceManagerUtils.getInstance().addDevice(this@UsbDeviceManager)
mUsbPrintConnCallBack?.onConnSucess(this@UsbDeviceManager)
}
} }
} }
}.queryStatus() }.queryStatus()
......
...@@ -161,8 +161,8 @@ open class PrintWriter(var maxLineChars:Int = 32 ) { ...@@ -161,8 +161,8 @@ open class PrintWriter(var maxLineChars:Int = 32 ) {
* ps 红烧肉 【*10】 100 * ps 红烧肉 【*10】 100
* **/ * **/
fun formatGoods(goodsName: String, nums: String, price: String): String { fun formatGoods(goodsName: String, nums: String, price: String,needBytes: Int = 16): String {
var formatGoodsName = fixedNumberOfDigits(goodsName, 16) var formatGoodsName = fixedNumberOfDigits(goodsName, needBytes)
var numsLength = getPerLineMaxByteNums() - getBytesSize(formatGoodsName) - 10 var numsLength = getPerLineMaxByteNums() - getBytesSize(formatGoodsName) - 10
var formatNums = fixedNumberOfDigits(nums, numsLength, 2) var formatNums = fixedNumberOfDigits(nums, numsLength, 2)
var formatPrice = fixedNumberOfDigits(price, 10, 2) var formatPrice = fixedNumberOfDigits(price, 10, 2)
...@@ -170,12 +170,20 @@ open class PrintWriter(var maxLineChars:Int = 32 ) { ...@@ -170,12 +170,20 @@ open class PrintWriter(var maxLineChars:Int = 32 ) {
if (formatGoodsName.length < goodsName.length) { if (formatGoodsName.length < goodsName.length) {
endGoodsName.append(goodsName.substring(formatGoodsName.length, goodsName.length)) endGoodsName.append(goodsName.substring(formatGoodsName.length, goodsName.length))
} }
if (endGoodsName.isNullOrBlank()){
return StringBuilder(formatGoodsName)
.append(formatNums)
.append(formatPrice)
.append(endGoodsName)
.toString()
}else{
return StringBuilder(formatGoodsName) return StringBuilder(formatGoodsName)
.append(formatNums) .append(formatNums)
.append(formatPrice) .append(formatPrice)
.append(endGoodsName) .append("\n")
.append(endGoodsName)
.toString() .toString()
} }}
/**** /****
* *
......
...@@ -39,14 +39,14 @@ complete example: ...@@ -39,14 +39,14 @@ complete example:
releaseRepository { releaseRepository {
url = "https://hub.zmcms.cn/repository/maven-public/" url = "https://hub.zmcms.cn/repository/maven-public/"
userName = "wangwei" userName = "wanglei1"
password = "caihong520" password = "woshiwanglei123"
} }
snapshotRepository { snapshotRepository {
url = "https://hub.zmcms.cn/repository/maven-snapshots/" url = "https://hub.zmcms.cn/repository/maven-snapshots/"
userName = "wangwei" userName = "wanglei1"
password = "caihong520" password = "woshiwanglei123"
} }
} }
......
...@@ -52,14 +52,14 @@ gradlePublish { ...@@ -52,14 +52,14 @@ gradlePublish {
releaseRepository { releaseRepository {
url = "https://hub.zmcms.cn/repository/maven-releases/" url = "https://hub.zmcms.cn/repository/maven-releases/"
userName = "wangwei" userName = "wanglei1"
password = "caihong520" password = "woshiwanglei123"
} }
snapshotRepository { snapshotRepository {
url = "https://hub.zmcms.cn/repository/maven-snapshots/" url = "https://hub.zmcms.cn/repository/maven-snapshots/"
userName = "wangwei" userName = "wanglei1"
password = "caihong520" password = "woshiwanglei123"
} }
} }
\ No newline at end of file
...@@ -59,14 +59,14 @@ gradlePublish { ...@@ -59,14 +59,14 @@ gradlePublish {
releaseRepository { releaseRepository {
url = "https://hub.zmcms.cn/repository/maven-releases/" url = "https://hub.zmcms.cn/repository/maven-releases/"
userName = "wangwei" userName = "wanglei1"
password = "caihong520" password = "woshiwanglei123"
} }
snapshotRepository { snapshotRepository {
url = "https://hub.zmcms.cn/repository/maven-snapshots/" url = "https://hub.zmcms.cn/repository/maven-snapshots/"
userName = "wangwei" userName = "wanglei1"
password = "caihong520" password = "woshiwanglei123"
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment