private void RefreshItemsFromTable()
        {
            try
            {
                _adapter.Flag   = false;
                _text_view.Text = "Loading..";

                // Get the items that weren't marked as completed and add them in the adapter
                var list = ((MainActivity)Activity).List;
                var favs = ((MainApplication)Activity.Application).FavoriteRepository.GetAllFavorites();
                _adapter.Clear();
                HashSet <string> set = new HashSet <string>();
                foreach (var i in favs)
                {
                    set.Add(i.ToString());
                }
                foreach (var current in list)
                {
                    if (set.Contains(current.Id))
                    {
                        _adapter.Add(current);
                    }
                }

                _adapter.Flag   = true;
                _text_view.Text = GetString(Resource.String.your_favorites);
            }
            catch (Exception e)
            {
                HelpMe.CreateAndShowDialog(e.Message, "Error", Activity);
            }
        }
Esempio n. 2
0
 private async void Update()
 {
     try
     {
         List = await((MainApplication)Application).arrangementTable.ToListAsync();
     }
     catch (Exception e)
     {
         HelpMe.CreateAndShowDialog(e.Message, "Error", this);
     }
     foreach (var i in List)
     {
         Console.Write(i.Date + " ");
     }
     List.Sort((a, b) => a.Date.Date.CompareTo(b.Date.Date));
     _pager.Adapter.NotifyDataSetChanged();
 }
        //Refresh the list.
        private void RefreshItemsFromTable()
        {
            try
            {
                _adapter.Flag = false;
                var tmp = _mDateEditext.Text;
                _mDateEditext.Text = "Loading..";

                // Get the items and add them in the adapter
                var list = ((MainActivity)Activity).List;
                _adapter.Clear();

                if (MainActivity.byDateFilter)
                {
                    if (MainActivity.byAuthorFilter)
                    {
                        foreach (var current in list)
                        {
                            if (current.Date.Date == MainActivity.dateFilter.Date && current.Author == MainActivity.Author)
                            {
                                _adapter.Add(current);
                            }
                        }
                    }
                    else
                    {
                        foreach (var current in list)
                        {
                            if (current.Date.Date == MainActivity.dateFilter.Date)
                            {
                                _adapter.Add(current);
                            }
                        }
                    }
                }
                else if (MainActivity.byAuthorFilter)
                {
                    foreach (var current in list)
                    {
                        if (current.Author == MainActivity.Author)
                        {
                            _adapter.Add(current);
                        }
                    }
                }
                else
                {
                    foreach (var current in list)
                    {
                        _adapter.Add(current);
                    }
                }

                if (_adapter.Count == 0 && list.Count != 0)
                {
                    Toast.MakeText(this.Activity, "Not Found", ToastLength.Short).Show();
                }
                _adapter.Flag      = true;
                _mDateEditext.Text = tmp;
            }
            catch (Exception e)
            {
                HelpMe.CreateAndShowDialog(e.Message, "Error", Activity);
            }
        }