From 95c4bdaa9d9678d0fb9ab0c6c12e1765ab38951d Mon Sep 17 00:00:00 2001 From: Jay Date: Tue, 15 Aug 2017 11:59:00 +0800 Subject: [PATCH] update --- .gitignore | 1 + .idea/misc.xml | 2 +- .../java/xyz/mtfos/btdemo/MainActivity.kt | 24 ++++++++----------- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 39fb081..5f8d8c1 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ /build /captures .externalNativeBuild +.idea/vcs.xml diff --git a/.idea/misc.xml b/.idea/misc.xml index 3963879..75dac50 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -24,7 +24,7 @@ - + diff --git a/app/src/main/java/xyz/mtfos/btdemo/MainActivity.kt b/app/src/main/java/xyz/mtfos/btdemo/MainActivity.kt index 010360c..da4d9a8 100644 --- a/app/src/main/java/xyz/mtfos/btdemo/MainActivity.kt +++ b/app/src/main/java/xyz/mtfos/btdemo/MainActivity.kt @@ -30,22 +30,18 @@ class MainActivity : Activity() { ble?.startScan() } - th = Thread(Runnable { -> - {}.run { - thrun = true - while (thrun) { - System.out.println("state ===== " + ble?.mState) - if (ble?.mState == ble?.CONNECTED) { - uiHandler.post { - run { - btn.isEnabled = true - } - } - thrun = false - break + th = Thread(Runnable { + thrun = true + while (thrun) { + System.out.println("state ===== " + ble?.mState) + if (ble?.mState == ble?.CONNECTED) { + uiHandler.post { + btn.isEnabled = true } - Thread.sleep(200) + thrun = false + break } + Thread.sleep(200) } }) th?.start()