public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Use this to return your custom view for this Fragment // return inflater.Inflate(Resource.Layout.YourFragment, container, false); var ignored = base.OnCreateView(inflater, container, savedInstanceState); view = inflater.Inflate(Resource.Layout.ListEPISRepuestos, null); var count = ManagerRepuestos.getRepuestos(); // this.Activity.Title = empleado.FullName; empleado = ManagerRepuestos.getEmpleado(); MobileBarcodeScanner.Initialize(this.Activity.Application); listRepuestosEpis = ManagerRepuestos.getRepuestos(); // listRepuestosEpis.Clear(); listViewEmpleados = (ListView)view.FindViewById(Resource.Id.listProductos); adapterRepuestos = new AdapterRepuestos(this.Activity, listRepuestosEpis);//new ArrayAdapter<string>(this,Android.Resource.Layout.SimpleListItem1, listRepuestosEpis); // adapterRepuestos; adaptarSwipe = new SwipeActionAdapter(adapterRepuestos); adaptarSwipe.SetSwipeActionListener(this) .SetDimBackgrounds(true) .SetListView(this.listViewEmpleados); listViewEmpleados.Adapter = adaptarSwipe; adaptarSwipe.AddBackground(SwipeDirection.DirectionFarLeft, Resource.Menu.row_bg_left_far); adaptarSwipe.AddBackground(SwipeDirection.DirectionNormalLeft, Resource.Menu.row_bg_left); adaptarSwipe.AddBackground(SwipeDirection.DirectionFarRight, Resource.Menu.row_bg_right_far); adaptarSwipe.AddBackground(SwipeDirection.DirectionNormalRight, Resource.Menu.row_bg_right); //listViewEmpleados.ItemClick += OnListItemClick; var fab = view.FindViewById <com.refractored.fab.FloatingActionButton>(Resource.Id.floating); fab.AttachToListView(listViewEmpleados); // Button btoScan = FindViewById<Button>(Resource.Id.btoScanear); fab.Click += (object sender, EventArgs e) => { var code = launchScaner(); }; listViewEmpleados.ItemClick += (sender, e) => { //var activityDetalleRepuestoActivity = new Intent(this.Activity, typeof(detalleRepuestoActivity)); //activityDetalleRepuestoActivity.PutExtra("idEntregaAlmacen", ManagerRepuestos.getRepuestos()[e.Position].Key); //StartActivity(activityDetalleRepuestoActivity); Android.Support.V4.App.Fragment fragment = new AlmacenRepuestosXamarin.Fragments.DetalleRepuesto(); Bundle bundle = new Bundle(); bundle.PutString("idEntregaAlmacen", ManagerRepuestos.getRepuestos()[e.Position].Key); fragment.Arguments = bundle; FragmentManager.BeginTransaction() .Replace(Resource.Id.content_frame, fragment) .AddToBackStack("ListaRepuestosEntrega") .Commit(); }; progressLayout = view.FindViewById <LinearLayout>(Resource.Id.progressBarListaEntrega); progressLayout.Visibility = ViewStates.Gone; return(view); }
private async Task launchScaner() { var scanner = new MobileBarcodeScanner(); Button flashButton; View zxingOverlay; scanner.UseCustomOverlay = true; //Inflate our custom overlay from a resource layout zxingOverlay = LayoutInflater.FromContext(this.Activity).Inflate(Resource.Layout.OverlayReadBarCode, null); //Find the button from our resource layout and wire up the click event flashButton = zxingOverlay.FindViewById <Button>(Resource.Id.buttonZxingFlash); flashButton.Click += (sender, e) => scanner.ToggleTorch(); //Set our custom overlay scanner.CustomOverlay = zxingOverlay; //Start scanning! var result = await scanner.Scan(); Toast.MakeText(this.Activity, result.Text, ToastLength.Long); //HandleScanResult(result); string msg = string.Empty; if (!ManagerRepuestos.existeRepuestoEnLista(empleado.No, result.Text)) { if (result != null && !string.IsNullOrEmpty(result.Text)) { EntregaAlmacen rep = await ManagerRepuestos.addRepuesto(empleado.No, result.Text); if (rep == null) { Android.App.AlertDialog.Builder alert = new Android.App.AlertDialog.Builder(this.Activity); alert.SetTitle("Error en lectura de Código de Barras"); alert.SetMessage("Código leido: " + result); alert.SetPositiveButton("Ok", (s, e) => { rep = null; //msg = "Código leido: " + result; //this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, msg, ToastLength.Short).Show()); }); alert.Show(); } else { //var rep = await ManagerRepuestos.addRepuesto(empleado.No, result.Text); //if (rep != null) //{ adaptarSwipe.NotifyDataSetChanged(); //var activityDetalleRepuestoActivity = new Intent(this.Activity, typeof(detalleRepuestoActivity)); //activityDetalleRepuestoActivity.PutExtra("idEntregaAlmacen", rep.Key); //StartActivity(activityDetalleRepuestoActivity); Android.Support.V4.App.Fragment fragment = new AlmacenRepuestosXamarin.Fragments.DetalleRepuesto(); Bundle bundle = new Bundle(); bundle.PutString("idEntregaAlmacen", rep.Key); fragment.Arguments = bundle; FragmentManager.BeginTransaction() .Replace(Resource.Id.content_frame, fragment) .AddToBackStack("ListaRepuestosEntrega") .Commit(); //} } } else { msg = "Scaneo Cancelado"; } } else { msg = "Ya fue escaneado ese producto!!"; } if (!string.IsNullOrEmpty(msg)) { this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, msg, ToastLength.Short).Show()); } }