Fixed: Application crashes when loading the asset(videos) from cache.

* The getData method of the Item class was throwing an error due to any condition, the reason is unknown(may be the data is corrupted or anything) since there are only very less occurrences but it was crashing the application so we are catching the exception if thrown by the `getData()` method so that our application will not crash.
This commit is contained in:
MohitMaliFtechiz 2024-07-17 18:04:05 +05:30 committed by Kelson
parent 9c69d77739
commit ca6d37b43f

View File

@ -347,7 +347,12 @@ class ZimFileReader constructor(
.inputStream() .inputStream()
} }
private fun getContent(url: String) = getItem(url)?.data?.data private fun getContent(url: String) = try {
getItem(url)?.data?.data
} catch (ignore: Exception) {
Log.e(TAG, "Could not get content for url = $url original exception = $ignore")
null
}
@SuppressLint("CheckResult") @SuppressLint("CheckResult")
private fun streamZimContentToPipe(item: Item?, uri: String, outputStream: OutputStream) { private fun streamZimContentToPipe(item: Item?, uri: String, outputStream: OutputStream) {
@ -365,8 +370,8 @@ class ZimFileReader constructor(
} }
} }
} }
} catch (ioException: IOException) { } catch (ignore: Exception) {
Log.e(TAG, "error writing pipe for $uri", ioException) Log.e(TAG, "error writing pipe for $uri", ignore)
} }
} }
} }