Skip to content

Commit

Permalink
Hide all entities when we dont have domains to show, show empty messa…
Browse files Browse the repository at this point in the history
…ge just in case (#3767)
  • Loading branch information
dshokouhi authored Aug 7, 2023
1 parent 73bc7b0 commit 6a8fd59
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ fun getDomainList(
)
}
}
listBuilder.setNoItemsMessage(carContext.getString(R.string.no_supported_entities))

return listBuilder
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class DomainListScreen(
}

private val domains = mutableSetOf<String>()
private var domainsAdded = false

override fun onDrivingOptimizedChanged(newState: Boolean) {
invalidate()
Expand All @@ -52,11 +53,11 @@ class DomainListScreen(
.distinct()
.filter { it in SUPPORTED_DOMAINS }
.toSet()
if (newDomains.size != domains.size || newDomains != domains) {
domains.clear()
domains.addAll(newDomains)
invalidate()
}
val invalidate = newDomains.size != domains.size || newDomains != domains || !domainsAdded
domains.clear()
domains.addAll(newDomains)
domainsAdded = true
if (invalidate) invalidate()
}
}
}
Expand All @@ -82,7 +83,7 @@ class DomainListScreen(
setActionStrip(nativeModeActionStrip(carContext))
}
val domainBuild = domainList.build()
if (domainBuild.items.isEmpty()) {
if (!domainsAdded) {
setLoading(true)
} else {
setLoading(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,20 @@ class EntityGridVehicleScreen(
allEntities
).build()
)
listBuilder.addItem(
getDomainsGridItem(
carContext,
screenManager,
serverManager,
integrationRepository,
serverId,
allEntities,
prefsRepository,
entityRegistry
).build()
)
if (domains.isNotEmpty()) {
listBuilder.addItem(
getDomainsGridItem(
carContext,
screenManager,
serverManager,
integrationRepository,
serverId,
allEntities,
prefsRepository,
entityRegistry
).build()
)
}
if (shouldSwitchServers) {
listBuilder.addItem(
getChangeServerGridItem(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class MainVehicleScreen(
) { onChangeServer(it) }.getEntityGridItems(favoritesEntities)
} else {
var builder = ItemList.Builder()
if (domains.isNotEmpty()) {
if (domains.isNotEmpty() && domainsAdded) {
builder = getDomainList(
domains,
carContext,
Expand Down

0 comments on commit 6a8fd59

Please sign in to comment.