Пример #1
0
            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);
            }
Пример #2
0
            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);
                }
            }