@@ -61,19 +61,20 @@ protected void onCreate(Bundle savedInstanceState) {
61
61
62
62
setSupportActionBar (toolbar );
63
63
64
- initFields ();
64
+ initFields (true );
65
65
}
66
66
67
67
@ Override
68
68
public void onResume (){
69
69
super .onResume ();
70
- initFields ();
70
+
71
+ initFields (false );
71
72
}
72
73
73
74
/**
74
75
* Initialize the input fields
75
76
*/
76
- private void initFields () {
77
+ private void initFields (boolean initDate ) {
77
78
attestation = new Attestation ();
78
79
79
80
attestationGenerator = new AttestationDeplacementDerogatoireGenerator (this , attestation );
@@ -114,13 +115,15 @@ private void initFields() {
114
115
115
116
travelHourInput = findViewById (R .id .travel_hour );
116
117
117
- DateTextWatcher birthDateTextWatcher = new DateTextWatcher (birthDateInput );
118
+ if (initDate ) {
119
+ DateTextWatcher birthDateTextWatcher = new DateTextWatcher (birthDateInput );
118
120
119
- birthDateInput .addTextChangedListener (birthDateTextWatcher );
121
+ birthDateInput .addTextChangedListener (birthDateTextWatcher );
120
122
121
- DateTextWatcher travelDateTextWatcher = new DateTextWatcher (travelDateInput );
123
+ DateTextWatcher travelDateTextWatcher = new DateTextWatcher (travelDateInput );
122
124
123
- travelDateInput .addTextChangedListener (travelDateTextWatcher );
125
+ travelDateInput .addTextChangedListener (travelDateTextWatcher );
126
+ }
124
127
125
128
travelHourInput .setOnClickListener (new View .OnClickListener () {
126
129
@ Override
@@ -140,15 +143,7 @@ public void onTimeSet(TimePicker timePicker, int hour, int minute) {
140
143
}
141
144
});
142
145
143
- ((CheckBox ) findViewById (R .id .reason1 )).setChecked (userDetails .getBoolean ("reason1" , false ));
144
- ((CheckBox ) findViewById (R .id .reason2 )).setChecked (userDetails .getBoolean ("reason2" , false ));
145
- ((CheckBox ) findViewById (R .id .reason3 )).setChecked (userDetails .getBoolean ("reason3" , false ));
146
- ((CheckBox ) findViewById (R .id .reason4 )).setChecked (userDetails .getBoolean ("reason4" , false ));
147
- ((CheckBox ) findViewById (R .id .reason5 )).setChecked (userDetails .getBoolean ("reason5" , false ));
148
- ((CheckBox ) findViewById (R .id .reason6 )).setChecked (userDetails .getBoolean ("reason6" , false ));
149
- ((CheckBox ) findViewById (R .id .reason7 )).setChecked (userDetails .getBoolean ("reason7" , false ));
150
- ((CheckBox ) findViewById (R .id .reason8 )).setChecked (userDetails .getBoolean ("reason8" , false ));
151
- ((CheckBox ) findViewById (R .id .reason9 )).setChecked (userDetails .getBoolean ("reason9" , false ));
146
+ setReasonsCheckboxes (userDetails );
152
147
153
148
setDate ();
154
149
@@ -168,6 +163,18 @@ public void onClick(View v) {
168
163
constraintSet .applyTo (constraintLayout );
169
164
}
170
165
166
+ private void setReasonsCheckboxes (SharedPreferences userDetails ) {
167
+ ((CheckBox ) findViewById (R .id .reason1 )).setChecked (userDetails .getBoolean ("reason1" , false ));
168
+ ((CheckBox ) findViewById (R .id .reason2 )).setChecked (userDetails .getBoolean ("reason2" , false ));
169
+ ((CheckBox ) findViewById (R .id .reason3 )).setChecked (userDetails .getBoolean ("reason3" , false ));
170
+ ((CheckBox ) findViewById (R .id .reason4 )).setChecked (userDetails .getBoolean ("reason4" , false ));
171
+ ((CheckBox ) findViewById (R .id .reason5 )).setChecked (userDetails .getBoolean ("reason5" , false ));
172
+ ((CheckBox ) findViewById (R .id .reason6 )).setChecked (userDetails .getBoolean ("reason6" , false ));
173
+ ((CheckBox ) findViewById (R .id .reason7 )).setChecked (userDetails .getBoolean ("reason7" , false ));
174
+ ((CheckBox ) findViewById (R .id .reason8 )).setChecked (userDetails .getBoolean ("reason8" , false ));
175
+ ((CheckBox ) findViewById (R .id .reason9 )).setChecked (userDetails .getBoolean ("reason9" , false ));
176
+ }
177
+
171
178
/**
172
179
* Generates the PDF by calling the async task
173
180
* @param v
0 commit comments