Fix crash

This commit is contained in:
nielsandriesse 2020-08-19 12:15:02 +10:00
parent 38464bf1f7
commit e1841db991
2 changed files with 8 additions and 2 deletions

View File

@ -142,7 +142,11 @@ class PathActivity : PassphraseRequiredActionBarActivity() {
private fun getPathRow(snode: Snode, location: LineView.Location, dotAnimationStartDelay: Long, dotAnimationRepeatInterval: Long, isGuardSnode: Boolean): LinearLayout {
val title = if (isGuardSnode) resources.getString(R.string.activity_path_guard_node_row_title) else resources.getString(R.string.activity_path_service_node_row_title)
val subtitle = IP2Country.shared.countryNamesCache[snode.ip] ?: "Resolving..."
val subtitle = if (IP2Country.isInitialized) {
IP2Country.shared.countryNamesCache[snode.ip] ?: "Resolving..."
} else {
"Resolving..."
}
return getPathRow(title, subtitle, location, dotAnimationStartDelay, dotAnimationRepeatInterval)
}
// endregion

View File

@ -29,8 +29,10 @@ class IP2Country private constructor(private val context: Context) {
public lateinit var shared: IP2Country
public val isInitialized: Boolean get() = ::shared.isInitialized
public fun configureIfNeeded(context: Context) {
if (::shared.isInitialized) { return; }
if (isInitialized) { return; }
shared = IP2Country(context)
}
}