Skip to content

Commit

Permalink
Remove unnecessary cast
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszkwiecinski committed May 4, 2024
1 parent b93eea7 commit 094fcc1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package com.usefulness.threetenbp

import android.app.Application
import android.content.Context
import androidx.annotation.MainThread
import androidx.annotation.WorkerThread
import org.threeten.bp.zone.ZoneRulesInitializer
import org.threeten.bp.ZoneId
import org.threeten.bp.zone.ZoneRulesInitializer
import org.threeten.bp.zone.ZoneRulesProvider
import java.util.concurrent.atomic.AtomicBoolean

Expand All @@ -22,7 +21,7 @@ public object LazyThreeTen {
if (INITIALIZED.getAndSet(true)) {
return
}
ZoneRulesInitializer.setInitializer(LazyZoneRulesInitializer((context.applicationContext as Application)))
ZoneRulesInitializer.setInitializer(LazyZoneRulesInitializer(context.applicationContext))
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.usefulness.threetenbp

import android.app.Application
import android.content.Context
import org.threeten.bp.zone.ZoneRulesInitializer
import org.threeten.bp.zone.ZoneRulesProvider

internal class LazyZoneRulesInitializer(private val application: Application) : ZoneRulesInitializer() {
internal class LazyZoneRulesInitializer(private val context: Context) : ZoneRulesInitializer() {

override fun initializeProviders() {
ZoneRulesProvider.registerProvider(LazyZoneRulesProvider(application))
ZoneRulesProvider.registerProvider(LazyZoneRulesProvider(context.assets))
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.usefulness.threetenbp

import android.content.Context
import android.content.res.AssetManager
import org.threeten.bp.jdk8.Jdk8Methods
import org.threeten.bp.zone.ZoneRules
import org.threeten.bp.zone.ZoneRulesCompat
Expand All @@ -13,7 +13,7 @@ import java.util.NavigableMap
import java.util.TreeMap
import java.util.concurrent.ConcurrentSkipListMap

internal class LazyZoneRulesProvider(private val context: Context) : ZoneRulesProvider() {
internal class LazyZoneRulesProvider(private val assets: AssetManager) : ZoneRulesProvider() {

private val map = ConcurrentSkipListMap<String, ZoneRules?>()

Expand All @@ -39,7 +39,7 @@ internal class LazyZoneRulesProvider(private val context: Context) : ZoneRulesPr
private fun loadData(zoneId: String): ZoneRules {
val fileName = "tzdb/$zoneId.dat"

return runCatching { context.assets.open(fileName).use(::loadData) }
return runCatching { assets.open(fileName).use(::loadData) }
.getOrElse { throw ZoneRulesException("Invalid binary time-zone data: $fileName", it) }
}

Expand Down

0 comments on commit 094fcc1

Please sign in to comment.