Пример #1
0
        private void SearchViewOnQueryTextSubmit(object sender, SearchView.QueryTextSubmitEventArgs e)
        {
            try
            {
                SearchView.ClearFocus();

                UserTab.MAdapter.UserList.Clear();
                UserTab.MAdapter.NotifyDataSetChanged();

                HashTagTab.MAdapter.HashTagsList.Clear();
                HashTagTab.MAdapter.NotifyDataSetChanged();

                if (Methods.CheckConnectivity())
                {
                    if (UserTab.MAdapter.UserList.Count > 0)
                    {
                        UserTab.MAdapter.UserList.Clear();
                        UserTab.MAdapter.NotifyDataSetChanged();
                    }

                    if (HashTagTab.MAdapter.HashTagsList.Count > 0)
                    {
                        HashTagTab.MAdapter.HashTagsList.Clear();
                        HashTagTab.MAdapter.NotifyDataSetChanged();
                    }

                    UserTab.ProgressBarLoader.Visibility = ViewStates.Visible;
                    UserTab.EmptyStateLayout.Visibility  = ViewStates.Gone;
                    PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                        StartSearchRequest
                    });
                }
                else
                {
                    if (UserTab.Inflated == null)
                    {
                        UserTab.Inflated = UserTab.EmptyStateLayout.Inflate();
                    }

                    EmptyStateInflater x = new EmptyStateInflater();
                    x.InflateLayout(UserTab.Inflated, EmptyStateInflater.Type.NoConnection);
                    if (x.EmptyStateButton.HasOnClickListeners)
                    {
                        x.EmptyStateButton.Click -= EmptyStateButtonOnClick;
                        x.EmptyStateButton.Click -= TryAgainButton_Click;
                    }

                    x.EmptyStateButton.Click            += TryAgainButton_Click;
                    UserTab.ProgressBarLoader.Visibility = ViewStates.Gone;
                    UserTab.EmptyStateLayout.Visibility  = ViewStates.Visible;
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
Пример #2
0
 protected override void OnResume()
 {
     base.OnResume();
     searchView.Post(() =>
     {
         if (searchView.IsIconfiedByDefault)
         {
             searchView.ClearFocus();
         }
     });
 }
Пример #3
0
        public void OnClick(View v)
        {
            if (v.Id == SearchViewBar.Id)
            {
                //Hide keyboard programmatically in MonoDroid

                var inputManager = (InputMethodManager)GetSystemService(InputMethodService);
                inputManager.HideSoftInputFromWindow(SearchViewBar.WindowToken, HideSoftInputFlags.None);

                SearchViewBar.ClearFocus();

                var intent = new Intent(this, typeof(Search_Tabbed_Activity));
                intent.PutExtra("Key", "");
                StartActivity(intent);
            }
        }
        private void SearchViewOnQueryTextSubmit(object sender, SearchView.QueryTextSubmitEventArgs e)
        {
            try
            {
                SearchKey = e.NewText;

                GamesTab.MAdapter.GamesList.Clear();
                GamesTab.MAdapter.NotifyDataSetChanged();

                GamesTab.SwipeRefreshLayout.Refreshing = true;

                if (!Methods.CheckConnectivity())
                {
                    Toast.MakeText(this, GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                }
                else
                {
                    PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                        () => SearchGames()
                    });
                }

                //Hide keyboard programmatically in MonoDroid
                e.Handled = true;

                SearchView.ClearFocus();

                var inputManager = (InputMethodManager)GetSystemService(InputMethodService);
                inputManager.HideSoftInputFromWindow(ToolBar.WindowToken, 0);
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
        public override bool OnCreateOptionsMenu(IMenu menu)
        {
            MenuInflater.Inflate(Resource.Menu.SearchGif_Menu, menu);

            try
            {
                var        item       = menu.FindItem(Resource.Id.searchUserBar);
                SearchView searchItem = (SearchView)item.ActionView;

                SearchView = searchItem.JavaCast <SearchView>();
                SearchView.SetQuery("", false);
                SearchView.SetIconifiedByDefault(false);
                SearchView.OnActionViewExpanded();
                SearchView.Iconified        = false;
                SearchView.QueryTextChange += SearchViewOnQueryTextChange;
                SearchView.QueryTextSubmit += SearchViewOnQueryTextSubmit;
                SearchView.ClearFocus();

                //Change text colors
                var editText = (EditText)SearchView.FindViewById(Resource.Id.search_src_text);
                editText.SetHintTextColor(Color.White);
                editText.SetTextColor(Color.White);

                //Remove Icon Search
                ImageView searchViewIcon         = (ImageView)SearchView.FindViewById(Resource.Id.search_mag_icon);
                ViewGroup linearLayoutSearchView = (ViewGroup)searchViewIcon.Parent;
                linearLayoutSearchView.RemoveView(searchViewIcon);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            return(base.OnCreateOptionsMenu(menu));
        }
Пример #6
0
        private void InitToolbar(View view)
        {
            try
            {
                var toolbar = view.FindViewById <Toolbar>(Resource.Id.toolbar);
                GlobalContext.SetToolBar(toolbar, "");

                SearchBox = view.FindViewById <SearchView>(Resource.Id.searchBox);
                SearchBox.SetQuery("", false);
                SearchBox.SetIconifiedByDefault(false);
                SearchBox.OnActionViewExpanded();
                SearchBox.Iconified        = false;
                SearchBox.QueryTextChange += SearchBoxOnQueryTextChange;
                SearchBox.QueryTextSubmit += SearchBoxOnQueryTextSubmit;
                SearchBox.ClearFocus();

                //Change text colors
                var editText = (EditText)SearchBox.FindViewById(Resource.Id.search_src_text);
                editText.SetHintTextColor(Color.Gray);
                editText.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black);

                //Remove Icon Search
                ImageView searchViewIcon         = (ImageView)SearchBox.FindViewById(Resource.Id.search_mag_icon);
                ViewGroup linearLayoutSearchView = (ViewGroup)searchViewIcon.Parent;
                linearLayoutSearchView.RemoveView(searchViewIcon);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Пример #7
0
        private void InitComponent(View view)
        {
            try
            {
                SearchView = view.FindViewById <SearchView>(Resource.Id.searchviewbox);
                SearchView.SetQuery("", false);
                SearchView.ClearFocus();
                SearchView.OnActionViewExpanded();
                SearchView.SetIconifiedByDefault(true);
                SearchView.OnActionViewExpanded();

                //Change text colors
                var editText = (EditText)SearchView.FindViewById(Resource.Id.search_src_text);
                editText.SetHintTextColor(Color.Gray);
                editText.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black);

                TabLayout = view.FindViewById <TabLayout>(Resource.Id.Searchtabs);
                ViewPager = view.FindViewById <ViewPager>(Resource.Id.Searchviewpager);

                AppBarLayout = view.FindViewById <AppBarLayout>(Resource.Id.mainAppBarLayout);
                AppBarLayout.SetExpanded(true);

                //Set Tab
                ViewPager.OffscreenPageLimit = 2;
                SetUpViewPager(ViewPager);
                TabLayout.SetupWithViewPager(ViewPager);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
        private void EditTextOnClick(object sender, View.TouchEventArgs e)
        {
            try
            {
                if (e.Event.Action != MotionEventActions.Down)
                {
                    return;
                }

                Bundle bundle = new Bundle();
                bundle.PutString("Key", "");
                SearchFragment = new SearchFragment
                {
                    Arguments = bundle
                };
                GlobalContext.FragmentBottomNavigator.DisplayFragment(SearchFragment);
                SearchBox.ClearFocus();
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
Пример #9
0
        void OnListItemClick(object sender, AdapterView.ItemClickEventArgs e)
        {
            var listView = sender as ListView;
            var t        = torrents[e.Position];
            //Android.Widget.Toast.MakeText(this, t.Name, Android.Widget.ToastLength.Short).Show();
            Bundle mybundle = new Bundle();

            mybundle.PutString("torname", t.Name);
            mybundle.PutString("magnet", t.Magnet);
            mybundle.PutString("pageurl", t.TpbPage);
            //mybundle.PutString("torname", t.Name);
            TorDetailDialogFragment modalBottomSheet = new TorDetailDialogFragment();

            modalBottomSheet.Arguments = mybundle;
            modalBottomSheet.Show(SupportFragmentManager, "modalMenu");


            //View dialogView = LayoutInflater.Inflate(Resource.Layout.TorrentDetailDialog, null);
            //BottomSheetDialog dialog = new BottomSheetDialog(this);
            //dialog.SetContentView(dialogView);
            //dialog.Show();

            //FragmentTransaction transaction = FragmentManager.BeginTransaction().SetCustomAnimations(Resource.Animation.abc_grow_fade_in_from_bottom, Resource.Animation.abc_shrink_fade_out_from_bottom) ;
            //TorDetailDialogFragment detdialog = new TorDetailDialogFragment();
            //detdialog.Show(transaction, "Dialog Fragment");

            //torrentDialog = new Dialog(this);
            //torrentDialog.SetContentView(Resource.Layout.TorrentDetailDialog);
            //torrentDialog.Window.SetSoftInputMode(SoftInput.AdjustResize);

            torSearchView.ClearFocus();
            torSearchView.SetQuery("", false);

            //MenuItemCompat.CollapseActionView(item);
            //torrentDialog.Show();

            // detailDialogToolbar = torrentDialog.FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.tordetaildialog_toolbar);
            //detailDialogToolbar.SetNavigationIcon(Resource.Drawable.ic_backarrow);
            //detailDialogToolbar.SetOnMenuItemClickListener(new Android.Support.V7.Widget.Toolbar.on() {

            //torrentDialog.Window.SetLayout(LayoutParams.FillParent, LayoutParams.FillParent);
            //torrentDialog.Window.SetBackgroundDrawableResource(Resource.Color.mtrl_btn_transparent_bg_color);;

            //tvTorName = torrentDialog.FindViewById<TextView>(Resource.Id.tvTorrentName);
            //tvTorUploaded = torrentDialog.FindViewById<TextView>(Resource.Id.tvTorrentUploaded);
            //tvTorName.Text = t.Name;
            //tvTorUploaded.Text = t.Uploaded;
        }
        public override void OnCreateOptionsMenu(IMenu menu, MenuInflater inflater)
        {
            inflater.Inflate(Resource.Menu.menu, menu);
            item = menu.FindItem(Resource.Id.action_search);
            var searchItem = Android.Support.V4.View.MenuItemCompat.GetActionView(item);

            searchView           = searchItem.JavaCast <SearchView>();
            searchView.QueryHint = "Search WeClip";
            searchView.Focusable = (false);
            searchView.SetQuery(query, false);
            searchView.Iconified = (false);
            searchView.RequestFocusFromTouch();
            searchView.SetOnQueryTextListener(this);
            if (query != null)
            {
                searchView.ClearFocus();
            }
        }
        public override bool OnCreateOptionsMenu(IMenu menu)
        {
            MenuInflater.Inflate(Resource.Menu.main, menu);

            var item = menu.FindItem(Resource.Id.action_search);

            var searchView = MenuItemCompat.GetActionView(item);
            _searchView = searchView.JavaCast<Android.Support.V7.Widget.SearchView>();

               // _searchView.QueryTextChange += (s, e) => _adapter.Filter.InvokeFilter(e.NewText);

            _searchView.QueryTextSubmit += (s, e) =>
            {
                // Handle enter/search button on keyboard here
                Toast.MakeText(this, "Searched for: " + e.Query, ToastLength.Short).Show();
            //				_adapter.Filter.InvokeFilter(e.Query);

                try
                {
                    var json = WebServices.getSearchResult(e.Query);
                    var ProdData = JsonConvert.DeserializeObject<WebServices.RootObject> (json);

                    Console.Error.WriteLine(ProdData.data[0].title);
                }
                catch
                {
                    RunOnUiThread (() => {
                        chemicals.Clear();
                        _adapter.NotifyDataSetChanged ();
                        _adapter.NotifyDataSetInvalidated();

                    });

                    Console.Error.WriteLine("Tiada padanan"+chemicals.Count);
                }
                e.Handled = true;
                _searchView.ClearFocus();
            };

            MenuItemCompat.SetOnActionExpandListener(item, new SearchViewExpandListener(_adapter));

            return true;
        }
            protected override void OnPostExecute(Java.Lang.Object result)
            {
                base.OnPostExecute(result);

                if (searchView != null)
                {
                    searchView.ClearFocus();
                }
                p.Dismiss();
                if (result != null && weClipdata != null)
                {
                    var adapter = new WeClipSearchAdapter(activity, weClipdata);

                    if (weClipdata.Count > 0)
                    {
                        gvWeClip.Adapter = adapter;
                    }
                    else
                    {
                        gvWeClip.Adapter     = adapter;
                        emptyText.Visibility = ViewStates.Visible;
                    }
                }
            }
Пример #13
0
        private void SearchBoxOnQueryTextSubmit(object sender, SearchView.QueryTextSubmitEventArgs e)
        {
            try
            {
                SearchBox.ClearFocus();
                SongsTab.MAdapter.SoundsList.Clear();
                SongsTab.MAdapter.NotifyDataSetChanged();

                AlbumsTab.MAdapter.AlbumsList.Clear();
                AlbumsTab.MAdapter.NotifyDataSetChanged();

                PlaylistTab.MAdapter.PlaylistList.Clear();
                PlaylistTab.MAdapter.NotifyDataSetChanged();

                ArtistsTab.MAdapter.UsersList.Clear();
                ArtistsTab.MAdapter.NotifyDataSetChanged();

                OffsetSongs    = "0";
                OffsetAlbums   = "0";
                OffsetPlaylist = "0";
                OffsetArtists  = "0";

                if (Methods.CheckConnectivity())
                {
                    if (SongsTab.MAdapter.SoundsList.Count > 0)
                    {
                        SongsTab.MAdapter.SoundsList.Clear();
                        SongsTab.MAdapter.NotifyDataSetChanged();
                    }

                    if (AlbumsTab.MAdapter.AlbumsList.Count > 0)
                    {
                        AlbumsTab.MAdapter.AlbumsList.Clear();
                        AlbumsTab.MAdapter.NotifyDataSetChanged();
                    }

                    SongsTab.ProgressBarLoader.Visibility = ViewStates.Visible;
                    SongsTab.EmptyStateLayout.Visibility  = ViewStates.Gone;
                    StartApiService();
                }
                else
                {
                    if (SongsTab.Inflated == null)
                    {
                        SongsTab.Inflated = SongsTab.EmptyStateLayout.Inflate();
                    }

                    EmptyStateInflater x = new EmptyStateInflater();
                    x.InflateLayout(SongsTab.Inflated, EmptyStateInflater.Type.NoConnection);
                    if (x.EmptyStateButton.HasOnClickListeners)
                    {
                        x.EmptyStateButton.Click -= EmptyStateButtonOnClick;
                        x.EmptyStateButton.Click -= TryAgainButton_Click;
                    }

                    x.EmptyStateButton.Click += TryAgainButton_Click;
                    SongsTab.ProgressBarLoader.Visibility = ViewStates.Gone;
                    SongsTab.EmptyStateLayout.Visibility  = ViewStates.Visible;
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
Пример #14
0
        public override bool OnCreateOptionsMenu(IMenu menu)
        {
            MenuInflater.Inflate(Resource.Menu.toolmenu, menu);
            var item       = menu.FindItem(Resource.Id.menu_search);
            var searchItem = MenuItemCompat.GetActionView(item);

            torSearchView = searchItem.JavaCast <Android.Support.V7.Widget.SearchView>();
            torSearchView.SetIconifiedByDefault(false);
            torSearchView.QueryHint = "Torrent Search...";
            //torSearchView.SubmitButtonEnabled = true;
            var simgid         = torSearchView.Context.Resources.GetIdentifier("search_mag_icon", "id", PackageName);
            var id             = torSearchView.Context.Resources.GetIdentifier("search_src_text", "id", PackageName);
            var searchEditText = torSearchView.FindViewById <EditText>(id);
            var searchIcon     = torSearchView.FindViewById <ImageView>(simgid);

            searchIcon.SetColorFilter(Android.Graphics.Color.White);
            searchEditText.SetTextColor(Android.Graphics.Color.White);
            searchEditText.SetHintTextColor(Android.Graphics.Color.White);



            torSearchView.QueryTextSubmit += (s, e) =>
            {
                if (IsConnected == true)
                {
                    string query = e.NewText.ToString();
                    rlStatusLayout.Visibility = ViewStates.Gone;
                    listView.Visibility       = ViewStates.Gone;
                    System.Threading.Thread thread = new System.Threading.Thread(() =>
                    {
                        UserDialogs.Instance.ShowLoading("Searching, Please Wait …", MaskType.Black);
                        torrents = Tpb.Search(new TpbQuery(query, 0, searchOrder, searchCategory));
                        if (torrents.Count == 0)
                        {
                            RunOnUiThread(() => Toast.MakeText(this, "No results found for " + query, ToastLength.Short).Show());
                        }
                        else
                        {
                            //listViewAnimShow.Duration = 200;
                            rlStatusLayout.StartAnimation(statusAnimShow);
                            listView.StartAnimation(listViewAnimShow);
                            RunOnUiThread(() => rlStatusLayout.Visibility = ViewStates.Visible);
                            RunOnUiThread(() => listView.Visibility       = ViewStates.Visible);
                            RunOnUiThread(() => listView.Adapter          = new TorListAdapter(this, torrents));
                        };

                        UserDialogs.Instance.HideLoading();
                    });;
                    thread.Start();
                    torSearchView.ClearFocus();

                    //torSearchView.SetQuery("", false);
                    //MenuItemCompat.CollapseActionView(item);
                    tvStatusText.Text = "Search results for: " + e.NewText.ToString();
                    //tvStatusText.Text = MaterialIcons.md_dis;
                    layoutWelcome.Visibility = ViewStates.Gone;

                    e.Handled = true;
                }
                else
                {
                    torSearchView.ClearFocus();
                    Toast.MakeText(this, "No internet connection detected!", ToastLength.Long).Show();
                };
            };
            //return true;
            return(base.OnCreateOptionsMenu(menu));
        }