Esempio n. 1
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = new ListView(this.Activity);

            this.DeserializingComplete += delegate
            {
                view.Adapter          = adapter = new SavedSearchesAdapter(this.Activity, deserialized);
                deserialized          = null;
                DeserializingComplete = null;
            };

            view.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) =>
            {
                QueryGeneration queryHelper = new QueryGeneration();

                var transaction = Activity.SupportFragmentManager.BeginTransaction();
                SearchResultsFragment resultsFragment = new SearchResultsFragment();
                resultsFragment.Query       = queryHelper.Generate(adapter._searches[e.Position]);
                resultsFragment.MaxListings = adapter._searches[e.Position].MaxListings;
                resultsFragment.WeeksOld    = adapter._searches[e.Position].PostedDate;

                transaction.Replace(Resource.Id.frameLayout, resultsFragment);
                transaction.AddToBackStack(null);
                transaction.Commit();
            };

            view.ItemLongClick += (sender, e) =>
            {
                PopupMenu menu = new PopupMenu(this.Activity, view.GetChildAt(e.Position));
                menu.Inflate(Resource.Menu.DeleteMenu);
                menu.Show();

                menu.MenuItemClick += (se, args) =>
                {
                    var result = MainActivity.databaseConnection.DeleteSearchAsync(adapter._searches[e.Position].SearchLocation.Url, adapter._searches[e.Position]).Result;
                    if (MainActivity.databaseConnection.StatusCode == codes.ok && result)
                    {
                        lock (adapter._searches)
                        {
                            Activity.RunOnUiThread(() =>
                            {
                                adapter._searches.RemoveAt(e.Position);
                            });

                            adapter.NotifyDataSetChanged();
                        }
                    }
                    else
                    {
                    }
                    Console.WriteLine(MainActivity.databaseConnection.StatusMessage);
                };
            };

            return(view);
        }
Esempio n. 2
0
        void ProceedButton_Click(object sender, EventArgs e)
        {
            QueryGeneration queryHelper = new QueryGeneration();

            SearchObject searchObject = new SearchObject();

            searchObject.SearchLocation = location;
            searchObject.Category       = SubCategory.Value != null ? new KeyValuePair <object, object>(SubCategory.Value, SubCategory.Key) : new KeyValuePair <object, object>(category.Key, category.Value);
            searchObject.SearchItems    = this.SearchItems;
            searchObject.Conditions     = this.Conditions;

            var transaction = ((AppCompatActivity)context).SupportFragmentManager.BeginTransaction();
            SearchResultsFragment resultsFragment = new SearchResultsFragment();

            resultsFragment.Query       = queryHelper.Generate(searchObject);
            resultsFragment.MaxListings = MaxListings;
            resultsFragment.WeeksOld    = WeeksOld;

            ((MainActivity)(this.context)).OptionItemSelected -= OnOptionItemSelected;

            transaction.Replace(Resource.Id.frameLayout, resultsFragment);
            transaction.AddToBackStack(null);
            transaction.Commit();
        }
        void ProceedButton_Click(object sender, EventArgs e)
        {
            QueryGeneration queryHelper = new QueryGeneration();

            SearchObject searchObject = new SearchObject();
            searchObject.SearchLocation = location;
            searchObject.Category = SubCategory.Value != null ? new KeyValuePair<object, object>(SubCategory.Value, SubCategory.Key) : new KeyValuePair<object, object>(category.Key, category.Value);
            searchObject.SearchItems = this.SearchItems;
            searchObject.Conditions = this.Conditions;

            var transaction = ((AppCompatActivity)context).SupportFragmentManager.BeginTransaction();
            SearchResultsFragment resultsFragment = new SearchResultsFragment();
            resultsFragment.Query = queryHelper.Generate(searchObject);
            resultsFragment.MaxListings = MaxListings;
            resultsFragment.WeeksOld = WeeksOld;

            ((MainActivity)(this.context)).OptionItemSelected -= OnOptionItemSelected;

            transaction.Replace(Resource.Id.frameLayout, resultsFragment);
            transaction.AddToBackStack(null);
            transaction.Commit();
        }