format code

This commit is contained in:
Jay 2017-08-22 22:37:57 +08:00
parent dca769861e
commit a4c214c1db

View File

@ -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()
} }
} }