예제 #1
0
        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());
        }
예제 #2
0
        private void oncreate()
        {
            int position = Intent.GetIntExtra("mtDataPos", 177);

            mountainsRepository = new MountainsService();
            if (position == 177)
            {
                ViewHolder();
                mSearch.TextChanged            += mSearch_TextChanged;
                mListView.FastScrollEnabled     = true;
                mListView.ScrollingCacheEnabled = false;
                mMountains     = mountainsRepository.GetAllMountains();
                mMountainsTemp = mMountains.ToList();
                mSearch.Alpha  = 0;
                mContainer.BringToFront();
                mAdapter          = new MountainsAdapter(this, Resource.Layout.ml_model, mMountains);
                mListView.Adapter = mAdapter;
                ItemClickMethod();
            }
            else
            {
                ViewHolder();
                mSearch.TextChanged            += mSearch_TextChanged;
                mListView.ScrollingCacheEnabled = false;
                mListView.FastScrollEnabled     = true;
                mMountains           = mountainsRepository.GetAllMountains();
                mMountainsTemp       = mMountains.ToList();
                mListView.ItemClick += mListView_ItemClick;
                mSearch.Alpha        = 0;
                mContainer.BringToFront();
                mAdapter          = new MountainsAdapter(this, Resource.Layout.ml_model, mMountains);
                mListView.Adapter = mAdapter;
                ItemClickMethod();
                OpenDetailActivitys(position);
            }
        }
예제 #3
0
        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));
            }
        }