Example #1
0
        private void SetupListView()
        {
            _listView = _view.FindViewById <ListView>(Resource.Id.listViewAudioDramas);

            _listViewAdapter = new AudioDramaListAdapter(Activity, _imageViewFiller, _releaseDateService);

            _listView.ItemClick += (sender, args) =>
            {
                var audioDrama = _listViewAdapter[args.Position];
                AudioDramaClicked?.Invoke(this, audioDrama.AudioDramaDto.Id);
            };

            var swipeActionAdapter = new SwipeActionAdapter(_listViewAdapter);

            swipeActionAdapter.SetListView(_listView);

            _listView.Adapter = swipeActionAdapter;

            swipeActionAdapter
            .AddBackground(SwipeDirection.DirectionFarLeft, Resource.Layout.swipebackgroundleft)
            .AddBackground(SwipeDirection.DirectionFarRight, Resource.Layout.swipebackgroundright)
            .AddBackground(SwipeDirection.DirectionNormalLeft, Resource.Layout.swipebackgroundleft)
            .AddBackground(SwipeDirection.DirectionNormalRight, Resource.Layout.swipebackgroundright);

            _swipeActionListener = new SwipeActionListener();

            _swipeActionListener.LeftSwiped += (sender, i) =>
            {
                try
                {
                    var audioDrama = _listViewAdapter[i];
                    HeardClicked?.Invoke(this, audioDrama.AudioDramaDto.Id);
                }
                catch (ArgumentOutOfRangeException)
                {
                    _userNotifier.Notify("Fehler beim Markieren als gehört. Bitte erneut versuchen.");
                }
            };

            _swipeActionListener.RightSwiped += (sender, i) =>
            {
                try
                {
                    var audioDrama = _listViewAdapter[i];
                    IsFavoriteClicked?.Invoke(this, audioDrama.AudioDramaDto.Id);
                }
                catch (ArgumentOutOfRangeException)
                {
                    _userNotifier.Notify("Fehler beim Markieren als Favorit. Bitte erneut versuchen.");
                }
            };


            swipeActionAdapter.SetSwipeActionListener(_swipeActionListener);
        }
        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);
        }