public void InitProperties() { var matches = AppDelegate.SharedAppDelegate.UoW.MatchRepo.GetActualMatches(AppDelegate.SharedAppDelegate.UoW.LeagueRepo.GetAllLeague()); SoonMatches = matches.Where(m => m.State != StateEnum.Playing).OrderBy(m => m.LeagueId); if (SoonMatches.Count() == 0) { HasSoonMatch = false; } else { HasSoonMatch = true; SoonTeams = AppDelegate.SharedAppDelegate.UoW.TeamRepo.GetTeamsByMatches(SoonMatches); SoonIndexes = CreateIndexes(SoonMatches); } LiveMatches = matches.Where(m => m.State == StateEnum.Playing).OrderBy(m => m.LeagueId); if (LiveMatches.Count() == 0) { HasLiveMatch = false; } else { HasLiveMatch = true; LiveTeams = AppDelegate.SharedAppDelegate.UoW.TeamRepo.GetTeamsByMatches(LiveMatches); LiveIndexes = CreateIndexes(LiveMatches); } }
public override nint RowsInSection(UITableView tableView, nint section) { if (section == 0) { if (!HasLiveMatch) { return(1); } return(LiveMatches.Count() + LiveMatches.DistinctBy(m => m.LeagueId).Count()); } if (!HasSoonMatch) { return(1); } return(SoonMatches.Count() + SoonMatches.DistinctBy(m => m.LeagueId).Count()); }
public override void PrepareForSegue(UIStoryboardSegue segue, Foundation.NSObject sender) { switch (segue.Identifier) { case "MatchFromActual": var vc = segue.DestinationViewController as MatchViewController; if (TableView.IndexPathForSelectedRow.Section == 0) { vc.Match = LiveMatches.ElementAt(TableView.IndexPathForSelectedRow.Row - LiveIndexes.Where(i => i < TableView.IndexPathForSelectedRow.Row).Count()); } else { vc.Match = SoonMatches.ElementAt(TableView.IndexPathForSelectedRow.Row - SoonIndexes.Where(i => i < TableView.IndexPathForSelectedRow.Row).Count()); } break; default: break; } }
public override UITableViewCell GetCell(UITableView tableView, Foundation.NSIndexPath indexPath) { if ((indexPath.Section == 0 && !HasLiveMatch) || (indexPath.Section == 1 && !HasSoonMatch)) { var cell = tableView.DequeueReusableCell("NoMatchCell"); cell.BackgroundColor = UIColor.Clear.FromHex(LightGreen.hex); return(cell); } Match match; Team homeTeam; Team awayTeam; if (indexPath.Section == 0) { if (LiveIndexes.Contains(indexPath.Row)) { return(CreateLeagueNameCell(tableView, indexPath, LiveIndexes)); } else { LiveMatchCell cell = tableView.DequeueReusableCell("LiveMatchCell", indexPath) as LiveMatchCell; cell.BackgroundColor = UIColor.Clear.FromHex(LightGreen.hex); var color = cell.ViewWithTag(500).BackgroundColor; //cell.ViewWithTag(500).BackgroundColor = cell.ViewWithTag(500).BackgroundColor.ColorWithAlpha((float)0.5);r match = LiveMatches.ElementAt(indexPath.Row - LiveIndexes.Where(i => i < indexPath.Row).Count()); homeTeam = LiveTeams.First(t => t.Id == match.HomeTeamId); awayTeam = LiveTeams.First(t => t.Id == match.AwayTeamId); if (match.State == StateEnum.Playing) { AnimateView(cell.ViewWithTag(800), true); } return(CreateActualTile(cell, match, homeTeam, awayTeam)); } } else { if (SoonIndexes.Contains(indexPath.Row)) { return(CreateLeagueNameCell(tableView, indexPath, SoonIndexes)); } else { LiveMatchCell cell = tableView.DequeueReusableCell("LiveMatchCell", indexPath) as LiveMatchCell; cell.BackgroundColor = UIColor.Clear.FromHex(LightGreen.hex); match = SoonMatches.ElementAt(indexPath.Row - SoonIndexes.Where(i => i < indexPath.Row).Count()); homeTeam = SoonTeams.First(t => t.Id == match.HomeTeamId); awayTeam = SoonTeams.First(t => t.Id == match.AwayTeamId); return(CreateActualTile(cell, match, homeTeam, awayTeam)); } } }