public override void TouchesBegan(NSSet touches, UIEvent evt) //when table is still scrolling, only TouchesBegan is called, thus row will remain highlighted. { base.TouchesBegan(touches, evt); var location = LocationInView(table); var indexPath = table.IndexPathForRowAtPoint(location); startX = location.X; startY = location.Y; if (indexPath != null && !ChatListActivity.chatListScrolling) { selectedCell = (ChatUserListCell)table.CellAt(indexPath); startTimer = new Timer(); startTimer.Interval = timerMs; startTimer.Elapsed += StartTimer_Elapsed; startTimer.Start(); } else { selectedCell = null; } }
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath) { ChatUserListCell cell = (ChatUserListCell)tableView.DequeueReusableCell("ChatUserListCell"); MatchItem item = items[indexPath.Row]; cell.SeparatorInset = new UIEdgeInsets(0, 0, 0, 0); if ((bool)item.Active) { cell.ContentView.BackgroundColor = UIColor.FromName("ChatTarget"); cell.activeCell = true; } else { cell.ContentView.BackgroundColor = UIColor.FromName("ChatPassive"); cell.activeCell = false; } UIImageView imageView = cell.ChatUserListImage; ImageCache im = new ImageCache(this); im.LoadImage(imageView, item.TargetID.ToString(), item.TargetPicture); cell.ChatUserListName.Text = item.TargetName; foreach (UILabel label in cell.ChatUserListItems.Subviews) { label.Text = ""; } int j = 0; for (int i = item.Chat.Length - 1; i >= 0; i--) { string messageItem = item.Chat[i]; int sep1Pos = messageItem.IndexOf('|'); int sep2Pos = messageItem.IndexOf('|', sep1Pos + 1); int sep3Pos = messageItem.IndexOf('|', sep2Pos + 1); int sep4Pos = messageItem.IndexOf('|', sep3Pos + 1); int sep5Pos = messageItem.IndexOf('|', sep4Pos + 1); int senderID = int.Parse(messageItem.Substring(sep1Pos + 1, sep2Pos - sep1Pos - 1)); long readTime = long.Parse(messageItem.Substring(sep4Pos + 1, sep5Pos - sep4Pos - 1)); string message = messageItem.Substring(sep5Pos + 1); UILabel label = (UILabel)cell.ChatUserListItems.Subviews[j]; label.Text = message.Replace(Environment.NewLine, " "); j++; label.TextColor = UIColor.FromName("PrimaryDark"); if (senderID != Session.ID) { label.Font = UIFont.BoldSystemFontOfSize(14); if (readTime == 0) { label.BackgroundColor = UIColor.FromName("ChatHighlight"); } else { label.BackgroundColor = UIColor.FromRGBA(0, 0, 0, 0); //label may remain blue after list reload } } else { label.Font = UIFont.SystemFontOfSize(14); label.BackgroundColor = UIColor.FromRGBA(0, 0, 0, 0); } } return(cell); }