Commit f4616a2a authored by linwei's avatar linwei
Browse files

优化蓝牙搜索列表

Showing with 25 additions and 14 deletions
+25 -14
......@@ -14,7 +14,7 @@ import java.util.List;
public abstract class Printer {
protected String mAddress;
protected BluetoothSocket mBluetoothSocket;
protected LabelPrinter mLabelPrinter;
protected LabelPrinter mLabelPrinter = new LabelPrinter();
protected static final Object mLock = new Object();
protected boolean mIsPrinting = false;
private PrinterUtil.PrintCallback mPrintCallback;
......
......@@ -195,14 +195,14 @@ public class PrinterManage extends Printer {
*/
private boolean connectPrinter(String address) {
boolean result = false;
if (null != mLabelPrinter) {
if (mLabelPrinter.Disconnect() == ConstantParams.CONSTANT_STARTS_0) {
mLabelPrinter = null;
} else {
mHandler.sendEmptyMessage(AppConstants.Printer.ADDRESS_INVALID);
}
}
mLabelPrinter = new LabelPrinter();
//if (null != mLabelPrinter) {
// if (mLabelPrinter.Disconnect() == ConstantParams.CONSTANT_STARTS_0) {
// mLabelPrinter = null;
// } else {
// mHandler.sendEmptyMessage(AppConstants.Printer.ADDRESS_INVALID);
// }
//}
//mLabelPrinter = new LabelPrinter();
int status = mLabelPrinter.ConnectPrinter(ConstantParams.CONSTANT_STARTS_7, address,
ConstantParams.CONSTANT_STARTS_4);
if (status == ConstantParams.CONSTANT_STARTS_0) {
......
......@@ -207,12 +207,23 @@ class BluetoothSettingActivity : BaseActivity() {
val device =
intent.getParcelableExtra<BluetoothDevice>(BluetoothDevice.EXTRA_DEVICE)
//if (device.bondState == BluetoothDevice.BOND_BONDED) {
mBluetoothSettingAdapter?.addData(
BluetoothInfoEntity(
device.name,
device.address
if (mNewPrinterType) {
if (device.name.notNullAndEmpty() && device.name.startsWith("BTP")) {
mBluetoothSettingAdapter?.addData(
BluetoothInfoEntity(
device.name,
device.address
)
)
}
} else {
mBluetoothSettingAdapter?.addData(
BluetoothInfoEntity(
device.name,
device.address
)
)
)
}
//}
} else if (BluetoothAdapter.ACTION_DISCOVERY_STARTED == action) {
showTipDialog(R.string.bluetooth_setting_search_device_tip)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment