How to go to another EDIT screen and do not reset the countdown time
Here is my code:
@Subscribe
protected void onInit(InitEvent event) {
ScreenOptions screenOptions = event.getOptions();
if (screenOptions instanceof MapScreenOptions) {
Map<String, Object> queryParams = ((MapScreenOptions) screenOptions).getParams();
count = (int) queryParams.get("count");
}
minute = countdowntime / 60;
second = countdowntime%60;
}
int count = 0;
int countdowntime = 63;
int second = 0;
int minute =0;
private void demNguoc() {
BackgroundTask<Integer, Void> task = new BackgroundTask<Integer, Void>(countdowntime, this) {
@Override
public Void run(TaskLifeCycle<Integer> taskLifeCycle) throws InterruptedException {
Thread.sleep(1000);
return null;
}
@Override
public void done(Void result) {
super.done(result);
thoigianlambaiLabel.setValue(minute + ":" + second);
if (second == 0) {
second = 60;
minute--;
}
if (minute < 0) {
thoigianlambaiLabel.setValue(00 + ":" + 00);
minute = 0;
second = 0;
} else {
second--;
demNguoc();
}
}
};
taskHandler = backgroundWorker.handle(task);
taskHandler.execute();
}