I noticed a repaint/revalidation issue with lightweight Picker shortcut buttons on Android.
Use case: a date/time picker using setUseLightweightPopup(true) and custom shortcut buttons added with addLightweightPopupButton(...), e.g. "Today", "Tomorrow", "+7 days", "Now".
On the Simulator the behavior is correct. On Android, when I tap one of these shortcut buttons, the picker value is changed programmatically, but the visible text/wheel in the lightweight picker popup is not refreshed immediately. It looks empty or stale until I touch/move the picker with a finger. After that interaction, the selected value becomes visible.
Expected behavior:
- after a shortcut button changes the picker value with
setDate(...) or setTime(...), the lightweight picker popup should immediately repaint/revalidate itself and show the new value.
Current workaround used in my app:
datePicker.addLightweightPopupButton("Today",
() -> {
datePicker.setDate(DateTimeUtil.toDate(LocalDate.now()));
refreshPickerAfterShortcut(datePicker);
},
Picker.LightweightPopupButtonPlacement.ABOVE_SPINNER,
Component.CENTER);
timePicker.addLightweightPopupButton("Now",
() -> {
timePicker.setTime(DateTimeUtil.toPickerTime(currentMinuteTime()));
refreshPickerAfterShortcut(timePicker);
},
Picker.LightweightPopupButtonPlacement.ABOVE_SPINNER,
Component.CENTER);
private void refreshPickerAfterShortcut(Picker picker) {
picker.repaint();
Form owner = picker.getComponentForm();
if (owner != null) {
owner.revalidateLater();
}
Form current = CN.getCurrentForm();
if (current != null) {
current.revalidateLater();
current.repaint();
}
CN.callSerially(() -> {
picker.repaint();
Form laterCurrent = CN.getCurrentForm();
if (laterCurrent != null) {
laterCurrent.revalidate();
laterCurrent.repaint();
}
});
}
This workaround fixes the problem, but it feels like the lightweight picker implementation should do this internally after a shortcut button callback changes the picker value.
Codename One version: 7.0.244.
I noticed a repaint/revalidation issue with lightweight
Pickershortcut buttons on Android.Use case: a date/time picker using
setUseLightweightPopup(true)and custom shortcut buttons added withaddLightweightPopupButton(...), e.g. "Today", "Tomorrow", "+7 days", "Now".On the Simulator the behavior is correct. On Android, when I tap one of these shortcut buttons, the picker value is changed programmatically, but the visible text/wheel in the lightweight picker popup is not refreshed immediately. It looks empty or stale until I touch/move the picker with a finger. After that interaction, the selected value becomes visible.
Expected behavior:
setDate(...)orsetTime(...), the lightweight picker popup should immediately repaint/revalidate itself and show the new value.Current workaround used in my app:
This workaround fixes the problem, but it feels like the lightweight picker implementation should do this internally after a shortcut button callback changes the picker value.
Codename One version: 7.0.244.