From fff5b4a29c99df35d009a6407c0403f510da2f40 Mon Sep 17 00:00:00 2001 From: Jay Date: Wed, 23 Aug 2017 22:31:59 +0800 Subject: [PATCH] add StateListener action --- app/src/main/java/xyz/mtfos/btdemo/PrinterBle.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/xyz/mtfos/btdemo/PrinterBle.java b/app/src/main/java/xyz/mtfos/btdemo/PrinterBle.java index 79e1a4b..1a3e216 100644 --- a/app/src/main/java/xyz/mtfos/btdemo/PrinterBle.java +++ b/app/src/main/java/xyz/mtfos/btdemo/PrinterBle.java @@ -248,6 +248,9 @@ public class PrinterBle { } mState = CONNECTING; + if(this.mStateListener != null) { + this.mStateListener.onChange(mState); + } } public void stopScan() { @@ -260,7 +263,12 @@ public class PrinterBle { mAdapter.stopLeScan(mLeScanCB); } - if (mState == CONNECTING) mState = DISCONNECTED; + if (mState == CONNECTING) { + mState = DISCONNECTED; + if(this.mStateListener != null) { + this.mStateListener.onChange(mState); + } + } } /** @@ -390,13 +398,13 @@ public class PrinterBle { default: return this; } - addText("__a" + strAlign + "__"); + addText("__&a" + strAlign + "__"); return this; } public void setSize(int w, int h) { if (w < 1 || h < 1 || w > 3 || h > 3) return; - addText(String.format("__s%d,%d__", w, h)); + addText(String.format("__&s%d,%d__", w, h)); } public void resetSize() {