mirror of
https://github.com/FossifyOrg/Notes.git
synced 2026-06-11 18:19:15 -04:00
Fix resource leak
This commit is contained in:
@@ -869,17 +869,16 @@ class MainActivity : SimpleActivity() {
|
||||
}
|
||||
|
||||
private fun checkUri(uri: Uri, onChecksPassed: () -> Unit) {
|
||||
val inputStream = try {
|
||||
contentResolver.openInputStream(uri) ?: return
|
||||
try {
|
||||
contentResolver.openInputStream(uri)?.use { inputStream ->
|
||||
if (inputStream.available() > 1000 * 1000) {
|
||||
toast(R.string.file_too_large)
|
||||
} else {
|
||||
onChecksPassed()
|
||||
}
|
||||
} ?: return
|
||||
} catch (e: Exception) {
|
||||
showErrorToast(e)
|
||||
return
|
||||
}
|
||||
|
||||
if (inputStream.available() > 1000 * 1000) {
|
||||
toast(R.string.file_too_large)
|
||||
} else {
|
||||
onChecksPassed()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user