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 {
System.out.println("Now State is >>>> " + it)
if(it == PrinterBle.CONNECTING) {
if (it == PrinterBle.CONNECTING) {
disconnectBtn.isEnabled = true
}
if(it == PrinterBle.CONNECTED) {
if (it == PrinterBle.CONNECTED) {
btn.isEnabled = true
connectBtn.isEnabled = false
disconnectBtn.isEnabled = true
}
if(it == PrinterBle.DISCONNECTED) {
if (it == PrinterBle.DISCONNECTED) {
btn.isEnabled = false
connectBtn.isEnabled = true
disconnectBtn.isEnabled = false
@ -65,7 +65,7 @@ class MainActivity : Activity() {
btn.setOnClickListener {
val txt: String = intxt.text.toString()
ble?.setAlign(PrinterBle.ALIGN_CENTER)?.addText(txt)
ble?.sendQueue()
ble?.sendQueue()
}
connectBtn.setOnClickListener {
@ -86,16 +86,16 @@ class MainActivity : Activity() {
}
fun scanConnect() {
if(ble?.init()!!){
if (ble?.init()!!) {
ble?.startScan()
}
}
fun disconnect() {
if(ble?.mState!! == PrinterBle.SCANNING) {
if (ble?.mState!! == PrinterBle.SCANNING) {
ble?.stopScan()
}
if(ble?.mState!! == PrinterBle.CONNECTED) {
if (ble?.mState!! == PrinterBle.CONNECTED) {
ble?.disconnect()
}
}