public override void ViewDidLoad() { base.ViewDidLoad(); TableView.RegisterNibForCellReuse(UINib.FromName("TextPostTableViewCell", NSBundle.MainBundle), TextPostTableViewCell.Identifier); TableView.RegisterNibForCellReuse(UINib.FromName("ImagePostTableViewCell", NSBundle.MainBundle), ImagePostTableViewCell.Identifier); TableView.BackgroundView = ViewUtils.GetBackgroundView(Strings.loading_posts, true); TableView.EstimatedRowHeight = UIScreen.MainScreen.Bounds.Size.Width + 200; TableView.DataSource = new PostFeedTableViewSource(this); TableViewDelegate = new BaseTableViewDelegate(this); TableView.Delegate = TableViewDelegate; }
public void BindListeneresToCell (Post post, List<Post> underlyingDataSource, NSIndexPath indexPath, UITableView tableView, BaseTableViewDelegate source) { CellLikeButton.RemoveTarget (null, null, UIControlEvent.TouchUpInside); CellLikeButton.TouchUpInside += async (sender, e) => { bool results = await TenServiceHelper.LikePost (post, CellLikeButton, tableView, indexPath); if (results) { tableView.ReloadRows (new NSIndexPath[] { indexPath }, UITableViewRowAnimation.None); } }; CellRepostedLabel.RemoveTarget (null, null, UIControlEvent.TouchUpInside); CellRepostedLabel.TouchUpInside += (sender, e) => { TenServiceHelper.GoToGuestProfile (post.userReposter); }; CellRepostButton.RemoveTarget (null, null, UIControlEvent.TouchUpInside); CellRepostButton.TouchUpInside += (sender, e) => { if (!post.isReposted) { UIAlertController AlertController = UIAlertController.Create (Strings.repost_confirm, null, UIAlertControllerStyle.Alert); AlertController.AddAction (UIAlertAction.Create (Strings.no, UIAlertActionStyle.Cancel, null)); AlertController.AddAction (UIAlertAction.Create (Strings.yes, UIAlertActionStyle.Default, async delegate { try { bool repostedSuccessfully = await TenServiceHelper.RepostPost (post, CellRepostButton, tableView, indexPath); if(repostedSuccessfully){ await source.Master.FetchTableData(); } } catch (RESTError) { } })); source.Master.Master.PresentViewController (AlertController, true, null); } }; CellClockImage.RemoveTarget (null, null, UIControlEvent.TouchUpInside); CellClockImage.TouchUpInside += (sender, e) => { TenServiceHelper.GoToListOf (FeedTypeEnum.FeedType.LikersListOfFeed, post.idPost); }; CellTimeRemaining.RemoveTarget (null, null, UIControlEvent.TouchUpInside); CellTimeRemaining.TouchUpInside += (sender, e) => { TenServiceHelper.GoToListOf (FeedTypeEnum.FeedType.LikersListOfFeed, post.idPost); }; CellUsernameLabel.RemoveTarget (null, null, UIControlEvent.TouchUpInside); CellUsernameLabel.TouchUpInside += (sender, e) => { TenServiceHelper.GoToGuestProfile (post.userPoster); }; CellUserImageButton.RemoveTarget (null, null, UIControlEvent.TouchUpInside); CellUserImageButton.TouchUpInside += (sender, e) => { TenServiceHelper.GoToGuestProfile (post.userPoster); }; UITapGestureRecognizer tapGesture = new UITapGestureRecognizer (delegate(UITapGestureRecognizer obj) { TenServiceHelper.ParseForMentionOrHash (obj, indexPath, tableView); }); CellCaptionTextView.AddGestureRecognizer (tapGesture); }