Fix resources possibly defined under a different package name
This commit is contained in:
@@ -3,6 +3,7 @@ package be.mygod.vpnhotspot.util
|
||||
import android.annotation.SuppressLint
|
||||
import android.annotation.TargetApi
|
||||
import android.content.*
|
||||
import android.content.res.Resources
|
||||
import android.net.InetAddresses
|
||||
import android.net.LinkProperties
|
||||
import android.net.RouteInfo
|
||||
@@ -134,6 +135,11 @@ var MenuItem.isNotGone: Boolean
|
||||
isEnabled = value
|
||||
}
|
||||
|
||||
fun Resources.findIdentifier(name: String, defType: String, defPackage: String, alternativePackage: String? = null) =
|
||||
getIdentifier(name, defType, defPackage).let {
|
||||
if (alternativePackage != null && it == 0) getIdentifier(name, defType, alternativePackage) else it
|
||||
}
|
||||
|
||||
@get:RequiresApi(26)
|
||||
private val newLookup by lazy @TargetApi(26) {
|
||||
MethodHandles.Lookup::class.java.getDeclaredConstructor(Class::class.java, Int::class.java).apply {
|
||||
|
||||
Reference in New Issue
Block a user