Use kotlinx-datetime
instead of Java APIs
#50
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR replaces Java-specific APIs with Kotlin's ones. In particular, it:
kotlinx-datetime
library (see the "Migration guide" below).SpriteSheet.aspectRatio
toAspectRatio
(previously it was anandroid.util.Rational
).java.io.Serializable
fromImageUrl
.Warning
This PR is a breaking change compared to the previous version!
kotlinx-datetime
kotlinx-serialization
out of the box. So theISO8601DateParser
andDateSerializer
are no longer necessary.java.time
API internally. So if the min API is less than 26, core library desugaring is necessary.Migration guide
The official documentation provides more information about
kotlinx-datetime
API, but here are some quick tips to help you get started:Date()
Clock.System.now()
Date.time
Instant.toEpochMilliseconds()
Date.after(Date)
Instant > Instant
Date.before(Date)
Instant < Instant
Date(timestamp + offset)
Instant + Duration
Clock.System.now() + 5.minutes
Next steps
Following the merge of this PR:
srgletterbox-android
will be updated as well to use the new models → https://github.com/SRGSSR/srgletterbox-android/pull/542playsrg-android
needs to be updated to support these changes → https://github.com/SRGSSR/playsrg-android/pull/314