-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cached times aren't working, even in previous releases #12
Comments
Honestly what even could cause this? A spontaneous bug affecting all versions that was definitely not there before just isn't possible. |
The problem seems to be in line 129 in Main.kt:
This creates a new Instant with the correct current date. In the previous versions this could be fixed, by updating
however Pair is immutable, thats why my current workaround is constructing a new Pair using the updated date and the old Buffer like so:
Im sure there is a cleaner way to do it but this seems to work |
Ahhhh that makes sense. I might write a really simple Pair implementation that is mutable to make the fix more readable. Thanks for explaining that haha |
I was confused about this as well at first😄 This stackoverflow answer explains it very nice in detail. Just like Java, Kotlin is pass-by-value, e.g. it passes a copy of a reference to a method, so reassigning this copy to a new object does not change the original. |
Maybe its a better idea, to just create a serializable class "Addiction", with fields name, date, buffer etc. and save that as an ArrayList, then This would also make it easier to add new fields later on, (e.g. total money / time saved?), because you wouldnt need to continue stacking Pairs into Pairs |
Ahaha I feel so stupid now. I wrote it the way I did at first because I thought Kotlin was PBR but thanks for explaining that. |
And yeah that's a good idea |
Closing now because a solution has been found, thanks so much ^^ |
I am 100% sure they worked before but now on every release on multiple devices the cached times don't reset correctly
Expected: Reset time, close and open app, time is relatively small because of the recent reset
Actual: Reset time, close and open app, time is back where it was
I am genuinely baffled.
The text was updated successfully, but these errors were encountered: