Skip to content

Commit b839446

Browse files
authored
Merge pull request #69 from ricknout/feature/nominally-away-teams
Support second team in World Rugby match being the home team
2 parents 84370fc + 4f1471c commit b839446

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

Diff for: app/src/main/java/com/ricknout/rugbyranker/ui/SportFragment.kt

+11-10
Original file line numberDiff line numberDiff line change
@@ -480,23 +480,24 @@ class SportFragment : DaggerAndroidXFragment(R.layout.fragment_sport) {
480480
}
481481

482482
private fun applyWorldRugbyMatchToInput(worldRugbyMatch: WorldRugbyMatch) {
483-
homeTeamId = worldRugbyMatch.firstTeamId
484-
homeTeamName = worldRugbyMatch.firstTeamName
485-
homeTeamAbbreviation = worldRugbyMatch.firstTeamAbbreviation!!
483+
val switched = worldRugbyMatch.secondTeamName == worldRugbyMatch.venueName
484+
homeTeamId = if (!switched) worldRugbyMatch.firstTeamId else worldRugbyMatch.secondTeamId
485+
homeTeamName = if (!switched) worldRugbyMatch.firstTeamName else worldRugbyMatch.secondTeamName
486+
homeTeamAbbreviation = if (!switched) worldRugbyMatch.firstTeamAbbreviation!! else worldRugbyMatch.secondTeamAbbreviation!!
486487
val homeTeam = EmojiCompat.get().process(getString(R.string.menu_item_team,
487-
FlagUtils.getFlagEmojiForTeamAbbreviation(worldRugbyMatch.firstTeamAbbreviation!!), homeTeamName))
488+
FlagUtils.getFlagEmojiForTeamAbbreviation(homeTeamAbbreviation!!), homeTeamName))
488489
matchPredictionInputView.homeTeamText = homeTeam
489-
awayTeamId = worldRugbyMatch.secondTeamId
490-
awayTeamName = worldRugbyMatch.secondTeamName
491-
awayTeamAbbreviation = worldRugbyMatch.secondTeamAbbreviation!!
490+
awayTeamId = if (!switched) worldRugbyMatch.secondTeamId else worldRugbyMatch.firstTeamId
491+
awayTeamName = if (!switched) worldRugbyMatch.secondTeamName else worldRugbyMatch.firstTeamName
492+
awayTeamAbbreviation = if (!switched) worldRugbyMatch.secondTeamAbbreviation!! else worldRugbyMatch.firstTeamAbbreviation!!
492493
val awayTeam = EmojiCompat.get().process(getString(R.string.menu_item_team,
493-
FlagUtils.getFlagEmojiForTeamAbbreviation(worldRugbyMatch.secondTeamAbbreviation!!), awayTeamName))
494+
FlagUtils.getFlagEmojiForTeamAbbreviation(awayTeamAbbreviation!!), awayTeamName))
494495
matchPredictionInputView.awayTeamText = awayTeam
495496
when (worldRugbyMatch.status) {
496497
MatchStatus.UNPLAYED -> matchPredictionInputView.clearMatchPredictionPointsInput()
497498
else -> {
498-
matchPredictionInputView.homePointsText = worldRugbyMatch.firstTeamScore
499-
matchPredictionInputView.awayPointsText = worldRugbyMatch.secondTeamScore
499+
matchPredictionInputView.homePointsText = if (!switched) worldRugbyMatch.firstTeamScore else worldRugbyMatch.secondTeamScore
500+
matchPredictionInputView.awayPointsText = if (!switched) worldRugbyMatch.secondTeamScore else worldRugbyMatch.firstTeamScore
500501
}
501502
}
502503
matchPredictionInputView.nhaChecked = worldRugbyMatch.venueCountry?.let { venueCountry ->

0 commit comments

Comments
 (0)