properly catch TransactionTooLargeException when sharing large items

This commit is contained in:
tibbi 2018-02-17 00:00:20 +01:00
parent 96f3875be2
commit 2e98a333c1
2 changed files with 14 additions and 13 deletions

View file

@ -6,7 +6,7 @@ buildscript {
propMinSdkVersion = 16
propTargetSdkVersion = propCompileSdkVersion
propVersionCode = 1
propVersionName = '3.12.0'
propVersionName = '3.12.2'
kotlin_version = '1.2.21'
support_libs = '27.0.2'
}

View file

@ -134,14 +134,15 @@ fun Activity.sharePathIntent(path: String, applicationId: String) {
putExtra(Intent.EXTRA_STREAM, newUri)
type = getUriMimeType(path, newUri)
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
if (resolveActivity(packageManager) != null) {
try {
try {
if (resolveActivity(packageManager) != null) {
startActivity(Intent.createChooser(this, getString(R.string.share_via)))
} catch (e: TransactionTooLargeException) {
toast(R.string.maximum_share_reached)
} else {
toast(R.string.no_app_found)
}
} else {
toast(R.string.no_app_found)
} catch (e: TransactionTooLargeException) {
toast(R.string.maximum_share_reached)
}
}
}.start()
@ -170,14 +171,14 @@ fun Activity.sharePathsIntent(paths: ArrayList<String>, applicationId: String) {
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
putParcelableArrayListExtra(Intent.EXTRA_STREAM, newUris)
if (resolveActivity(packageManager) != null) {
try {
try {
if (resolveActivity(packageManager) != null) {
startActivity(Intent.createChooser(this, getString(R.string.share_via)))
} catch (e: TransactionTooLargeException) {
toast(R.string.maximum_share_reached)
} else {
toast(R.string.no_app_found)
}
} else {
toast(R.string.no_app_found)
} catch (e: TransactionTooLargeException) {
toast(R.string.maximum_share_reached)
}
}
}