mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-22 12:38:00 +01:00
Merge pull request #2955 from gmasil/close-closables-to-prevent-leaks
close inputstream and datasource to prevent leaks
This commit is contained in:
commit
4951002796
2 changed files with 11 additions and 8 deletions
|
@ -745,17 +745,17 @@ class PhotoFragment : ViewPagerFragment() {
|
|||
|
||||
private fun checkIfPanorama() {
|
||||
mIsPanorama = try {
|
||||
val inputStream = if (mMedium.path.startsWith("content:/")) {
|
||||
if (mMedium.path.startsWith("content:/")) {
|
||||
requireContext().contentResolver.openInputStream(Uri.parse(mMedium.path))
|
||||
} else {
|
||||
File(mMedium.path).inputStream()
|
||||
}
|
||||
|
||||
val imageParser = JpegImageParser().getXmpXml(ByteSourceInputStream(inputStream, mMedium.name), HashMap<String, Any>())
|
||||
}.use {
|
||||
val imageParser = JpegImageParser().getXmpXml(ByteSourceInputStream(it, mMedium.name), HashMap<String, Any>())
|
||||
imageParser.contains("GPano:UsePanoramaViewer=\"True\"", true) ||
|
||||
imageParser.contains("<GPano:UsePanoramaViewer>True</GPano:UsePanoramaViewer>", true) ||
|
||||
imageParser.contains("GPano:FullPanoWidthPixels=") ||
|
||||
imageParser.contains("GPano:ProjectionType>Equirectangular")
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
false
|
||||
} catch (e: OutOfMemoryError) {
|
||||
|
|
|
@ -364,6 +364,7 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
|
|||
try {
|
||||
fileDataSource.open(dataSpec)
|
||||
} catch (e: Exception) {
|
||||
fileDataSource.close()
|
||||
activity?.showErrorToast(e)
|
||||
return
|
||||
}
|
||||
|
@ -372,6 +373,8 @@ class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, S
|
|||
val mediaSource: MediaSource = ProgressiveMediaSource.Factory(factory)
|
||||
.createMediaSource(MediaItem.fromUri(fileDataSource.uri!!))
|
||||
|
||||
fileDataSource.close()
|
||||
|
||||
mPlayOnPrepared = true
|
||||
|
||||
mExoPlayer = ExoPlayer.Builder(requireContext())
|
||||
|
|
Loading…
Reference in a new issue