public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath) { var cell = (CustomCellJobListing)tableView.DequeueReusableCell(CustomCellJobListing.Key); if (cell != null) { cell = null; } if (cell == null) { cell = CustomCellJobListing.Create(); } JobCMS aJob = jobList[indexPath.Row]; cell.UpdateCell(aJob); JobCMS tempJob = DbHelper.GetFavoriteJobs().Where(x => x.JobId == aJob.JobId).SingleOrDefault <JobCMS>(); if (tempJob == null) { aJob.isFavorote = false; } else { aJob.isFavorote = true; } foreach (UIView view in cell.ContentView.Subviews) { if (view is UIButton) { UIButton btnFav = (UIButton)view; btnFav.TouchUpInside += FavoriteButtonPressed; btnFav.Tag = (int)indexPath.Row; if (aJob.isFavorote) { btnFav.SetImage(UIImage.FromFile("heart-icon-selected.png"), UIControlState.Normal); } else { btnFav.SetImage(UIImage.FromFile("fav-icon.png"), UIControlState.Normal); } } } return(cell); }
void FavoriteButtonPressed(object sender, EventArgs ea) { UIButton btnFav = (UIButton)sender; JobCMS aJob = jobList[(int)btnFav.Tag]; bool isFavorote = !aJob.isFavorote; if (isFavorote) { btnFav.SetImage(UIImage.FromFile("heart-icon-selected.png"), UIControlState.Normal); DbHelper.AddFavoriteJob(aJob); } else { btnFav.SetImage(UIImage.FromFile("fav-icon.png"), UIControlState.Normal); DbHelper.DeleteFavoriteJob(aJob); } aJob.isFavorote = isFavorote; ((UITableView)btnFav.Superview.Superview.Superview.Superview).ReloadData(); _introViewCtrl.FavoriteButtonWithCount(_introViewCtrl.NavigationItem); }
public override void RowSelected(UITableView tableView, NSIndexPath indexPath) { JobCMS aJob = jobList[indexPath.Row]; AppDelegate appDelegate = (AppDelegate)UIApplication.SharedApplication.Delegate; UIStoryboard storyboard = UIStoryboard.FromName(appDelegate.storyboard, null); var jobDetailVC = (JobDetailVC)storyboard.InstantiateViewController("JobDetailVC"); jobDetailVC.JobId = aJob.JobId; jobDetailVC.jobTitle = aJob.JobTitle; jobDetailVC.postingDate = aJob.PostedDate; jobDetailVC.salary = aJob.Salary; jobDetailVC.jobCategory = aJob.JobCategoryTitle; jobDetailVC.aJob = aJob; jobDetailVC.contractType = aJob.ContractTypeTitle; jobDetailVC.loaction = aJob.JobLocation; jobDetailVC.isNew = aJob.isExpiredorNew; searchResultVC.NavigationController.PushViewController(jobDetailVC, true); tableView.DeselectRow(indexPath, true); }
//Dictionary<string, List<string>> public async System.Threading.Tasks.Task <Dictionary <string, dynamic> > AsyncJobSearch(JobRequest jobRequest) { var responseDict = new Dictionary <string, dynamic>(); List <JobCMS> jobList = new List <JobCMS>(); var baseAddress = new Uri(Constants.JobBaseAddress); var values = new Dictionary <string, string>(); values.Add("filterUrl", jobRequest.FilterURL); values.Add("sfr", Constants.JobDetailSiteName); //Adecco USA values.Add("facetSettingId", "{D4739C3F-3DAB-49DE-9C6E-7215979C15BF}"); values.Add("facetSettingId", Constants.JobSearchFacetSettingID); values.Add("currentLanguage", Constants.JobDetailCurrentLanguage); values.Add("IsJobPage", "1"); values.Add("clientId", ""); values.Add("clientName", ""); values.Add("branchId", ""); var content = new FormUrlEncodedContent(values); var cookieContainer = new CookieContainer(); CFNetworkHandler networkHandler = new CFNetworkHandler(); networkHandler.UseSystemProxy = true; networkHandler.CookieContainer = cookieContainer; HttpClientHandler handler = new HttpClientHandler() { AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate, CookieContainer = cookieContainer }; //using (var handler = new HttpClientHandler() { CookieContainer = cookieContainer }) using (var client = new HttpClient(handler)) { try { cookieContainer.Add(baseAddress, new Cookie("sitenameForRegister", Constants.JobDetailSiteName)); //Adecco USA cookieContainer.Add(baseAddress, new Cookie("ASP.NET_SessionId", "wejofxxqheshv4gzya35sakr")); cookieContainer.Add(baseAddress, new Cookie("ASP.NET_SessionId", "01pypyigge22sem4bd5mmjba")); cookieContainer.Add(baseAddress, new Cookie("Locale", Constants.JobDetailCurrentLanguage)); //ja-JP cookieContainer.Add(baseAddress, new Cookie("userstatus", "candidate")); cookieContainer.Add(baseAddress, new Cookie("IsJobPage", "1")); var httpResponse = await client.PostAsync(Constants.JobSearchURL, content); if (httpResponse.StatusCode == HttpStatusCode.OK) { string responseContent = await httpResponse.Content.ReadAsStringAsync(); dynamic responseObj = Newtonsoft.Json.JsonConvert.DeserializeObject(responseContent); //if(responseObj == null) // return null; dynamic jobitems = responseObj["Items"]; dynamic jobsCount = responseObj["Count"]; dynamic TotalCount = responseObj["TotalCount"]; Constants.TotalJobCount = TotalCount.ToObject <string>(); Constants.JobCount = jobsCount.ToObject <string>(); Constants.JobCount = Constants.JobCount.Replace("xx", Constants.TotalJobCount); JobCMS job = null; jobList = new List <JobCMS>(); foreach (JObject jcontent in jobitems.Children <JObject>()) { job = new JobCMS(); job = jcontent.ToObject <JobCMS>(); if (Constants.JobDetailSiteName.Equals("adecco.fr")) { job.ContractTypeTitle = job.EmploymentTypeTitle; } jobList.Add(job); } responseDict.Add("jobList", jobList); dynamic presentationFacetResults = responseObj["PresentationFacetResults"]; List <PresentationFacetResult> presentationFacetResultList = new List <PresentationFacetResult>(); PresentationFacetResult _presentationFacetResult = new PresentationFacetResult(); foreach (JObject jcontent in presentationFacetResults.Children <JObject>()) { //presentationFacetResult.ListFacetValues = new List<FacetValue>(); _presentationFacetResult = jcontent.ToObject <PresentationFacetResult>(); presentationFacetResultList.Add(_presentationFacetResult); } //Console.WriteLine("ListPresentationFacetResult =={0}", presentationFacetResultList); responseDict.Add("presentationFacetResultList", presentationFacetResultList); dynamic _SelectedFacets = responseObj["SelectedFacets"]; List <SelectedFacets> selectedFacetsList = new List <SelectedFacets>(); SelectedFacets aSelectedFacets = new SelectedFacets(); foreach (JObject jcontent in _SelectedFacets.Children <JObject>()) { aSelectedFacets = jcontent.ToObject <SelectedFacets>(); selectedFacetsList.Add(aSelectedFacets); } Console.WriteLine("selectedFacetsList =={0}", selectedFacetsList); responseDict.Add("selectedFacetsList", selectedFacetsList); return(responseDict); } return(responseDict); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } } return(responseDict); }
public void UpdateCell(JobCMS aJob) { this.titleLabel.Text = aJob.JobTitle; this.LocationLabel.Text = aJob.JobLocation; //this.datePostedLabel.Hidden = true; if (!string.IsNullOrEmpty(aJob.Salary) && !(aJob.Salary.Equals("NoContent"))) { this.ContractType.Text = aJob.Salary; this.ContractTypeImgView.Image = UIImage.FromBundle("eurosymbol.png"); // } else if (!string.IsNullOrEmpty(aJob.ContractTypeTitle) && !(aJob.ContractTypeTitle.Equals("NoContent"))) { this.ContractType.Text = aJob.ContractTypeTitle; this.ContractTypeImgView.Image = UIImage.FromBundle("calender-icon.png"); } else { this.ContractType.Text = "N/A"; this.ContractTypeImgView.Image = UIImage.FromBundle("calender-icon.png"); //this.expLable.Hidden = true; //this.expImgView.Hidden = tr } if (!string.IsNullOrEmpty(aJob.JobCategoryTitle) && !(aJob.JobCategoryTitle.Equals("NoContent"))) { this.CategoryLabel.Text = aJob.JobCategoryTitle; this.CategoryImageView.Image = UIImage.FromBundle("Truck.png"); } else { this.CategoryLabel.Text = "N/A"; this.CategoryImageView.Image = UIImage.FromBundle("Truck.png"); //this.expLable.Hidden = true; //this.expImgView.Hidden = tr } if (!string.IsNullOrEmpty(aJob.isExpiredorNew)) { this.lblNew.Hidden = false; this.lblNew.Layer.CornerRadius = 5.0f; } else { this.lblNew.Hidden = true; } //btnFavJob.Hidden = true; // iPhone 5 customization AppDelegate appDelegate = (AppDelegate)UIApplication.SharedApplication.Delegate; if (appDelegate.Window.Frame.Size.Width == 320 && appDelegate.Window.Frame.Size.Height == 568) { this.titleLabel.Frame = new CGRect(5, 5, 270, 25); this.btnFavJob.Frame = new CGRect(275, 5, 40, 40); this.datePostedLabel.Frame = new CGRect(220, 60, 95, 20); } else if (appDelegate.Window.Frame.Size.Width == 414) { // iPhone 6+ this.titleLabel.Frame = new CGRect(5, 5, 350, 25); this.btnFavJob.Frame = new CGRect(360, 5, 40, 40); this.datePostedLabel.Frame = new CGRect(300, 60, 95, 20); } string endDate = ""; if (!string.IsNullOrEmpty(aJob.PostedDate)) { string[] tokens = aJob.PostedDate.Split(new[] { " " }, StringSplitOptions.None); endDate = tokens[0]; } else if (!string.IsNullOrEmpty(aJob.PostingEndDate)) { string[] tokens = aJob.PostingEndDate.Split(new[] { " " }, StringSplitOptions.None); endDate = tokens[0]; } NSDateFormatter dateFormat = new NSDateFormatter(); dateFormat.DateFormat = "MM/dd/yyyy"; NSDate date = dateFormat.Parse(endDate); DateTime dt = ConvertNsDateToDateTime(date); endDate = calculateJobPostedDate(dt); if (!string.IsNullOrEmpty(endDate) && !(endDate.Equals("NoContent"))) { this.datePostedLabel.Text = endDate; } else { this.datePostedLabel.Hidden = true; } if (Constants.JobDetailSiteName.Equals("adecco.fr")) { this.datePostedLabel.Frame = new CGRect(273, 60, 85, 20); this.CategoryLabel.Hidden = true; this.CategoryImageView.Hidden = true; } }
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath) { if (isRecentSearch) { var cell = (RecentSearchesCell)tableView.DequeueReusableCell(RecentSearchesCell.Key); if (cell == null) { cell = RecentSearchesCell.Create(); } int index = _recentSearchs.Count - 1 - indexPath.Row; cell.UpdateCell(_recentSearchs[index]); UITapGestureRecognizer tapRecognizer = new UITapGestureRecognizer(); tapRecognizer.NumberOfTapsRequired = 1; cell.ContentView.AddGestureRecognizer(tapRecognizer); tapRecognizer.AddTarget(() => { this.DidSelectRow(tableView, indexPath.Row); }); return(cell); } else { var cell = (CustomCellJobListing)tableView.DequeueReusableCell(CustomCellJobListing.Key); if (cell != null) { cell = null; } if (cell == null) { cell = CustomCellJobListing.Create(); } JobCMS aJob = jobList[indexPath.Row]; JobCMS tempJob = DbHelper.GetFavoriteJobs().Where(x => x.JobId == aJob.JobId).SingleOrDefault <JobCMS>(); if (tempJob == null) { aJob.isFavorote = false; } else { aJob.isFavorote = true; } cell.UpdateCell(aJob); foreach (UIView view in cell.ContentView.Subviews) { if (view is UIButton) { UIButton btnFav = (UIButton)view; btnFav.TouchUpInside += FavoriteButtonPressed; btnFav.Tag = (int)indexPath.Row; if (aJob.isFavorote) { btnFav.SetImage(UIImage.FromFile("heart-icon-selected.png"), UIControlState.Normal); } else { btnFav.SetImage(UIImage.FromFile("fav-icon.png"), UIControlState.Normal); } } } UITapGestureRecognizer tapRecognizer = new UITapGestureRecognizer(); tapRecognizer.NumberOfTapsRequired = 1; cell.ContentView.AddGestureRecognizer(tapRecognizer); tapRecognizer.AddTarget(() => { this.DidSelectRow(tableView, indexPath.Row); }); return(cell); } }
public override void RowSelected(UITableView tableView, NSIndexPath indexPath) { if (isRecentSearch) { int index = _recentSearchs.Count - 1 - indexPath.Row; RecentSearch aRecentSearch = _recentSearchs[index]; string keyword = aRecentSearch.Keyword; string location = aRecentSearch.Location; if (keyword.Equals("N/A")) { keyword = ""; } if (location.Equals("N/A")) { location = ""; } if (!string.IsNullOrEmpty(aRecentSearch.LocationLatLong)) { Constants.LocationLatLong = aRecentSearch.LocationLatLong; } _introViewCtrl.searchJobButtonPressed = true; _introViewCtrl.txtKeyword.Text = keyword; _introViewCtrl.txtLocation.Text = location; _introViewCtrl.GetJobSearchData(keyword, location); } else { string keyword = _introViewCtrl.txtKeyword.Text.Trim(); string location = _introViewCtrl.txtLocation.Text.Trim(); if (keyword.Equals("N/A")) { keyword = ""; } if (location.Equals("N/A")) { location = ""; } Constants.JobKeyword = keyword; Constants.JobLocation = location; JobCMS aJob = jobList[indexPath.Row]; AppDelegate appDelegate = (AppDelegate)UIApplication.SharedApplication.Delegate; UIStoryboard storyboard = UIStoryboard.FromName(appDelegate.storyboard, null); var jobDetailVC = (JobDetailVC)storyboard.InstantiateViewController("JobDetailVC"); jobDetailVC.JobId = aJob.JobId; jobDetailVC.jobTitle = aJob.JobTitle; jobDetailVC.postingDate = aJob.PostedDate; jobDetailVC.salary = aJob.Salary; jobDetailVC.jobCategory = aJob.JobCategoryTitle; jobDetailVC.aJob = aJob; jobDetailVC.loaction = aJob.JobLocation; jobDetailVC.isNew = aJob.isExpiredorNew; _introViewCtrl.NavController.PushViewController(jobDetailVC, true); } tableView.DeselectRow(indexPath, true); }
void FavoriteButtonPressed(object sender, EventArgs ea) { UIButton btnFav = (UIButton)sender; JobCMS aJob = jobList[(int)btnFav.Tag]; // Console.WriteLine("FavoriteButtonPressed tag =={0}", (int)btnFav.Tag); //Console.WriteLine("FavoriteButtonPressed =={0}", aJob); bool isFavorote = !aJob.isFavorote; if (isFavorote) { btnFav.SetImage(UIImage.FromFile("heart-icon-selected.png"), UIControlState.Normal); DbHelper.AddFavoriteJob(aJob); } else { btnFav.SetImage(UIImage.FromFile("fav-icon.png"), UIControlState.Normal); DbHelper.DeleteFavoriteJob(aJob); } aJob.isFavorote = isFavorote; UITableView tableView = (UITableView)btnFav.Superview.Superview.Superview.Superview; if (isFavoriteJob && !isFavorote) { try { // IF we are coming from Fav job then delete the record from list NSIndexPath indexPath = NSIndexPath.FromRowSection((int)btnFav.Tag, 0); if (jobList.Count > (int)btnFav.Tag) { // remove the item from the underlying data source jobList.RemoveAt((int)btnFav.Tag); // delete the row from the table tableView.DeleteRows(new NSIndexPath[] { indexPath }, UITableViewRowAnimation.Right); } } catch (Exception ex) { string str = ex.Message; Console.WriteLine("== This is the main entry point of the application. Main.cs Exception=== {0}", str); } } // manage fav button count searchResultVC.FavoriteButtonWithCount(searchResultVC.NavigationItem); //Now simply reload tableview //tableView.ReloadData(); // Invoke our method in 2 seconds //PerformSelector(new MonoTouch.ObjCRuntime.Selector("ReloadTableData:"), tableView, 2); tableView.ReloadData(); if (jobList.Count < 1) { BTProgressHUD.ShowToast("No record found.", false, 3000); } }