Exemplo n.º 1
0
        public void onStatus(StatusData statusData)
        {
            StringBuilder text            = new StringBuilder();
            bool          isUpdateAddress = false;

            switch (statusData.State.ToString().ToUpper())
            {
            case "WAITING":
                text.Append("Waiting for trigger press to scan the barcode");
                break;

            case "SCANNING":
                text.Append("Scanner Beam is on, aim at the barcode.");
                break;

            case "DISCOVERING":
                text.Append("Discovering for the Bluetooth device");
                isUpdateAddress = true;
                break;

            case "PAIRED":
                text.Append("Bluetooth device is paired successfully");
                break;

            case "UNPAIRED":
                text.Append("Bluetooth device is un-paired successfully");
                break;

            default:
            case "ERROR":
                text.Append("\n" + statusData.GetType().Name + ": " + statusData.Result);
                break;
            }

            bool isUpdateUI = isUpdateAddress;

            RunOnUiThread(() => {
                statusView.SetText(text + "\n", TextView.BufferType.Normal);
                if (isUpdateUI)
                {
                    btName.SetText(scanAndPairMgr.Config.BluetoothInfo.DeviceName, TextView.BufferType.Normal);
                    btAddress.SetText(scanAndPairMgr.Config.BluetoothInfo.MacAddress, TextView.BufferType.Normal);
                }
            });
        }