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); }
public override void RowSelected(UITableView tableView, Foundation.NSIndexPath indexPath) { var feedResultsVC = new SearchResultsViewController(); var search = savedSearches[indexPath.Row]; QueryGeneration helper = new QueryGeneration(); var query = helper.Generate(savedSearches[indexPath.Row]); Console.WriteLine(query); feedResultsVC.Query = query; feedResultsVC.MaxListings = search.MaxListings; feedResultsVC.WeeksOld = search.PostedDate; owner.ShowViewController(feedResultsVC, owner); }
void SearchButton_Clicked(object sender, EventArgs e) { QueryGeneration queryHelper = new QueryGeneration(); var feedViewController = new SearchResultsViewController(); 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 query = queryHelper.Generate(searchObject); feedViewController.Query = query; feedViewController.MaxListings = MaxListings; feedViewController.WeeksOld = WeeksOld; this.ShowViewController(feedViewController, this); }
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(); }