protected void AttachSearchViewActivityDrawer(FloatingSearchView searchView)
 {
     if (callbacks != null)
     {
         callbacks.OnAttachSearchViewToDrawer(searchView);
     }
 }
Ejemplo n.º 2
0
        public override void OnViewCreated(View view, Bundle savedInstanceState)
        {
            base.OnViewCreated(view, savedInstanceState);

            mSearchView        = view.FindViewById <FloatingSearchView>(Resource.Id.floating_search_view);
            mSearchResultsList = view.FindViewById <RecyclerView>(Resource.Id.search_results_list);

            SetupFloatingSearch();
            SetupResultsList();
            SetupDrawer();
        }
        public override void OnViewCreated(View view, Bundle savedInstanceState)
        {
            base.OnViewCreated(view, savedInstanceState);

            mSearchView = view.FindViewById <FloatingSearchView>(Resource.Id.floating_search_view);
            mAppBar     = view.FindViewById <AppBarLayout>(Resource.Id.appbar);

            mAppBar.OffsetChanged += (sender, e) =>
            {
                mSearchView.TranslationY = e.VerticalOffset;
            };

            SetupDrawer();
            SetupSearchBar();
        }
Ejemplo n.º 4
0
        void AddControls()
        {
            searchView         = FindViewById <FloatingSearchView>(Resource.Id.floating_search_view);
            recycler           = FindViewById <RecyclerView>(Resource.Id.recycler);
            progressBarLoading = FindViewById <ProgressBar>(Resource.Id.loading);
            layoutManager      = new LinearLayoutManager(this);
            recycler.SetLayoutManager(layoutManager);


            pref   = Application.Context.GetSharedPreferences("History", FileCreationMode.Private);
            editor = pref.Edit();

            //Get the history search
            searchHistory = pref.GetString("search_string", "");
        }
Ejemplo n.º 5
0
        public override void OnViewCreated(View view, Bundle savedInstanceState)
        {
            base.OnViewCreated(view, savedInstanceState);

            mSearchView = view.FindViewById <FloatingSearchView>(Resource.Id.floating_search_view);
            mHeaderView = view.FindViewById(Resource.Id.header_view);

            mDimSearchViewBackground = view.FindViewById(Resource.Id.dim_background);
            mDimDrawable             = new ColorDrawable(Color.Black);
            mDimDrawable.SetAlpha(0);
            if (Build.VERSION.SdkInt >= BuildVersionCodes.JellyBean)
            {
                mDimSearchViewBackground.Background = mDimDrawable;
            }
            else
            {
                mDimSearchViewBackground.SetBackgroundDrawable(mDimDrawable);
            }

            SetupFloatingSearch();
            SetupDrawer();
        }
Ejemplo n.º 6
0
 public void OnAttachSearchViewToDrawer(FloatingSearchView searchView)
 {
     searchView.AttachNavigationDrawerToMenuButton(drawerLayout);
 }
Ejemplo n.º 7
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.activity_main);

            parentView = FindViewById <ViewGroup> (Resource.Id.parent_view);

            searchView     = FindViewById <FloatingSearchView> (Resource.Id.floating_search_view);
            colorNameText  = FindViewById <TextView> (Resource.Id.color_name_text);
            colorValueText = FindViewById <TextView> (Resource.Id.color_value_text);

            drawerLayout = FindViewById <DrawerLayout> (Resource.Id.drawer_layout);

            // sets the background color
            RefreshBackgroundColor("Xamarin Blue", "#3498DB");

            searchView.QueryChange += async(sender, e) => {
                if (!string.IsNullOrEmpty(e.OldQuery) && string.IsNullOrEmpty(e.NewQuery))
                {
                    searchView.ClearSuggestions();
                }
                else
                {
                    // this shows the top left circular progress
                    // you can call it where ever you want, but
                    // it makes sense to do it when loading something in
                    // the background.
                    searchView.ShowProgress();

                    // simulates a query call to a data source
                    // with a new query.
                    var results = await DataHelper.FindAsync(this, e.NewQuery);

                    // this will swap the data and
                    // render the collapse/expand animations as necessary
                    searchView.SwapSuggestions(results);

                    // let the users know that the background
                    // process has completed
                    searchView.HideProgress();
                }

                Console.WriteLine("QueryChange");
            };

            searchView.SuggestionClicked += (sender, e) => {
                var colorSuggestion = (ColorSuggestion)e.SearchSuggestion;
                RefreshBackgroundColor(colorSuggestion.Color.Name, colorSuggestion.Color.Hex);

                Console.WriteLine("SuggestionClicked");
            };

            searchView.SearchAction += (sender, e) => {
                Console.WriteLine("SearchAction");
            };

            searchView.Focus += async(sender, e) => {
                searchView.SwapSuggestions(await DataHelper.GetHistoryAsync(this, 3));

                Console.WriteLine("Focus");
            };

            searchView.FocusCleared += (sender, e) => {
                Console.WriteLine("FocusCleared");
            };

            searchView.MenuItemClick += (sender, e) => {
                // handle menu clicks the same way as you would
                // in a regular activity
                switch (e.MenuItem.ItemId)
                {
                case Resource.Id.action_show_menu:
                    searchView.SetLeftShowMenu(true);
                    break;

                case Resource.Id.action_hide_menu:
                    searchView.SetLeftShowMenu(false);
                    break;
                }
            };

            searchView.MenuOpened += (sender, e) => {
                drawerLayout.OpenDrawer(GravityCompat.Start);
            };

            searchView.MenuClosed += (sender, e) => {
                drawerLayout.CloseDrawer(GravityCompat.Start);
            };

            drawerLayout.DrawerOpened += (sender, e) => {
                // since the drawer might have opened as a results of
                // a click on the left menu, we need to make sure
                // to close it right after the drawer opens, so that
                // it is closed when the drawer is closed.
                searchView.CloseMenu(false);
            };
        }