示例#1
0
        private void SearchData(object sender, TextChangedEventArgs e)
        {
            _listMonAn_Filtered = new List <BeanMonAn>();
            if (!String.IsNullOrEmpty(_edtSearch.Text))
            {
                string content = CmmFunction.RemoveVietNamAccent(_edtSearch.Text.Trim().ToLowerInvariant());
                _imgDeleteText.Visibility = ViewStates.Visible;
                foreach (BeanMonAn item in _listMonAn)
                {
                    string _name   = CmmFunction.RemoveVietNamAccent(item.TenMon).ToLowerInvariant();
                    string _search = CmmFunction.RemoveVietNamAccent(item.SearchData).ToLowerInvariant();
                    if (_name.Contains(content) || _search.Contains(content))
                    {
                        _listMonAn_Filtered.Add(item);
                    }
                }
            }
            else
            {
                _imgDeleteText.Visibility = ViewStates.Gone;
                _listMonAn_Filtered       = _listMonAn;
            }
            HomeRecyclerViewAdapter adapter = new HomeRecyclerViewAdapter(this, _listMonAn_Filtered, _category);

            adapter.ItemClick += Click_RecyclerData;
            _recyclerData      = FindViewById <RecyclerView>(Resource.Id.FoodCategory_RecyclerView_Data);
            _recyclerData.SetAdapter(adapter);
            _recyclerData.SetLayoutManager(new LinearLayoutManager(this));
        }
 private void setupSQLite()
 {
     SQLiteDataHandler.CreateDBSQLite();
     if (API_RESULT_LISTMONAN != null && API_RESULT_LISTMONAN.Count > 0)
     {
         List <BeanMonAn> listMonAn = new List <BeanMonAn>();
         listMonAn = SQLiteDataHandler.BeanMonAn_LoadList();
         foreach (BeanMonAn item in API_RESULT_LISTMONAN)
         {
             if (String.IsNullOrEmpty(item.SearchData)) // de search
             {
                 item.SearchData = CmmFunction.RemoveVietNamAccent(item.TenMon) + " " + CmmFunction.RemoveVietNamAccent(item.MieuTa);
             }
             if (listMonAn.Any(x => x.MaMon.Equals(item.MaMon))) // da ton tai trong db
             {
                 BeanMonAn temp = listMonAn.Find(x => x.MaMon.Equals(item.MaMon));
                 if (temp.Modified != item.Modified) // cap nhat moi
                 {
                     SQLiteDataHandler.BeanMonAn_Update(item);
                     Utilities_DownloadImageFromURL download = new Utilities_DownloadImageFromURL(this);
                     string url = Utilities_API._SiteName + Utilities_API._SiteImageUrl + item.HinhAnh;
                     download.Execute(url);
                 }
             }
             else
             {
                 SQLiteDataHandler.BeanMonAn_Insert(item);
                 Utilities_DownloadImageFromURL download = new Utilities_DownloadImageFromURL(this);
                 string url = Utilities_API._SiteName + Utilities_API._SiteImageUrl + item.HinhAnh;
                 download.Execute(url);
             }
         }
     }
 }