Replace Illegal{State,Argument} exceptions with more idiomatic kotlin code
This commit is contained in:
parent
e0892ca9df
commit
07e53a2d7a
5 changed files with 10 additions and 10 deletions
|
|
@ -92,7 +92,7 @@ class AboutActivity : AppCompatActivity() {
|
||||||
return when (position) {
|
return when (position) {
|
||||||
posAbout -> AboutFragment()
|
posAbout -> AboutFragment()
|
||||||
posLicense -> LicenseFragment.newInstance(SOFTWARE_COMPONENTS)
|
posLicense -> LicenseFragment.newInstance(SOFTWARE_COMPONENTS)
|
||||||
else -> throw IllegalArgumentException("Unknown position for ViewPager2")
|
else -> error("Unknown position for ViewPager2")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -105,7 +105,7 @@ class AboutActivity : AppCompatActivity() {
|
||||||
return when (position) {
|
return when (position) {
|
||||||
posAbout -> R.string.tab_about
|
posAbout -> R.string.tab_about
|
||||||
posLicense -> R.string.tab_licenses
|
posLicense -> R.string.tab_licenses
|
||||||
else -> throw IllegalArgumentException("Unknown position for ViewPager2")
|
else -> error("Unknown position for ViewPager2")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ abstract class StreamDAO : BasicDAO<StreamEntity> {
|
||||||
|
|
||||||
private fun compareAndUpdateStream(newerStream: StreamEntity) {
|
private fun compareAndUpdateStream(newerStream: StreamEntity) {
|
||||||
val existentMinimalStream = getMinimalStreamForCompare(newerStream.serviceId, newerStream.url)
|
val existentMinimalStream = getMinimalStreamForCompare(newerStream.serviceId, newerStream.url)
|
||||||
?: throw IllegalStateException("Stream cannot be null just after insertion.")
|
?: error("Stream cannot be null just after insertion.")
|
||||||
newerStream.uid = existentMinimalStream.uid
|
newerStream.uid = existentMinimalStream.uid
|
||||||
|
|
||||||
if (!StreamTypeUtil.isLiveStream(newerStream.streamType)) {
|
if (!StreamTypeUtil.isLiveStream(newerStream.streamType)) {
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ abstract class SubscriptionDAO : BasicDAO<SubscriptionEntity> {
|
||||||
entity.uid = uidFromInsert
|
entity.uid = uidFromInsert
|
||||||
} else {
|
} else {
|
||||||
val subscriptionIdFromDb = getSubscriptionIdInternal(entity.serviceId, entity.url!!)
|
val subscriptionIdFromDb = getSubscriptionIdInternal(entity.serviceId, entity.url!!)
|
||||||
?: throw IllegalStateException("Subscription cannot be null just after insertion.")
|
?: error("Subscription cannot be null just after insertion.")
|
||||||
entity.uid = subscriptionIdFromDb
|
entity.uid = subscriptionIdFromDb
|
||||||
|
|
||||||
update(entity)
|
update(entity)
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ internal fun infoItemTypeToString(type: InfoType): String {
|
||||||
InfoType.STREAM -> ID_STREAM
|
InfoType.STREAM -> ID_STREAM
|
||||||
InfoType.PLAYLIST -> ID_PLAYLIST
|
InfoType.PLAYLIST -> ID_PLAYLIST
|
||||||
InfoType.CHANNEL -> ID_CHANNEL
|
InfoType.CHANNEL -> ID_CHANNEL
|
||||||
else -> throw IllegalStateException("Unexpected value: $type")
|
else -> error("Unexpected value: $type")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -31,7 +31,7 @@ internal fun infoItemTypeFromString(type: String): InfoType {
|
||||||
ID_STREAM -> InfoType.STREAM
|
ID_STREAM -> InfoType.STREAM
|
||||||
ID_PLAYLIST -> InfoType.PLAYLIST
|
ID_PLAYLIST -> InfoType.PLAYLIST
|
||||||
ID_CHANNEL -> InfoType.CHANNEL
|
ID_CHANNEL -> InfoType.CHANNEL
|
||||||
else -> throw IllegalStateException("Unexpected value: $type")
|
else -> error("Unexpected value: $type")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -82,11 +82,11 @@ internal class PackageValidator(context: Context) {
|
||||||
|
|
||||||
// Build the caller info for the rest of the checks here.
|
// Build the caller info for the rest of the checks here.
|
||||||
val callerPackageInfo = buildCallerInfo(callingPackage)
|
val callerPackageInfo = buildCallerInfo(callingPackage)
|
||||||
?: throw IllegalStateException("Caller wasn't found in the system?")
|
?: error("Caller wasn't found in the system?")
|
||||||
|
|
||||||
// Verify that things aren't ... broken. (This test should always pass.)
|
// Verify that things aren't ... broken. (This test should always pass.)
|
||||||
if (callerPackageInfo.uid != callingUid) {
|
check(callerPackageInfo.uid != callingUid) {
|
||||||
throw IllegalStateException("Caller's package UID doesn't match caller's actual UID?")
|
"Caller's package UID doesn't match caller's actual UID?"
|
||||||
}
|
}
|
||||||
|
|
||||||
val callerSignature = callerPackageInfo.signature
|
val callerSignature = callerPackageInfo.signature
|
||||||
|
|
@ -202,7 +202,7 @@ internal class PackageValidator(context: Context) {
|
||||||
*/
|
*/
|
||||||
private fun getSystemSignature(): String = getPackageInfo(ANDROID_PLATFORM)?.let { platformInfo ->
|
private fun getSystemSignature(): String = getPackageInfo(ANDROID_PLATFORM)?.let { platformInfo ->
|
||||||
getSignature(platformInfo)
|
getSignature(platformInfo)
|
||||||
} ?: throw IllegalStateException("Platform signature not found")
|
} ?: error("Platform signature not found")
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a SHA-256 signature given a certificate byte array.
|
* Creates a SHA-256 signature given a certificate byte array.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue