public void ReceiveDetections(Detections detections) { if (this.ViewModel.State == RegisterDeviceViewModel.RegistrationState.New) { SparseArray qrcodes = detections.DetectedItems; if (qrcodes.Size() != 0) { try { Vibrator vibrator = (Vibrator)GetSystemService(Context.VibratorService); vibrator.Vibrate(VibrationEffect.CreateOneShot(1000, 1)); } catch { } var value = ((Barcode)qrcodes.ValueAt(0)).RawValue; string networkSSID = value; if (!string.IsNullOrEmpty(networkSSID)) { Task.Run(async() => await this.ViewModel.ProvisionDevice(new Common.WiFi.WifiNetwork() { SSID = networkSSID })); } } } }
private async Task ExecuteLoadDetectionsCommand() { if (IsBusy) { return; } IsBusy = true; try { var detections = await EyeSpyService.Value.GetDetections(); detections = detections.OrderByDescending(d => d.DetectionTimestamp ?? DateTime.MinValue).ToList(); Detections.Clear(); detections.ForEach(d => { d.DetectionImageUrl = d.ImageReference.WithToken(); Detections.Add(d); }); } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
public void ReceiveDetections(Detections detections) { SparseArray qrcodes = detections.DetectedItems; //cameraSource.Stop(); string[] spstring, spstring2, spstring3; if (qrcodes.Size() != 0) { spstring = ((Barcode)qrcodes.ValueAt(0)).RawValue.Split("\r\n"); if (spstring.Count <string>() > 1) //VCARD { if (spstring[0].Contains("VCARD")) { spstring2 = spstring[3].Split(':'); tempname = spstring2[1]; //txtresult.Text += " "; spstring3 = spstring[5].Split(';'); spstring2 = spstring3[2].Split(':'); tempnumber = spstring2[1]; //txtresult.Text = spstring[3]; //insertContacts(tempname, tempnumber); checkdetect = true; } } else if (spstring.Count <string>() == 1) { spstring2 = spstring[0].Split(';'); if (spstring2[0].Contains("MECARD:")) //MECARD { spstring3 = spstring2[0].Split(':'); tempname = spstring3[2]; spstring3 = spstring2[1].Split(':'); tempnumber = spstring3[1]; //insertContacts(tempname, tempnumber); checkdetect = true; } else if (spstring2[0].Contains("{\"name\"")) //App { Newtonsoft.Json.Linq.JObject jo = Newtonsoft.Json.Linq.JObject.Parse(spstring2[0]); tempname = jo["name"].ToString(); tempnumber = jo["number"].ToString(); //insertContacts(tempname, tempnumber); checkdetect = true; } } /* * txtresult.Post(() => { * //Vibrator vibrator = (Vibrator)GetSystemService(Context.VibratorService); * //vibrator.Vibrate(1000); * //txtresult.Text = ((Barcode)qrcodes.ValueAt(0)).RawValue; * } * * ); */ Finish(); } //throw new NotImplementedException(); }
public void ReceiveDetections(Detections detections) { SparseArray qrcodes = detections.DetectedItems; if (qrcodes.Size() != 0) { _txtResult.Post(() => { _txtResult.Text = ((Barcode)qrcodes.ValueAt(0)).RawValue; AlertDialog.Builder dialog = new AlertDialog.Builder(this); AlertDialog alert = dialog.Create(); alert.SetTitle("Código de Barras"); alert.SetMessage(((Barcode)qrcodes.ValueAt(0)).RawValue); alert.SetIcon(Resource.Drawable.logo); alert.SetButton("Volver", (c, ev) => { // Para actualizar una actividad desde dentro de sí mismo Finish(); StartActivity(Intent); GC.Collect(); }); alert.Show(); }); } }
public void ReceiveDetections(Detections detections) { if (detected) { return; } detected = true; var items = detections.DetectedItems; if (items.Size() != 0) { RunOnUiThread(delegate { var vibr = (Vibrator)GetSystemService(Android.Content.Context.VibratorService); if (vibr.HasVibrator) { vibr.Vibrate(500); } var txt = ((Barcode)items.ValueAt(0)).RawValue; ProgressData(txt); Toast.MakeText(this, txt, ToastLength.Long).Show(); }); } else { detected = false; } }
public void ReceiveDetections(Detections detections) { try { if (_isBusy) { return; } SparseArray items = detections.DetectedItems; if (items.Size() != 0) { tv.Post(() => { StringBuilder bulder = new StringBuilder(); for (int i = 0; i < items.Size(); i++) { string det = ((TextBlock)items.ValueAt(i)).Value; Log.Debug("......ReceiveDetections.....", det); GetNumber(det); bulder.Append(det); bulder.Append("\n"); } tv.Text = bulder.ToString(); }); } } catch (Exception ex) { Log.Error("Detector", ex.Message); } }
public void ReceiveDetections(Detections detections) { SparseArray detectedfaces = detections.DetectedItems; //PictureCallback pictureCallback = new PictureCallback(); if (detectedfaces.Size() != 0) { for (int i = 0; i < detectedfaces.Size(); i++) { Face face = (Face)detectedfaces.ValueAt(i); //ShowToast(" Blinked ", true); txt.Post(() => { txt.Text = face.IsLeftEyeOpenProbability.ToString() + " " + face.IsRightEyeOpenProbability.ToString(); }); if ((face.IsLeftEyeOpenProbability + face.IsRightEyeOpenProbability) / 2.0f < 0.3 && face.IsLeftEyeOpenProbability > 0 && face.IsRightEyeOpenProbability > 0) { closed_eyes = true; } if (closed_eyes) { if ((face.IsLeftEyeOpenProbability + face.IsRightEyeOpenProbability) / 2.0f >= 0.6 && face.IsLeftEyeOpenProbability > 0 && face.IsRightEyeOpenProbability > 0) { if (captured) { cameraSource.TakePicture(null, this); captured = false; } } } } } }
public void ReceiveDetections(Detections detections) { SparseArray qrcodes = detections.DetectedItems; if (qrcodes.Size() != 0) { _txtResult.Post(() => { _txtResult.Text = ((Barcode)qrcodes.ValueAt(0)).RawValue; }); } }
public void ReceiveDetections(Detections detections) //wykrywanie QR Code { SparseArray qrcodes = detections.DetectedItems; if (qrcodes.Size() != 0) { txtResult.Post(() => { txtResult.Text = ((Barcode)qrcodes.ValueAt(0)).RawValue; //wyświetlenie zawartości QR kodu }); } }
/// <summary> /// 바코드 검출시 호출되는 콜백 함수입니다. /// </summary> /// <param name="detections">검출된 바코드(들)</param> public void ReceiveDetections(Detections detections) { var barcodes = detections.DetectedItems; var meta = detections.FrameMetadata; for (int i = 0; i < barcodes.Size(); i++) { int key = barcodes.KeyAt(i); var barcode = barcodes.Get(key) as Android.Gms.Vision.Barcodes.Barcode; if (barcode == null) { continue; } // 검출 영역 범위 설정(비율에 맞게 변환) var ratioX = meta.Width / Element.Width; var ratioY = meta.Height / Element.Height; var area = Element.Content != null ? Element.Content.Bounds : Element.Bounds; var scanAreaLeft = area.Left * ratioX; var scanAreaRight = area.Right * ratioX; var scanAreaTop = area.Top * ratioY; var scanAreaBottom = area.Bottom * ratioY; // 검출 영역 내 스캔된 바코드 처리 var boundingBox = barcode.BoundingBox; if (scanAreaLeft < boundingBox.Left && scanAreaRight > boundingBox.Right && scanAreaTop < boundingBox.Top && scanAreaBottom > boundingBox.Bottom) { // 지연 시간 동안 바코드 스캔 결과를 전달하지 않음 var ts = DateTime.Now.TimeOfDay - _preDetectionDt.TimeOfDay; if (ts.TotalMilliseconds < Element.DelayBetweenDetections) { return; } _preDetectionDt = DateTime.Now; var b = ((Android.Gms.Vision.Barcodes.Barcode)barcodes.ValueAt(i)); this.Write($"Barcode Detection, Format : {b.Format.ToTmonFormat()}, Data : {b.RawValue}"); Element?.OnBarcodeDetected(new BarcodeData(b.Format.ToTmonFormat(), b.RawValue)); return; } } }
public void ReceiveDetections(Detections detections) { SparseArray qrcodes = detections.DetectedItems; if (qrcodes.Size() != 0) { result = ((Barcode)qrcodes.ValueAt(0)).RawValue; Intent resultIntent = new Intent(this, typeof(MainActivity)); resultIntent.PutExtra("json", ((Barcode)qrcodes.ValueAt(0)).RawValue); SetResult(Result.Ok, resultIntent); Finish(); } }
public void ReceiveDetections(Detections detections) { SparseArray qrcodes = detections.DetectedItems; if (qrcodes.Size() != 0) { txtResult.Post(() => { Vibrator vib = (Vibrator)GetSystemService(Context.VibratorService); vib.Vibrate(1000); txtResult.Text = ((Barcode)qrcodes.ValueAt(0)).RawValue; }); } }
public void ReceiveDetections(Detections detections) { try { SparseArray barcodes = detections.DetectedItems; if (barcodes.Size() != 0) { var view = (BarcodeScanView)this.Element; view.OnBarcodeScanResult?.Invoke(((Barcode)barcodes.ValueAt(0)).RawValue); } } catch (Exception ex) { Console.WriteLine("DROID_SCAN | ReceiveDetections error", ex); } }
void IProcessor.ReceiveDetections(Detections detections) { SparseArray qrcodes = detections.DetectedItems; if (qrcodes.Size() != 0) { txtResult.Post(() => { Vibrator vib = (Vibrator)GetSystemService(Context.VibratorService); #pragma warning disable CS0618 // Type or member is obsolete vib.Vibrate(300); #pragma warning restore CS0618 // Type or member is obsolete txtResult.Text = ((Barcode)qrcodes.ValueAt(0)).RawValue; GoToConnection(txtResult.Text); }); } }
public void ReceiveDetections(Detections detections) { SparseArray items = detections.DetectedItems; if (items.Size() != 0) { textView.Post(() => { StringBuilder strBuilder = new StringBuilder(); for (int i = 0; i < items.Size(); ++i) { strBuilder.Append((TextBlock)items.ValueAt(i)); strBuilder.Append("\n"); } textView.Text = strBuilder.ToString(); }); } }
public void ReceiveDetections(Detections detections) { if (!Element.IsScannerActive) { return; } SparseArray qrcodes = detections.DetectedItems; if (qrcodes.Size() != 0) { Vibrator vibrator = (Vibrator)Context.GetSystemService(Context.VibratorService); vibrator.Vibrate(100); Element.Barcode = ((Barcode)qrcodes.ValueAt(0)).RawValue; cam.StopPreview(); Element.IsScannerActive = false; Element.Barcode = null; } }
public void ReceiveDetections(Detections detections) { SparseArray qrcodes = detections.DetectedItems; if (qrcodes.Size() != 0) { txtResult.Post(() => { Vibrator vibrator = (Vibrator)GetSystemService(Context.VibratorService); vibrator.Vibrate(100); txtResult.Text = ((Barcode)qrcodes.ValueAt(0)).RawValue; Intent intent = new Intent(); intent.PutExtra("qrcode", txtResult.Text); SetResult(Result.Ok, intent); Finish(); }); } }
public void ReceiveDetections(Detections detections) { SparseArray items = detections.DetectedItems; if (items.Size() != 0) { textView.Post(() => { StringBuilder strBuilder = new StringBuilder(); for (int i = 0; i < items.Size(); i++) { strBuilder.Append(((TextBlock)items.ValueAt(i)).Value); strBuilder.Append("\n"); } textView.Text = strBuilder.ToString(); //text to speech var text = strBuilder.ToString(); CrossTextToSpeech.Current.Speak(text); }); } }
public void ReceiveDetections(Detections detections) { SparseArray qrcodes = detections.DetectedItems; if (qrcodes.Size() != 0) { txtResult.Post(() => { vib.Vibrate(100); Toast.MakeText(Application.Context, ((Barcode)qrcodes.ValueAt(0)).RawValue, ToastLength.Short).Show(); logList.Clear(); txtResult.Text = ((Barcode)qrcodes.ValueAt(0)).RawValue; cameraPreview.LayoutParameters.Height = 0; cameraSource.Stop(); GetDataFromDB(txtResult.Text); btnApproved.Visibility = Android.Views.ViewStates.Visible; }); } }
public void RemoveDetectionItem(object sender, KeyRoutedEventArgs e) { if (e.Key != Windows.System.VirtualKey.Delete) { return; } var lw = sender as ListView; var oldIndex = lw.SelectedIndex; Detections.Remove(lw.SelectedItem as Detection); if (oldIndex > 0) { lw.SelectedIndex = oldIndex - 1; } else { if (lw.Items.Count > 0) { lw.SelectedIndex = 0; } } }
public void ReceiveDetections(Detections detections) { SparseArray items = detections.DetectedItems; StringBuilder strBuilder = new StringBuilder(); if (items.Size() != 0) { textView.Post(() => { for (int i = 0; i < items.Size(); i++) { strBuilder.Append(((TextBlock)items.ValueAt(i)).Value + " " + "\n"); } //var textRemoved = Regex.Replace(strBuilder.ToString(), "[A-Za-z ]", " "); string text = GetTextMatch(strBuilder.ToString()); if (!string.IsNullOrEmpty(text)) { contTextCorrect++; textView.Text = text + " Lendo o valor pela :" + contTextCorrect + " vez."; } else { contTextCorrect = 0; cont = 0; textView.Text = "No Price."; } }); } else { cont++; textView.Post(() => { textView.Text = "Não reconheceu nada: " + cont; }); } }
public override void OnUpdate(Detections detectionResults, Java.Lang.Object item) { mOverlay.Add(mEyesGraphic); var face = item as Face; updatePreviousProportions(item); PointF leftPosition = getLandmarkPosition(face, (int)LandmarkType.LeftEye); PointF rightPosition = getLandmarkPosition(face, (int)LandmarkType.RightEye); float leftOpenScore = face.IsLeftEyeOpenProbability; bool isLeftOpen; if (leftOpenScore == Face.UncomputedProbability) { isLeftOpen = mPreviousIsLeftOpen; } else { isLeftOpen = (leftOpenScore > EYE_CLOSED_THRESHOLD); mPreviousIsLeftOpen = isLeftOpen; } float rightOpenScore = face.IsRightEyeOpenProbability; bool isRightOpen; if (rightOpenScore == Face.UncomputedProbability) { isRightOpen = mPreviousIsRightOpen; } else { isRightOpen = (rightOpenScore > EYE_CLOSED_THRESHOLD); mPreviousIsRightOpen = isRightOpen; } mEyesGraphic.updateEyes(leftPosition, isLeftOpen, rightPosition, isRightOpen); }
public void ReceiveDetections(Detections detections) { SparseArray qrcodes = detections.DetectedItems; if (qrcodes.Size() != 0) { txtResult.Post(() => { Vibrator vib = (Vibrator)GetSystemService(Context.VibratorService); vib.Vibrate(1000); var qrtext = ((Barcode)qrcodes.ValueAt(0)).RawValue; var username = qrtext.Split(',')[0].Substring(10); var key = qrtext.Split(',')[1].Substring(6); var keys = KeyGenerator(); SaveContact(username, key, keys["privateKey"]); cameraPreview.Visibility = ViewStates.Invisible; txtResult.Text = string.Format("Contact {0} saved!!", username); }); } }
public void ReceiveDetections(Detections detections) { SparseArray items = detections.DetectedItems; const string Pattern = "#.*?#"; Regex regex = new Regex(Pattern); string found = ""; if (items.Size() != 0) { textView.Post(() => { StringBuilder strBuilder = new StringBuilder(); for (int i = 0; i < items.Size(); i++) { //Match match = regex.Match(((TextBlock)items.ValueAt(i)).Value); //if (match.Success) //{ // found = match.Value; // cameraSource.Stop(); //} ////else ////{ //// strBuilder.Append(((TextBlock)items.ValueAt(i)).Value); //// strBuilder.Append("\n"); ////} strBuilder.Append(((TextBlock)items.ValueAt(i)).Value); strBuilder.Append("\n"); } //if (found != "") //textView.Text = found; textView.Text = strBuilder.ToString(); //else }); } }
//(Metodo de IProcessor) Metodo que recibe de la API de Google el texto detectado. public void ReceiveDetections(Detections detections) { SparseArray items = detections.DetectedItems; List <TextBlock> listaTexto = new List <TextBlock>(); StringBuilder cadenaTexto = new StringBuilder(); //Funcion Lambda texto.Post(() => { for (int cont = 0; cont < items.Size(); cont++) { //Agrega los "bloques de texto" a listaTexto listaTexto.Add((TextBlock)items.ValueAt(cont)); } foreach (TextBlock item in listaTexto) { //Adjunta TextBlock on a StringBuilder cadenaTexto.Append(item.Value); cadenaTexto.Append("\n"); } //Actualiza el TextView texto.Text = cadenaTexto.ToString(); // Creacion del archivo de texto en la memoria del dispositivo if (capturarTexto) { //Creacion del nombre del archivo guardado (En este caso se usa la fecha actual como nombre). String nombreArchivo = DateTime.Now.ToString(); //Quitar caracteres invalidos para los nombres de archivo. nombreArchivo = nombreArchivo.Replace(':', '-'); nombreArchivo = nombreArchivo.Replace('/', '-'); //Creación de la ruta completa con la ruta mas el nombre del archivo. string rutaCompleta = System.IO.Path.Combine(ruta, nombreArchivo.ToString() + ".txt"); GeneradorArchivos(cadenaTexto, rutaCompleta); Toast.MakeText(this.ApplicationContext, "Texto Capturado!", ToastLength.Short).Show(); } }); }
public void ReceiveDetections(Detections detections) { SparseArray items = detections.DetectedItems; if (items.Size() != 0) { txtView.Post(() => { StringBuilder strBuilder = new StringBuilder(); strBuilder.Append(((TextBlock)items.ValueAt(0)).Value); strBuilder.Append("\n"); str = strBuilder.ToString(); string str_num = ""; for (int i = 0; i < str.Length; i++) { if (str[i] >= '0' && str[i] <= '9') { str_num += str[i].ToString(); } } txtView.Text = str_num; flag = true; }); } }
public void ReceiveDetections(Detections detections) { SparseArray items = detections.DetectedItems; if (items.Size() != 0) { for (int i = 0; i < items.Size(); i++) { var line = ((TextBlock)items.ValueAt(i)).Value; if (string.IsNullOrEmpty(line)) { continue; } if (line.Contains("<<<")) { textView.Text = line; //cameraSource.TakePicture() cameraSource.TakePicture(this, this); } if (line.Contains(">>>")) { textView.Text = line; } } //textView.Post(() => //{ // StringBuilder strBuilder = new StringBuilder(); // for (int i = 0; i < items.Size(); i++) // { // var line = ((TextBlock)items.ValueAt(i)).Value; // if (string.IsNullOrEmpty(line)) continue; // } // textView.Text = strBuilder.ToString(); //}); } }
public void ReceiveDetections(Detections detections) { SparseArray items = detections.DetectedItems; if (items.Size() != 0) { textView.Post(() => { StringBuilder strBuilder = new StringBuilder(); for (int i = 0; i < items.Size(); ++i) { strBuilder.Append(((TextBlock)items.ValueAt(i)).Value); strBuilder.Append("\n"); } string source = strBuilder.ToString(); Regex regex = new Regex("\\((?<output>[a-zA-Z0-9]+)/*\\).*"); GroupCollection capturas = regex.Match(source).Groups; codigo = capturas["output"].ToString(); if (codigo != "" && !varBool) { MySqlConnection conexao = new MySqlConnection(Conexao.strConexao); MySqlCommand verificaProduto = new MySqlCommand(ComandosSQL.verificaProduto, conexao); MySqlCommand contaProdutoCarrinho = new MySqlCommand(ComandosSQL.contaProdutoCarrinho, conexao); MySqlCommand selecionaProdutoCarrinho = new MySqlCommand(ComandosSQL.selecionaProdutoCarrinho, conexao); MySqlDataReader retorno; MySqlDataReader produtoCarrinho; verificaProduto.Parameters.Add("@idProduto", MySqlDbType.VarChar, 60).Value = codigo.ToString(); contaProdutoCarrinho.Parameters.Add("@idProduto", MySqlDbType.VarChar, 60).Value = codigo.ToString(); contaProdutoCarrinho.Parameters.Add("@idRevendedor", MySqlDbType.VarChar, 60).Value = "2"; contaProdutoCarrinho.Parameters.Add("@idCliente", MySqlDbType.VarChar, 60).Value = "2"; selecionaProdutoCarrinho.Parameters.Add("@idProduto", MySqlDbType.VarChar, 60).Value = codigo.ToString(); selecionaProdutoCarrinho.Parameters.Add("@idRevendedor", MySqlDbType.VarChar, 60).Value = "2"; conexao.Open(); contaProdutoCarrinho.CommandType = CommandType.Text; numeroRegistro = (long)contaProdutoCarrinho.ExecuteScalar(); contaProdutoCarrinho.Dispose(); if (numeroRegistro > 0) { conexao.Close(); Toast.MakeText(Application.Context, "Este produto já está em seu carrinho.", ToastLength.Long).Show(); conexao.Open(); produtoCarrinho = selecionaProdutoCarrinho.ExecuteReader(); if (produtoCarrinho.Read()) { byte[] imagem = (byte[])(produtoCarrinho["imagem"]); imagemProduto = BitmapFactory.DecodeByteArray(imagem, 0, imagem.Length); descricao = produtoCarrinho.GetString("descricao").ToString(); preco = produtoCarrinho.GetString("preco").ToString(); quantidade = produtoCarrinho.GetString("quantidade").ToString(); StartActivity(typeof(ExibeProduto)); Finish(); } } else { conexao.Close(); conexao.Open(); retorno = verificaProduto.ExecuteReader(); if (retorno.Read()) { byte[] imagem = (byte[])(retorno["imagem"]); imagemProduto = BitmapFactory.DecodeByteArray(imagem, 0, imagem.Length); descricao = retorno.GetString("descricao").ToString(); preco = retorno.GetString("preco").ToString(); quantidade = "1"; StartActivity(typeof(ExibeProduto)); Finish(); } else { Toast.MakeText(Application.Context, "O Produto não consta no banco de dados!", ToastLength.Long).Show(); Finish(); } } conexao.Close(); varBool = true; } }); } }
public void ReceiveDetections(Detections detections) { SparseArray items = detections.DetectedItems; List <DrawItem> drItems = new List <DrawItem>(); if (items.Size() != 0) { Paint backPaint = new Paint(); backPaint.Color = Color.DarkGray; Paint textPaint = new Paint(); textPaint.Color = Color.White; for (int i = 0; i < items.Size(); i++) { TextBlock tb = (TextBlock)items.ValueAt(i); foreach (IText line in tb.Components) { string temp = line.Value; if (checkBox.Checked) { // Test for Base64 try { temp = Encoding.UTF8.GetString(Convert.FromBase64String(temp)); } catch { temp = line.Value; } } drItems.Add(new DrawItem() { Text = temp, Top = line.BoundingBox.Top, Left = line.BoundingBox.Left, Bottom = line.BoundingBox.Bottom, Right = line.BoundingBox.Right }); } } drawingView.Items.Clear(); drawingView.Items.AddRange(drItems); drawingView.Invalidate(); } else { drawingView.Items.Clear(); drawingView.Invalidate(); } //List<DrawItem> drItems = new List<DrawItem>(); //if (items.Size() != 0) //{ // for (int i = 0; i < items.Size(); ++i) // { // TextBlock tb = (TextBlock)items.ValueAt(i); // drItems.Add(new DrawItem() // { // Text = tb.Value, // Left = tb.BoundingBox.Left, // Top = tb.BoundingBox.Top, // Right = tb.BoundingBox.Right, // Bottom = tb.BoundingBox.Bottom // }); // } //} //if (drItems.Count > 0) //{ // drawView.Post(() => // { // drawView.Items.Clear(); // drawView.Items.AddRange(drItems); // drawView.PostInvalidate(); // }); //} //if (items.Size() != 0) //{ // //txtView.Post(() => { // // StringBuilder strBuilder = new StringBuilder(); // // for (int i = 0; i < items.Size(); ++i) // // { // // strBuilder.Append(((TextBlock)items.ValueAt(i)).Value); // // strBuilder.Append("\n"); // // } // // txtView.Text = strBuilder.ToString(); // //}); //} }
public void ReceiveDetections(Detections detections) { var codes = detections.DetectedItems; if (codes.Size() == 0) { return; } if (Task != null) { if (Task.IsCanceled) { Task = null; RunOnUiThread(() => { ShowToastMessage("Task.IsCanceled", ToastLength.Long); }); Thread.Sleep(5000); return; } if (Task.IsFaulted) { Task = null; RunOnUiThread(() => { ShowToastMessage("Task.IsFaulted", ToastLength.Long); }); Thread.Sleep(5000); return; } if (Task.IsCompletedSuccessfully) { Task = null; RunOnUiThread(() => { ShowToastMessage("Task.IsCompletedSuccessfully", ToastLength.Long); }); Thread.Sleep(5000); return; } if (Task.IsCompleted) { Task = null; RunOnUiThread(() => { ShowToastMessage("Task.IsCompleted", ToastLength.Long); }); Thread.Sleep(5000); return; } ShowToastMessage(Task.Status.ToString()); Thread.Sleep(5000); return; } BarcodeDetector.Release(); var barcode = (Barcode)codes.ValueAt(0); _scannedBarcode = barcode.RawValue; CameraPreviewProgressBar.Visibility = ViewStates.Visible; RunOnUiThread(() => { ShowToastMessage(_scannedBarcode, ToastLength.Long); }); Thread.Sleep(5000); if (!_callback) { Task = Task.Run(async() => { try { var result = await ProductService.GetProductByBarcode(_scannedBarcode); if (result.Error.Any()) { var message = Resources.GetString(Resource.String.ProductBarcodeNotFound); RunOnUiThread(() => { BarcodeDetector.SetProcessor(this); ShowToastMessage(message, ToastLength.Long); }); return; } RunOnUiThread(() => { NavigationManager.GoToProductDetails(result.Data); }); } catch (Exception ex) { RunOnUiThread(() => { BarcodeDetector.SetProcessor(this); ShowToastMessage(ex.Message, ToastLength.Long); }); } }); } else { NavigationManager.GoToPrevious(); } }