| 91 | /// |
| 92 | /// @author Shai Almog |
| 93 | public class Picker extends Button { |
| 94 | |
| 95 | /// Whether useLightweightPopup should default to true, this can be set via |
| 96 | /// the theme constant `lightweightPickerBool` |
| 97 | private static boolean defaultUseLightweightPopup; |
| 98 | private static boolean defaultLightweightModeSet; |
| 99 | private int type = Display.PICKER_TYPE_DATE; |
| 100 | private Object value = new Date(); |
| 101 | private boolean showMeridiem; |
| 102 | private Object metaData; |
| 103 | private Object renderingPrototype = "XXXXXXXXXXXXXX"; |
| 104 | private SimpleDateFormat formatter; |
| 105 | private int preferredPopupWidth; |
| 106 | private int preferredPopupHeight; |
| 107 | private int minuteStep = 5; |
| 108 | private int minHour = -1; |
| 109 | private int maxHour = -1; |
| 110 | private Date startDate; |
| 111 | private Date endDate; |
| 112 | private VirtualInputDevice currentInput; |
| 113 | /// Supplies the initial date shown by the picker when no explicit value has |
| 114 | /// been set via `setDate(Date)`. Resolved lazily each time the picker is |
| 115 | /// opened (or `getDate()` is called against an unset picker) so it can |
| 116 | /// depend on state that changes at runtime - e.g. a reminder picker whose |
| 117 | /// default tracks "one hour before the current due date" can keep returning |
| 118 | /// fresh values as the due date moves. Null means fall back to `new Date()`. |
| 119 | private DateGetter defaultDateGetter; |
| 120 | /// True once the picker's date has been pinned by an explicit `setDate(...)` |
| 121 | /// call (including `setDate(null)` to clear) or a successful user selection. |
| 122 | /// While false the picker treats `value` as a placeholder and prefers |
| 123 | /// `defaultDateGetter` (when set) as the displayed value, so callers can |
| 124 | /// install a default after construction and still see it take effect. Once |
| 125 | /// the caller has explicitly set a value - even `null` - `getDate()` returns |
| 126 | /// exactly that value; the default getter only continues to seed the popup |
| 127 | /// UI when the picker is opened with a `null` value. Issue #5024. |
| 128 | private boolean dateValueExplicitlySet; |
| 129 | |
| 130 | // Variables to store the form's previous margins before showing |
| 131 | // the popup dialog so that we can restore them when the popup is disposed. |
| 132 | private byte[] tmpContentPaneMarginUnit; |
| 133 | private float tmpContentPaneBottomMargin; |
| 134 | /// Flag to indicate that the picker should prefer lightweight components |
| 135 | /// rather than native components. |
| 136 | private boolean useLightweightPopup; |
| 137 | private Runnable stopEditingCallback; |
| 138 | private boolean suppressPaint; |
| 139 | private final ArrayList<LightweightPopupButton> lightweightPopupButtons = new ArrayList<LightweightPopupButton>(); |
| 140 | /// While the lightweight popup is on screen this points at the live spinner widget |
| 141 | /// so that setters propagate into the visible wheels and getters read the wheel |
| 142 | /// position. Null whenever the popup is not showing. |
| 143 | private InternalPickerWidget currentSpinner; |
| 144 | /// Snapshot of `value` taken right before the lightweight popup is shown. |
| 145 | /// Setter calls from custom popup buttons (e.g. a "+7 days" action that does |
| 146 | /// `setDate(getDate() + 7d)`) stage their result into `value`, but if the user |
| 147 | /// dismisses the popup with Cancel we roll `value` back to this snapshot so |
| 148 | /// `getDate()` returns what the picker held before editing began. Non-null only |
| 149 | /// while the popup is on screen. |
| 150 | private Object preEditValue; |
nothing calls this directly
no outgoing calls
no test coverage detected