@@ -65,22 +65,24 @@ class MatchRepository(
65
65
return try {
66
66
val response = service.getMatches(sports, states, startDate, endDate, sort, page, pageSize)
67
67
val teamIds = dao.loadTeamIds(sport)
68
- val matches = MatchDataConverter .getMatchesFromResponse(response, sport, teamIds).map { match ->
69
- when (match.status) {
70
- Status .LIVE -> {
71
- val summaryResponse = service.getMatchSummary(match.id)
72
- val minute = MatchDataConverter .getMinuteFromResponse(summaryResponse)
73
- match.copy(minute = minute)
68
+ val matches = MatchDataConverter .getMatchesFromResponse(response, sport, teamIds)
69
+ .filter { match -> match.displayable }
70
+ .map { match ->
71
+ when (match.status) {
72
+ Status .LIVE -> {
73
+ val summaryResponse = service.getMatchSummary(match.id)
74
+ val minute = MatchDataConverter .getMinuteFromResponse(summaryResponse)
75
+ match.copy(minute = minute)
76
+ }
77
+ else -> match
78
+ }
79
+ }.run {
80
+ if (sort == WorldRugbyService .SORT_ASC ) {
81
+ sortedBy { match -> match.timeMillis }
82
+ } else {
83
+ sortedByDescending { match -> match.timeMillis }
74
84
}
75
- else -> match
76
- }
77
- }.run {
78
- if (sort == WorldRugbyService .SORT_ASC ) {
79
- sortedBy { match -> match.timeMillis }
80
- } else {
81
- sortedByDescending { match -> match.timeMillis }
82
85
}
83
- }
84
86
true to matches
85
87
} catch (e: Exception ) {
86
88
Log .e(TAG , e.toString())
@@ -96,7 +98,7 @@ class MatchRepository(
96
98
val response = service.getMatchSummary(id)
97
99
val teamIds = dao.loadTeamIds(sport)
98
100
val match = MatchDataConverter .getMatchFromResponse(response, sport, teamIds)
99
- true to match
101
+ match.displayable to match
100
102
} catch (e: Exception ) {
101
103
Log .e(TAG , e.toString())
102
104
false to null
0 commit comments