format code
This commit is contained in:
parent
dca769861e
commit
a4c214c1db
@ -38,15 +38,15 @@ class MainActivity : Activity() {
|
|||||||
|
|
||||||
ble?.setOnStateChangeListener {
|
ble?.setOnStateChangeListener {
|
||||||
System.out.println("Now State is >>>> " + it)
|
System.out.println("Now State is >>>> " + it)
|
||||||
if(it == PrinterBle.CONNECTING) {
|
if (it == PrinterBle.CONNECTING) {
|
||||||
disconnectBtn.isEnabled = true
|
disconnectBtn.isEnabled = true
|
||||||
}
|
}
|
||||||
if(it == PrinterBle.CONNECTED) {
|
if (it == PrinterBle.CONNECTED) {
|
||||||
btn.isEnabled = true
|
btn.isEnabled = true
|
||||||
connectBtn.isEnabled = false
|
connectBtn.isEnabled = false
|
||||||
disconnectBtn.isEnabled = true
|
disconnectBtn.isEnabled = true
|
||||||
}
|
}
|
||||||
if(it == PrinterBle.DISCONNECTED) {
|
if (it == PrinterBle.DISCONNECTED) {
|
||||||
btn.isEnabled = false
|
btn.isEnabled = false
|
||||||
connectBtn.isEnabled = true
|
connectBtn.isEnabled = true
|
||||||
disconnectBtn.isEnabled = false
|
disconnectBtn.isEnabled = false
|
||||||
@ -65,7 +65,7 @@ class MainActivity : Activity() {
|
|||||||
btn.setOnClickListener {
|
btn.setOnClickListener {
|
||||||
val txt: String = intxt.text.toString()
|
val txt: String = intxt.text.toString()
|
||||||
ble?.setAlign(PrinterBle.ALIGN_CENTER)?.addText(txt)
|
ble?.setAlign(PrinterBle.ALIGN_CENTER)?.addText(txt)
|
||||||
ble?.sendQueue()
|
ble?.sendQueue()
|
||||||
}
|
}
|
||||||
|
|
||||||
connectBtn.setOnClickListener {
|
connectBtn.setOnClickListener {
|
||||||
@ -86,16 +86,16 @@ class MainActivity : Activity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun scanConnect() {
|
fun scanConnect() {
|
||||||
if(ble?.init()!!){
|
if (ble?.init()!!) {
|
||||||
ble?.startScan()
|
ble?.startScan()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun disconnect() {
|
fun disconnect() {
|
||||||
if(ble?.mState!! == PrinterBle.SCANNING) {
|
if (ble?.mState!! == PrinterBle.SCANNING) {
|
||||||
ble?.stopScan()
|
ble?.stopScan()
|
||||||
}
|
}
|
||||||
if(ble?.mState!! == PrinterBle.CONNECTED) {
|
if (ble?.mState!! == PrinterBle.CONNECTED) {
|
||||||
ble?.disconnect()
|
ble?.disconnect()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user