@@ -128,7 +128,7 @@ protected void onCreate(final Bundle savedInstanceState) {
128
128
tvShadow .setOnClickListener (new View .OnClickListener () {
129
129
@ Override
130
130
public void onClick (View v ) {
131
- if (bottomSheetBehavior .getState ()== BottomSheetBehavior .STATE_EXPANDED )
131
+ if (bottomSheetBehavior .getState () == BottomSheetBehavior .STATE_EXPANDED )
132
132
bottomSheetBehavior .setState (BottomSheetBehavior .STATE_HIDDEN );
133
133
tvShadow .setVisibility (View .GONE );
134
134
}
@@ -184,6 +184,7 @@ public void onClick(View v) {
184
184
switch (knobState ) {
185
185
case 3 :
186
186
if (scienceLab .isConnected ()) {
187
+ v .setEnabled (false );
187
188
DecimalFormat resistanceFormat = new DecimalFormat ("#.##" );
188
189
Double resistance ;
189
190
Double avgResistance = 0.0 ;
@@ -225,33 +226,41 @@ public void onClick(View v) {
225
226
saveAndSetData (Resistance , resistanceUnit );
226
227
if (recordData )
227
228
record ("Resistance" , Resistance + recordUnit );
229
+ v .setEnabled (true );
228
230
}
229
231
break ;
230
232
case 4 :
231
233
if (scienceLab .isConnected ()) {
234
+ v .setEnabled (false );
232
235
Double capacitance = scienceLab .getCapacitance ();
233
236
DecimalFormat capacitanceFormat = new DecimalFormat ("#.##" );
234
237
String Capacitance ;
235
238
String capacitanceUnit ;
236
- if (capacitance < 1e-9 ) {
237
- Capacitance = capacitanceFormat .format ((capacitance / 1e-12 ));
238
- capacitanceUnit = "pF" ;
239
- } else if (capacitance < 1e-6 ) {
240
- Capacitance = capacitanceFormat .format ((capacitance / 1e-9 ));
241
- capacitanceUnit = "nF" ;
242
- } else if (capacitance < 1e-3 ) {
243
- Capacitance = capacitanceFormat .format ((capacitance / 1e-6 ));
244
- capacitanceUnit = "\u00B5 " + "F" ;
245
- } else if (capacitance < 1e-1 ) {
246
- Capacitance = capacitanceFormat .format ((capacitance / 1e-3 ));
247
- capacitanceUnit = "mF" ;
239
+ if (capacitance == null ) {
240
+ Capacitance = "Cannot measure!" ;
241
+ capacitanceUnit = "" ;
248
242
} else {
249
- Capacitance = capacitanceFormat .format (capacitance );
250
- capacitanceUnit = getString (R .string .capacitance_unit );
243
+ if (capacitance < 1e-9 ) {
244
+ Capacitance = capacitanceFormat .format ((capacitance / 1e-12 ));
245
+ capacitanceUnit = "pF" ;
246
+ } else if (capacitance < 1e-6 ) {
247
+ Capacitance = capacitanceFormat .format ((capacitance / 1e-9 ));
248
+ capacitanceUnit = "nF" ;
249
+ } else if (capacitance < 1e-3 ) {
250
+ Capacitance = capacitanceFormat .format ((capacitance / 1e-6 ));
251
+ capacitanceUnit = "\u00B5 " + "F" ;
252
+ } else if (capacitance < 1e-1 ) {
253
+ Capacitance = capacitanceFormat .format ((capacitance / 1e-3 ));
254
+ capacitanceUnit = "mF" ;
255
+ } else {
256
+ Capacitance = capacitanceFormat .format (capacitance );
257
+ capacitanceUnit = getString (R .string .capacitance_unit );
258
+ }
251
259
}
252
260
saveAndSetData (Capacitance , capacitanceUnit );
253
261
if (recordData )
254
262
record ("Capacitance" , Capacitance + capacitanceUnit );
263
+ v .setEnabled (true );
255
264
}
256
265
break ;
257
266
case 5 :
@@ -260,26 +269,32 @@ public void onClick(View v) {
260
269
case 8 :
261
270
if (!switchIsChecked ) {
262
271
if (scienceLab .isConnected ()) {
272
+ v .setEnabled (false );
263
273
Double frequency = scienceLab .getFrequency (knobMarker [knobState ], null );
264
274
saveAndSetData (String .valueOf (frequency ), getString (R .string .frequency_unit ));
265
275
if (recordData )
266
276
record (knobMarker [knobState ], String .valueOf (frequency ) + getString (R .string .frequency_unit ));
277
+ v .setEnabled (true );
267
278
}
268
279
} else {
269
280
if (scienceLab .isConnected ()) {
281
+ v .setEnabled (false );
270
282
scienceLab .countPulses (knobMarker [knobState ]);
271
283
double pulseCount = scienceLab .readPulseCount ();
272
284
saveAndSetData (String .valueOf (pulseCount ), "" );
273
285
if (recordData )
274
286
record (knobMarker [knobState ], String .valueOf (pulseCount ));
287
+ v .setEnabled (true );
275
288
}
276
289
}
277
290
break ;
278
291
default :
279
292
if (scienceLab .isConnected ()) {
293
+ v .setEnabled (false );
280
294
saveAndSetData (String .valueOf (String .format (Locale .ENGLISH , "%.2f" , scienceLab .getVoltage (knobMarker [knobState ], 1 ))), getString (R .string .multimeter_voltage_unit ));
281
295
if (recordData )
282
296
record (knobMarker [knobState ], String .valueOf (String .format (Locale .ENGLISH , "%.2f" , scienceLab .getVoltage (knobMarker [knobState ], 1 ))) + getString (R .string .multimeter_voltage_unit ));
297
+ v .setEnabled (true );
283
298
}
284
299
break ;
285
300
}
0 commit comments