void mSearch_TextChanged(object sender, Android.Text.TextChangedEventArgs e) { List <Mountain> searchedMountains = (from mountain in mMountains where mountain.MtName.Contains(mSearch.Text, StringComparison.OrdinalIgnoreCase) select mountain).ToList <Mountain>(); mAdapter = new MountainsAdapter(this, Resource.Layout.ml_model, searchedMountains); mListView.Adapter = mAdapter; mMountainsTemp = searchedMountains.ToList(); RunOnUiThread(() => mAdapter.NotifyDataSetChanged()); }
public override void OnBackPressed() { var intent = new Intent(this, typeof(Activities.MainMenuAct)); StartActivity(intent); OverridePendingTransition(Resource.Animation.slide_left, Resource.Animation.fade_out); List <Mountain> filteredMountains = (mMountains.OrderBy(mountain => mountain.MtName)).ToList(); mAdapter.Update(filteredMountains); RunOnUiThread(() => mAdapter.NotifyDataSetChanged()); intent.SetFlags(ActivityFlags.ClearTop); Finish(); }
public override bool OnOptionsItemSelected(IMenuItem item) { int id = item.ItemId; if (id == Resource.Id.action1) //Show all mountains { List <Mountain> filteredMountains = (mMountains.OrderBy(mountain => mountain.MtName)).ToList <Mountain>(); mAdapter = new MountainsAdapter(this, Resource.Layout.ml_model, filteredMountains); mListView.Adapter = mAdapter; mMountainsTemp = filteredMountains.ToList(); RunOnUiThread(() => mAdapter.NotifyDataSetChanged()); } else if (id == Resource.Id.action2) //Show mountains Z-A { List <Mountain> filteredMountains = (mMountains.OrderByDescending(mountain => mountain.MtName)).ToList <Mountain>(); mAdapter = new MountainsAdapter(this, Resource.Layout.ml_model, filteredMountains); mListView.Adapter = mAdapter; mMountainsTemp = filteredMountains.ToList(); RunOnUiThread(() => mAdapter.NotifyDataSetChanged()); } else if (id == Resource.Id.action3) //Sort Elevation (lowest to highest) { List <Mountain> filteredMountains = (mMountains.OrderBy(mountain => mountain.Masl)).ToList <Mountain>(); mAdapter = new MountainsAdapter(this, Resource.Layout.ml_model, filteredMountains); mListView.Adapter = mAdapter; mMountainsTemp = filteredMountains.ToList(); RunOnUiThread(() => mAdapter.NotifyDataSetChanged()); } else if (id == Resource.Id.action4) //Sort Elevation (highest to lowest) { List <Mountain> filteredMountains = (mMountains.OrderByDescending(mountain => mountain.Masl)).ToList <Mountain>(); mAdapter = new MountainsAdapter(this, Resource.Layout.ml_model, filteredMountains); mListView.Adapter = mAdapter; mMountainsTemp = filteredMountains.ToList(); RunOnUiThread(() => mAdapter.NotifyDataSetChanged()); } else if (id == Resource.Id.action5) //Sort Difficulty from easiest { List <Mountain> filteredMountains = (mMountains.OrderBy(mountain => mountain.Difficulty)).ToList <Mountain>(); mAdapter = new MountainsAdapter(this, Resource.Layout.ml_model, filteredMountains); mListView.Adapter = mAdapter; mMountainsTemp = filteredMountains.ToList(); RunOnUiThread(() => mAdapter.NotifyDataSetChanged()); } else if (id == Resource.Id.action6) //Sort Difficulty from most difficult { List <Mountain> filteredMountains = (mMountains.OrderByDescending(mountain => mountain.Difficulty)).ToList <Mountain>(); mAdapter = new MountainsAdapter(this, Resource.Layout.ml_model, filteredMountains); mListView.Adapter = mAdapter; mMountainsTemp = filteredMountains.ToList(); RunOnUiThread(() => mAdapter.NotifyDataSetChanged()); } else if (id == Resource.Id.action7) //show LUZON { List <Mountain> filteredMountains = (from mountain in mMountains where mountain.Island == 1 orderby mountain.MtName select mountain).ToList <Mountain>(); mAdapter = new MountainsAdapter(this, Resource.Layout.ml_model, filteredMountains); mListView.Adapter = mAdapter; mMountainsTemp = filteredMountains.ToList(); RunOnUiThread(() => mAdapter.NotifyDataSetChanged()); } else if (id == Resource.Id.action8) //show Visayas { List <Mountain> filteredMountains = (from mountain in mMountains where mountain.Island == 2 orderby mountain.MtName select mountain).ToList <Mountain>(); mAdapter = new MountainsAdapter(this, Resource.Layout.ml_model, filteredMountains); mListView.Adapter = mAdapter; mMountainsTemp = filteredMountains.ToList(); RunOnUiThread(() => mAdapter.NotifyDataSetChanged()); } else if (id == Resource.Id.action9) //show Mindanao { List <Mountain> filteredMountains = (from mountain in mMountains where mountain.Island == 3 orderby mountain.MtName select mountain).ToList <Mountain>(); mAdapter = new MountainsAdapter(this, Resource.Layout.ml_model, filteredMountains); mListView.Adapter = mAdapter; mMountainsTemp = filteredMountains.ToList(); RunOnUiThread(() => mAdapter.NotifyDataSetChanged()); } else if (id == Resource.Id.action10) // show dayhike mountains { List <Mountain> filteredMountains = (from mountain in mMountains where mountain.Difficulty <= 4 orderby mountain.MtName select mountain).ToList <Mountain>(); mAdapter = new MountainsAdapter(this, Resource.Layout.ml_model, filteredMountains); mListView.Adapter = mAdapter; mMountainsTemp = filteredMountains.ToList(); RunOnUiThread(() => mAdapter.NotifyDataSetChanged()); } else if (id == Resource.Id.action11) // show overnight mountains { List <Mountain> filteredMountains = (from mountain in mMountains where mountain.Difficulty >= 4 orderby mountain.MtName select mountain).ToList <Mountain>(); mAdapter = new MountainsAdapter(this, Resource.Layout.ml_model, filteredMountains); mListView.Adapter = mAdapter; mMountainsTemp = filteredMountains.ToList(); RunOnUiThread(() => mAdapter.NotifyDataSetChanged()); } switch (item.ItemId) { case Resource.Id.search: //Search icon has been clicked mSearch.Visibility = ViewStates.Visible; if (mIsAnimating) { return(true); } if (!mAnimatedDown) { //Listview is up MyAnimation anim = new MyAnimation(mListView, mListView.Height - mSearch.Height); anim.Duration = 500; mListView.StartAnimation(anim); anim.AnimationStart += anim_AnimationStartDown; anim.AnimationEnd += anim_AnimationEndDown; mContainer.Animate().TranslationYBy(mSearch.Height).SetDuration(500).Start(); } else { //Listview is down MyAnimation anim = new MyAnimation(mListView, mListView.Height + mSearch.Height); anim.Duration = 500; mListView.StartAnimation(anim); anim.AnimationStart += anim_AnimationStartUp; anim.AnimationEnd += anim_AnimationEndUp; mContainer.Animate().TranslationYBy(-mSearch.Height).SetDuration(500).Start(); } mAnimatedDown = !mAnimatedDown; return(true); default: return(base.OnOptionsItemSelected(item)); } }