I have the following code that runs at program startup. It serves to show a toast informing which people are birthday on the current day, through an excel file. However, when there is more than one birthday person, he shows several toasts at once, one on top of the other. I wanted a way to wait, while a toast disappears, to show the next one
Arquivo arquivo = new Arquivo();
ObservableList<String> listaDatas = arquivo.pegarListaString(1, 8); //take people's birthday dates
String data = Agenda.dateParaString(LocalDate.now()).substring(0, 5); //today's day
String data2 = Agenda.dateParaString(LocalDate.now().plusDays(1)).substring(0, 5); //tomorrow
int index = 0;
for(String valor: listaDatas) {
if (valor.length() > 4) {
if (valor.substring(0, 5).equalsIgnoreCase(data)) {
Agenda.mostrarToastTexto("Hoje é aniversário de " + arquivo.pegarValor(1, index, 0), 2000);
} else if(valor.substring(0, 5).equalsIgnoreCase(data2)) {
Agenda.mostrarToastTexto("Amanhã é aniversário de " + arquivo.pegarValor(1, index, 0) , 2000);
}
}
index++;
}
I already tried to use a "Thread.sleep" and also the class Timer, but to no avail.