Skip to content

Commit

Permalink
Merge pull request #41 from danielpsantiago/feat/disconnectedPrinting…
Browse files Browse the repository at this point in the history
…Callback

create disconnected function for printing callback
  • Loading branch information
mazenrashed committed Mar 4, 2022
2 parents b9306a1 + 0a7d2a8 commit 5674058
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 5674058

Please sign in to comment.