Skip to content

Commit

Permalink
create disconnected function for printing callback
Browse files Browse the repository at this point in the history
  • Loading branch information
danielpsantiago committed Feb 11, 2020
1 parent 678b111 commit 0a7d2a8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions app/src/main/java/com/mazenrashed/example/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ class MainActivity : AppCompatActivity() {
Toast.makeText(this@MainActivity, "Message: $message", Toast.LENGTH_SHORT).show()
}

override fun disconnected() {
Toast.makeText(this@MainActivity, "Disconnected Printer", Toast.LENGTH_SHORT).show()
}

}
}

Expand Down
4 changes: 4 additions & 0 deletions app/src/main/java/com/mazenrashed/example/WoosimActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ class WoosimActivity : AppCompatActivity() {
Toast.makeText(this@WoosimActivity, "Message: $message", Toast.LENGTH_SHORT).show()
}

override fun disconnected() {
Toast.makeText(this@WoosimActivity, "Disconnected printer", Toast.LENGTH_SHORT).show()
}

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ class Printing(private var printer: Printer, private var pairedPrinter: PairedPr
printingCallback?.printingOrderSentSuccessfully()
}

override fun onDeviceDisconnected(device: BluetoothDevice, message: String) {}
override fun onDeviceDisconnected(device: BluetoothDevice, message: String) {
printingCallback?.disconnected()
}

override fun onMessage(message: String) {
printingCallback?.onMessage(message)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ interface PrintingCallback {
fun connectionFailed(error: String)
fun onError(error: String)
fun onMessage(message: String)
fun disconnected()
}

0 comments on commit 0a7d2a8

Please sign in to comment.