wireguard-android/ui/src/main/java/com/wireguard/android/util/FragmentUtils.kt
Harsh Shandilya b2bbaf050c util: Start converting to Kotlin
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
2020-03-26 22:33:01 -06:00

22 lines
640 B
Kotlin

/*
* Copyright © 2017-2019 WireGuard LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package com.wireguard.android.util
import android.view.ContextThemeWrapper
import androidx.preference.Preference
import com.wireguard.android.activity.SettingsActivity
object FragmentUtils {
fun getPrefActivity(preference: Preference): SettingsActivity {
val context = preference.context
if (context is ContextThemeWrapper) {
if (context is SettingsActivity) {
return context
}
}
throw IllegalStateException("Failed to resolve SettingsActivity")
}
}