From 219ef6d64edb95d02010ffc95174c2eec4a9d9a7 Mon Sep 17 00:00:00 2001 From: Hyperling Date: Sun, 13 Jul 2025 12:47:27 -0700 Subject: [PATCH] Add more debug output regarding the prevention of large numbers. Reinstate missing assignment of longLoopInterval. --- .../apps/infinitetimer/MainActivity.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/hyperling/apps/infinitetimer/MainActivity.java b/app/src/main/java/com/hyperling/apps/infinitetimer/MainActivity.java index bed99fb..ac98a9b 100755 --- a/app/src/main/java/com/hyperling/apps/infinitetimer/MainActivity.java +++ b/app/src/main/java/com/hyperling/apps/infinitetimer/MainActivity.java @@ -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);