private void SortOutletList() { string orderby = ""; switch (GlobalsAndroid.SortBy) { case "OutletID": orderby = "CUSTOMER_ID"; break; case "OutletName": orderby = "CUSTOMER_NAME"; break; case "BAT": orderby = "FIS_PER"; break; case "Premium": orderby = "HP_PER"; break; case "MR": orderby = "FIS_MR_PER"; break; } if (orderby != "") { outletList.Clear(); var masterDB = GlobalsAndroid.GetMasterDBInstance(); if (masterDB != null) { outletList = masterDB.GetOutletListSortedBy(orderby); } outletListViewModels.Clear(); SelectedIndex = -1; foreach (var item in outletList) { var viewModel = new vwOutletListViewModel(item); outletListViewModels.Add(viewModel); } this.Activity.RunOnUiThread(() => { adapter = new OutletListAdapter(outletListViewModels, this); adapter.ItemClick += OnItemClick; adapter.ItemProjectCodeClick += OnItemProjectCodeClick; recyclerView.SetAdapter(adapter); }); } }
public override void OnCreateOptionsMenu(IMenu menu, MenuInflater inflater) { inflater.Inflate(Resource.Menu.fragment_outletlist_menu, menu); var item = menu.FindItem(Resource.Id.outletlist_action_search); var searchItem = MenuItemCompat.GetActionView(item); _searchView = searchItem.JavaCast <Android.Support.V7.Widget.SearchView>(); _searchView.QueryTextChange += (sender, e) => { var keyword = _searchView.Query; var resultList = outletList.FindAll(delegate(vwOutletList outlet) { return(outlet.getCustomerID().ToLower().Contains(keyword.ToLower()) || outlet.getCustomerName().ToLower().Contains(keyword.ToLower())); }); outletListViewModels.Clear(); SelectedIndex = -1; foreach (var outlet in resultList) { var viewModel = new vwOutletListViewModel(outlet); outletListViewModels.Add(viewModel); } // Plug in my adapter: adapter = new OutletListAdapter(outletListViewModels, this); adapter.ItemClick += OnItemClick; adapter.ItemProjectCodeClick += OnItemProjectCodeClick; recyclerView.SetAdapter(adapter); }; var expandListener = new SearchViewExpandListener(); expandListener.SearchViewMenuItemActionCollapsed += OnSearchViewMenuItemActionCollapsed; expandListener.SearchViewMenuItemActionExpanded += OnSearchViewMenuItemActionExpanded; MenuItemCompat.SetOnActionExpandListener(item, expandListener); this.menu = menu; base.OnCreateOptionsMenu(menu, inflater); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Use this to return your custom view for this Fragment HasOptionsMenu = true; var view = inflater.Inflate(Resource.Layout.fragment_outletlist, null); recyclerView = (RecyclerView)view.FindViewById(Resource.Id.recyclerview_outletlist); // Plug in the linear layout manager: var layoutManager = new LinearLayoutManager(Activity); recyclerView.SetLayoutManager(layoutManager); // Plug in my adapter: adapter = new OutletListAdapter(outletListViewModels, this); adapter.ItemClick += OnItemClick; adapter.ItemProjectCodeClick += OnItemProjectCodeClick; recyclerView.SetAdapter(adapter); return(view); }