everyone, i would like to have information displayed promptly in my android car app.
I use a GridTemplate in which I want to update the texts of the items. For testing, I have a simple counter, with a timer (10ms) a function is called recursively, which writes the new value into a variable, which in turn is used by the grid when building. It all works, but I can't get the screen to update faster than a second. To redraw the screen, I use invalidate() to re-call onGetTemplate. Is there another possibility to display live data or to speed up the reloading of the screen?
Here some simplyfied code:
public class MyScreen extends Screen {
private int run = 0;
public MyScreen(CarContext carContext) {
super(carContext);
}
@NonNull
@Override
public Template onGetTemplate() {
looping();
Row row = new Row.Builder().setTitle("Count:").addText(run+"").build();
return new PaneTemplate.Builder(new Pane.Builder().addRow(row).build()).setTitle("Wasup").build();
}
private void looping() {
Timer timer = new Timer();
new Timer().schedule(new TimerTask() {
@Override
public void run() {
looping();
}
}, 100);
run++;
Log.d("Test",run+"");
invalidate();
if(run >=1000){run = 0;}
}
}