mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-25 22:18:00 +01:00
close inputstream and datasource to prevent leaks
This commit is contained in:
parent
c3778e36c6
commit
a5292aa669
2 changed files with 11 additions and 8 deletions
|
@ -740,18 +740,18 @@ class PhotoFragment : ViewPagerFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkIfPanorama() {
|
private fun checkIfPanorama() {
|
||||||
mIsPanorama = try {
|
mIsPanorama = try {
|
||||||
val inputStream = if (mMedium.path.startsWith("content:/")) {
|
if (mMedium.path.startsWith("content:/")) {
|
||||||
requireContext().contentResolver.openInputStream(Uri.parse(mMedium.path))
|
requireContext().contentResolver.openInputStream(Uri.parse(mMedium.path))
|
||||||
} else {
|
} else {
|
||||||
File(mMedium.path).inputStream()
|
File(mMedium.path).inputStream()
|
||||||
|
}.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")
|
||||||
}
|
}
|
||||||
|
|
||||||
val imageParser = JpegImageParser().getXmpXml(ByteSourceInputStream(inputStream, 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) {
|
} catch (e: Exception) {
|
||||||
false
|
false
|
||||||
} catch (e: OutOfMemoryError) {
|
} catch (e: OutOfMemoryError) {
|
||||||
|
|
|
@ -362,6 +362,7 @@ import java.io.FileInputStream
|
||||||
try {
|
try {
|
||||||
fileDataSource.open(dataSpec)
|
fileDataSource.open(dataSpec)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
fileDataSource.close()
|
||||||
activity?.showErrorToast(e)
|
activity?.showErrorToast(e)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -370,6 +371,8 @@ import java.io.FileInputStream
|
||||||
val mediaSource: MediaSource = ProgressiveMediaSource.Factory(factory)
|
val mediaSource: MediaSource = ProgressiveMediaSource.Factory(factory)
|
||||||
.createMediaSource(MediaItem.fromUri(fileDataSource.uri!!))
|
.createMediaSource(MediaItem.fromUri(fileDataSource.uri!!))
|
||||||
|
|
||||||
|
fileDataSource.close()
|
||||||
|
|
||||||
mPlayOnPrepared = true
|
mPlayOnPrepared = true
|
||||||
|
|
||||||
mExoPlayer = ExoPlayer.Builder(requireContext())
|
mExoPlayer = ExoPlayer.Builder(requireContext())
|
||||||
|
|
Loading…
Reference in a new issue