1

I have my simple app working and now I want it to support Android Auto. The principle is to send message to webserver which will open my gate or garage door.

The app is checking the current state from the webserver overy 2 seconds to check if it's open, opening, closed or closing. For these states I have several drawables representing the states.

The issue I'm facing now is I dont understand how to rebuild/repaint the Android Auto Screen as it's using different approach. Originally I was simply changing the textView.text but now it's creating the objects via Builder(), so I dont understand how to change it after it's created.

Thank you!

class DeanoCarScreen (carContext: CarContext) : Screen(carContext){

val MAIN_URL = "xxx"

override fun onGetTemplate(): Template {
val itemList = ItemList.Builder()


val garageIcon0 = CarIcon.Builder(IconCompat.createWithResource(carContext,R.drawable.gar0)).build()
val garageIcon1 = CarIcon.Builder(IconCompat.createWithResource(carContext,R.drawable.gar1)).build()


val garage = GridItem.Builder()
    .setTitle("Garáž")
    .setImage(garageIcon0)
    .setOnClickListener { garageClick() }
    .build()

itemList.addItem(garage)

    return GridTemplate.Builder().setSingleList(itemList.build()).setHeaderAction(Action.BACK).build()
}


fun garageClick(){
    changeState(1,"xxx",carContext,MAIN_URL)
    imageSwap()
}

fun imageSwap(){
   ????
}
Dan Rykala
  • 19
  • 3

0 Answers0