Add more debug output regarding the prevention of large numbers. Reinstate missing assignment of longLoopInterval.
This commit is contained in:
@@ -207,30 +207,39 @@ public class MainActivity extends AppCompatActivity {
|
||||
int hours = 0, minutes = 0, seconds = 0;
|
||||
try {
|
||||
hours = Integer.parseInt("0" + etHours.getText().toString());
|
||||
} catch (NumberFormatException e) {
|
||||
} catch (Exception e) {
|
||||
if (DEBUG) Log.d(tag, "Hours had an exception, using highest value");
|
||||
hours = 99;
|
||||
}
|
||||
try {
|
||||
minutes = Integer.parseInt("0" + etMinutes.getText().toString());
|
||||
} catch (NumberFormatException e) {
|
||||
} catch (Exception e) {
|
||||
if (DEBUG) Log.d(tag, "Minutes had an exception, using highest value");
|
||||
minutes = 59;
|
||||
}
|
||||
try {
|
||||
seconds = Integer.parseInt("0" + etSeconds.getText().toString());
|
||||
} catch (NumberFormatException e) {
|
||||
} catch (Exception e) {
|
||||
if (DEBUG) Log.d(tag, "Seconds had an exception, using highest value");
|
||||
seconds = 59;
|
||||
}
|
||||
|
||||
if ((hours + (minutes/60) + (seconds/60/60)) > 99) {
|
||||
if (DEBUG) Log.d(tag, "Sum is over 99 hours, setting to 99:59:59");
|
||||
hours = 99;
|
||||
minutes = 59;
|
||||
seconds = 59;
|
||||
}
|
||||
|
||||
if (DEBUG) Log.d(tag, "hours=" + hours);
|
||||
if (DEBUG) Log.d(tag, "minutes=" + minutes);
|
||||
if (DEBUG) Log.d(tag, "seconds=" + seconds);
|
||||
|
||||
if (hours > 0) etHours.setText("" + hours);
|
||||
if (minutes > 0) etMinutes.setText("" + minutes);
|
||||
if (seconds > 0) etSeconds.setText("" + seconds);
|
||||
|
||||
longLoopInterval = (((hours*60*60) + (minutes*60) + seconds) * 1000);
|
||||
if (DEBUG) Log.d(tag, "longLoopInterval=" + longLoopInterval);
|
||||
|
||||
setChronometer(longLoopInterval);
|
||||
|
Reference in New Issue
Block a user