Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/bitfireAT/ical4android.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicki Hirner <hirner@bitfire.at>2022-09-27 11:29:13 +0300
committerRicki Hirner <hirner@bitfire.at>2022-09-27 11:29:13 +0300
commita334d4fd7da36a230e9287dbb62ccd8513f3fa58 (patch)
tree939d921815ae77781eba4a3b0e43e512f60fc0f7
parente880785483f5e2e488982206cdaf1842e43dc36b (diff)
Small AndroidCompatTimeZoneRegistry refactoring
-rw-r--r--src/main/java/at/bitfire/ical4android/AndroidCompatTimeZoneRegistry.kt11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/main/java/at/bitfire/ical4android/AndroidCompatTimeZoneRegistry.kt b/src/main/java/at/bitfire/ical4android/AndroidCompatTimeZoneRegistry.kt
index 4030404..14fc31d 100644
--- a/src/main/java/at/bitfire/ical4android/AndroidCompatTimeZoneRegistry.kt
+++ b/src/main/java/at/bitfire/ical4android/AndroidCompatTimeZoneRegistry.kt
@@ -32,7 +32,11 @@ class AndroidCompatTimeZoneRegistry(
* @return time zone
*/
override fun getTimeZone(id: String): TimeZone? {
- // check whether time zone is available on Android
+ val tz: TimeZone? = base.getTimeZone(id)
+ if (tz == null) // ical4j doesn't know time zone, return null
+ return null
+
+ // check whether time zone is available on Android, too
val androidTzId =
try {
ZoneId.of(id).id
@@ -40,7 +44,7 @@ class AndroidCompatTimeZoneRegistry(
/* Not available in Android, should return null in a later version.
However, we return the ical4j timezone to keep the changes caused by AndroidCompatTimeZoneRegistry introduction
as small as possible. */
- return base.getTimeZone(id)
+ return tz
}
/* Time zone known by Android. Unfortunately, we can't use the Android timezone database directly
@@ -51,8 +55,7 @@ class AndroidCompatTimeZoneRegistry(
Example: getTimeZone("Europe/Kiev") returns a TimeZone with TZID:Europe/Kyiv since ical4j/3.2.5,
but most Android devices don't now Europe/Kyiv yet.
*/
- val tz: TimeZone? = base.getTimeZone(id)
- if (tz != null && tz.id != androidTzId) {
+ if (tz.id != androidTzId) {
Ical4Android.log.warning("Using Android TZID $androidTzId instead of ical4j ${tz.id}")
// create a copy of the VTIMEZONE so that we don't modify the original registry values (which are not immutable)