Beispiel #1
0
        private void SetScrollListener()
        {
            countReq = 0;
            if (rvMedLost != null)
            {
                try
                {
                    rvMedLost.HasFixedSize = true;
                    var onScrollListener = new MedicineServerRecyclerViewOnScrollListener(layoutManager);
                    onScrollListener.LoadMoreEvent += async(sender, e) =>
                    {
                        countReq++;
                        if (countReq == 1)
                        {
                            if (_medicineLostAdapter.getList().Count <= 7)
                            {
                                return;
                            }

                            var arr = _medicineLostAdapter.getList().Where(c => !(c.Uuid.Contains("disease"))).ToList();

                            var newItems = await GetMoreData(arr.Count);

                            if (newItems.Count != 0)
                            {
                                Log.Error("MEDICINE LOST", "new items: " + newItems.Count);
                                try
                                {
                                    for (var ms = 0; ms <= newItems.Count; ms++)
                                    {
                                        DateTime date = parseTimestampStringToDate(newItems[ms]);
                                        newItems[ms].Timestampstring = date.ToString();
                                        _medicineLostAdapter.AddItem(newItems[ms]);
                                    }
                                    _medicineLostAdapter.setMedsList(_medicineLostAdapter.getList().OrderBy(x => DateTime.Parse(x.Timestampstring)).ToList());
                                    _medicineLostAdapter.NotifyDataSetChanged();
                                    Log.Error("MEDICINE LOST", "new items : " + newItems.Count + " list count: " + _medicationsLost.Count);
                                }
                                catch (Exception ex)
                                {
                                    Log.Error("ERRRRR MEDICINE LOST", ex.Message);
                                }
                            }
                        }
                    };
                    rvMedLost.AddOnScrollListener(onScrollListener);
                    rvMedLost.SetLayoutManager(layoutManager);
                }
                catch (Exception ex)
                {
                    Log.Error("ERRRRR MEDICINE LOST scroll listener", ex.Message);
                }
            }
        }
Beispiel #2
0
        private void setupRecycleView(View view)
        {
            var rvMedSer = view.FindViewById <RecyclerView>(Resource.Id.rv_medser);

            cwEmpty            = view.FindViewById <CardView>(Resource.Id.cw_empty);
            cwEmpty.Visibility = ViewStates.Gone;
            var layoutManager = new LinearLayoutManager(Activity);

            rvMedSer.SetLayoutManager(layoutManager);

            _medications           = new List <MedicationSchedule>();
            _medicineServerAdapter = new MedicineServerAdapter(_medications);
            rvMedSer.SetAdapter(_medicineServerAdapter);
            _medicineServerAdapter.SetListener(this);

            countReq = 0;
            if (rvMedSer != null)
            {
                try {
                    rvMedSer.HasFixedSize = true;
                    var onScrollListener = new MedicineServerRecyclerViewOnScrollListener(layoutManager);
                    onScrollListener.LoadMoreEvent += async(sender, e) =>
                    {
                        countReq++;
                        Log.Error("MEDICATION SERVER", _medications.Count + "");
                        if (countReq == 1)
                        {
                            if (_medicineServerAdapter.getList().Count <= 7)
                            {
                                return;
                            }
                            var newItems = await GetMoreData(_medicineServerAdapter.getList().Count);

                            if (newItems.Count != 0)
                            {
                                Log.Error("MEDICATION SERVER", "new items: " + newItems.Count);
                                try
                                {
                                    for (var ms = 0; ms <= newItems.Count; ms++)
                                    {
                                        DateTime date = parseTimestampStringToDate(newItems[ms]);
                                        newItems[ms].Timestampstring = date.ToString();
                                        _medicineServerAdapter.AddItem(newItems[ms]);
                                    }
                                    _medicineServerAdapter.NotifyDataSetChanged();
                                    Log.Error("MEDICINE SERVER", "new items : " + newItems.Count + " list count: " + _medications.Count);
                                }
                                catch (Exception ex)
                                {
                                    Log.Error("ERRRRR MEDICINE SERVER", ex.Message);
                                }
                            }
                        }
                    };
                    rvMedSer.AddOnScrollListener(onScrollListener);
                    rvMedSer.SetLayoutManager(layoutManager);
                }
                catch (Exception e) {
                    Log.Error("ERRRRR MEDICINE SERVER scroll listener", e.Message);
                }
            }
        }