private void SetRecyclerViewAdapters()
        {
            try
            {
                MAdapter = new SuggestionsAdapter(this)
                {
                    SuggestionsList = new ObservableCollection <UserDataObject>()
                };
                LayoutManager = new GridLayoutManager(this, 3);
                MRecycler.SetLayoutManager(LayoutManager);
                MRecycler.HasFixedSize = true;
                MRecycler.SetItemViewCacheSize(10);
                MRecycler.GetLayoutManager().ItemPrefetchEnabled = true;
                var sizeProvider = new FixedPreloadSizeProvider(10, 10);
                var preLoader    = new RecyclerViewPreloader <UserDataObject>(this, MAdapter, sizeProvider, 10);
                MRecycler.AddOnScrollListener(preLoader);
                MRecycler.SetAdapter(MAdapter);

                RecyclerViewOnScrollListener xamarinRecyclerViewOnScrollListener = new RecyclerViewOnScrollListener(LayoutManager);
                MainScrollEvent = xamarinRecyclerViewOnScrollListener;
                MainScrollEvent.LoadMoreEvent += MainScrollEventOnLoadMoreEvent;
                MRecycler.AddOnScrollListener(xamarinRecyclerViewOnScrollListener);
                MainScrollEvent.IsLoading = false;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Exemplo n.º 2
0
		public override bool OnCreateOptionsMenu (IMenu menu)
		{
			//Used to put dark icons on light action bar
			bool isLight = SampleList.THEME == Resource.Style.Sherlock___Theme_Light;

			//Create the search view
			SearchView searchView = new SearchView (SupportActionBar.ThemedContext);
			searchView.QueryHint = "Search for countries…";
			searchView.SetOnQueryTextListener (this);
			searchView.SetOnSuggestionListener (this);

			if (mSuggestionsAdapter == null) {
				MatrixCursor cursor = new MatrixCursor (COLUMNS);
				Converter<string, Java.Lang.Object> func = s => new Java.Lang.String (s);
				cursor.AddRow (Array.ConvertAll<string,Java.Lang.Object> (new string[] { "1", "'Murica" }, func));
				cursor.AddRow (Array.ConvertAll<string,Java.Lang.Object> (new string[] { "2", "Canada" }, func));
				cursor.AddRow (Array.ConvertAll<string,Java.Lang.Object> (new string[] { "3", "Denmark" }, func));
				mSuggestionsAdapter = new SuggestionsAdapter (SupportActionBar.ThemedContext, cursor);
			}

			searchView.SuggestionsAdapter = mSuggestionsAdapter;

			menu.Add ("Search")
				.SetIcon (isLight ? Resource.Drawable.ic_search_inverse : Resource.Drawable.abs__ic_search)
					.SetActionView (searchView)
					.SetShowAsAction (MenuItem.ShowAsActionIfRoom | MenuItem.ShowAsActionCollapseActionView);

			return true;
		}
Exemplo n.º 3
0
        public override bool OnCreateOptionsMenu(IMenu menu)
        {
            //Used to put dark icons on light action bar
            bool isLight = SampleList.THEME == Resource.Style.Sherlock___Theme_Light;

            //Create the search view
            SearchView searchView = new SearchView(SupportActionBar.ThemedContext);

            searchView.QueryHint = "Search for countries…";
            searchView.SetOnQueryTextListener(this);
            searchView.SetOnSuggestionListener(this);

            if (mSuggestionsAdapter == null)
            {
                MatrixCursor cursor = new MatrixCursor(COLUMNS);
                Converter <string, Java.Lang.Object> func = s => new Java.Lang.String(s);
                cursor.AddRow(Array.ConvertAll <string, Java.Lang.Object> (new string[] { "1", "'Murica" }, func));
                cursor.AddRow(Array.ConvertAll <string, Java.Lang.Object> (new string[] { "2", "Canada" }, func));
                cursor.AddRow(Array.ConvertAll <string, Java.Lang.Object> (new string[] { "3", "Denmark" }, func));
                mSuggestionsAdapter = new SuggestionsAdapter(SupportActionBar.ThemedContext, cursor);
            }

            searchView.SuggestionsAdapter = mSuggestionsAdapter;

            menu.Add("Search")
            .SetIcon(isLight ? Resource.Drawable.ic_search_inverse : Resource.Drawable.abs__ic_search)
            .SetActionView(searchView)
            .SetShowAsAction(MenuItem.ShowAsActionIfRoom | MenuItem.ShowAsActionCollapseActionView);

            return(true);
        }
Exemplo n.º 4
0
 private void OnFetchTimerTick(object sender, EventArgs e)
 {
     FetchTimer.IsEnabled = false;
     FetchTimer.Stop();
     if (Provider != null && ItemsSelector != null)
     {
         Filter = Editor.Text;
         if (_suggestionsAdapter == null)
         {
             _suggestionsAdapter = new SuggestionsAdapter(this);
         }
         _suggestionsAdapter.GetSuggestions(Filter);
     }
 }
 private void OnFetchTimerTick(object sender, EventArgs e)
 {
     this.FetchTimer.IsEnabled = false;
     this.FetchTimer.Stop();
     if (this.Provider != null && this.ItemsSelector != null)
     {
         this.Filter = this.Editor.Text;
         if (this._suggestionsAdapter == null)
         {
             this._suggestionsAdapter = new SuggestionsAdapter(this);
         }
         this._suggestionsAdapter.GetSuggestions(this.Filter);
     }
 }
Exemplo n.º 6
0
        private void SetRecyclerViewAdapters()
        {
            try
            {
                SuggestionsAdapter = new SuggestionsAdapter(Activity);
                LinearLayoutManager suggestionsLayoutManager = new LinearLayoutManager(Activity, LinearLayoutManager.Horizontal, false);
                SuggestionsRecylerView.SetLayoutManager(suggestionsLayoutManager);
                SuggestionsRecylerView.HasFixedSize = true;
                SuggestionsRecylerView.SetItemViewCacheSize(10);
                SuggestionsRecylerView.GetLayoutManager().ItemPrefetchEnabled = true;
                var sizeProviderSuggestions = new FixedPreloadSizeProvider(10, 10);
                var preLoaderSuggestions    = new RecyclerViewPreloader <UserDataObject>(Activity, SuggestionsAdapter, sizeProviderSuggestions, 10);
                SuggestionsRecylerView.AddOnScrollListener(preLoaderSuggestions);
                SuggestionsAdapter.ItemClick += SuggestionsAdapterOnItemClick;
                SuggestionsRecylerView.SetAdapter(SuggestionsAdapter);

                RecyclerViewOnScrollListener xamarinRecyclerViewOnScrollListener2 = new RecyclerViewOnScrollListener(suggestionsLayoutManager);
                SeconderScrollEvent = xamarinRecyclerViewOnScrollListener2;
                SeconderScrollEvent.LoadMoreEvent += SeconderScrollEventOnLoadMoreEvent;
                SuggestionsRecylerView.AddOnScrollListener(xamarinRecyclerViewOnScrollListener2);
                SeconderScrollEvent.IsLoading = false;

                //*******************************************************************

                ExploreAdapter = new ExploreAdapter(Activity);
                GridLayoutManager mLayoutManager = new GridLayoutManager(Activity, 3);
                mLayoutManager.SetSpanSizeLookup(new MySpanSizeLookup(8, 1, 2));
                ExploreRecylerView.AddItemDecoration(new GridSpacingItemDecoration(1, 1, true));
                ExploreRecylerView.SetLayoutManager(mLayoutManager);
                ExploreRecylerView.HasFixedSize = true;
                ExploreRecylerView.SetItemViewCacheSize(10);
                ExploreRecylerView.GetLayoutManager().ItemPrefetchEnabled = true;
                var sizeProvider = new FixedPreloadSizeProvider(10, 10);
                var preLoader    = new RecyclerViewPreloader <PostsObject>(Activity, ExploreAdapter, sizeProvider, 8);
                ExploreRecylerView.AddOnScrollListener(preLoader);
                ExploreAdapter.ItemClick += ExploreAdapterOnItemClick;
                ExploreRecylerView.SetAdapter(ExploreAdapter);

                RecyclerViewOnScrollListener xamarinRecyclerViewOnScrollListener = new RecyclerViewOnScrollListener(mLayoutManager);
                MainScrollEvent = xamarinRecyclerViewOnScrollListener;
                MainScrollEvent.LoadMoreEvent += MainScrollEventOnLoadMoreEvent;
                ExploreRecylerView.AddOnScrollListener(xamarinRecyclerViewOnScrollListener);
                MainScrollEvent.IsLoading = false;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
 private void OnFetchTimerTick(object sender, EventArgs e)
 {
     FetchTimer.IsEnabled = false;
     FetchTimer.Stop();
     if (Provider != null && ItemsSelector != null) {
         Filter = Editor.Text;
         if (_suggestionsAdapter == null) {
             _suggestionsAdapter = new SuggestionsAdapter(this);
         }
         _suggestionsAdapter.GetSuggestions(Filter);
     }
 }
Exemplo n.º 8
0
        //https://philio.me/styling-the-searchview-with-appcompat-v21/
        //https://code.google.com/p/android/issues/detail?id=70754
        public void Init(string searchIdName, string textFieldHint, bool topLine, bool serachLine, bool bottomline = false)
        {
            _stoppingPlaceViewModel = Stops.Setup.IoC.Container.Get <Core.ViewModels.SearchViewModel> ();


            /*
             * Load last selected on startup
             */
            _searchView           = _view.FindViewById <Android.Support.V7.Widget.SearchView> (Resource.Id.SearchFragmentSearch);
            _searchView.QueryHint = textFieldHint;
            _searchView.SetOnQueryTextListener(this);
            _searchView.SetOnSuggestionListener(this);

            ((EditText)_searchView.FindViewById(Resource.Id.search_src_text)).CustomSelectionActionModeCallback
                = this;

            if (mSuggestionsAdapter == null)
            {
                MatrixCursor cursor = new MatrixCursor(COLUMNS);
                mSuggestionsAdapter = new SuggestionsAdapter(Android.App.Application.Context, cursor);
            }

            _searchView.SuggestionsAdapter = mSuggestionsAdapter;


            if (!topLine)
            {
                var topLineView = _view.FindViewById <FrameLayout> (Resource.Id.SearchFragmentTopLine);
                topLineView.Visibility = topLine ? ViewStates.Visible : ViewStates.Gone;
            }

            if (!serachLine)
            {
                var view = _view.FindViewById <FrameLayout> (Resource.Id.SearchFragmentDragLine);
                view.Visibility = serachLine ? ViewStates.Visible : ViewStates.Gone;
            }
            if (!bottomline)
            {
                var view = _view.FindViewById <FrameLayout>(Resource.Id.SearchFragmentBottomLine);
                view.Visibility = serachLine ? ViewStates.Visible : ViewStates.Gone;
            }

            int searchEditTextId = Resource.Id.search_src_text;             // for AppCompat

            // get AutoCompleteTextView from SearchView
            AutoCompleteTextView searchEditText = (AutoCompleteTextView)_searchView.FindViewById(searchEditTextId);
            View dropDownAnchor = _searchView.FindViewById(searchEditText.DropDownAnchor);

            dropDownAnchor.AddOnLayoutChangeListener(this);

            searchEditText.LongClick += (object sender, View.LongClickEventArgs e) => {
                SetChoicedStop(null);
            };

            /*
             * Init the view model and set the last chocied stop
             */
            _stoppingPlaceViewModel.Init(searchIdName);
            if (_stoppingPlaceViewModel.HasLatestCLickeStop())
            {
                _choicedStop = _stoppingPlaceViewModel.GetLatestCLickeStop();
                _ignoreAutoCompleteTextChange = true;

                _searchView.SetQuery(_choicedStop.Name, true);
                Events.Trigger("initWithStop", _choicedStop, 100);
            }

            var btnPos = _view.FindViewById <ImageButton> (Resource.Id.btnPos);

            btnPos.Click += (object sender, EventArgs e) => {
                Events.Trigger("locationClick", null);
                return;
            };
        }