From 878b39605bbdbfa75a9c6b025e265bc27772d2d4 Mon Sep 17 00:00:00 2001 From: Thibault Deckers Date: Sun, 20 Nov 2022 20:17:28 +0100 Subject: [PATCH] minor fixes --- .../kotlin/deckers/thibault/aves/metadata/XMP.kt | 16 +++++++++++----- .../grid/sections/fixed/section_layout.dart | 4 ++-- plugins/aves_magnifier/lib/src/core/core.dart | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/android/app/src/main/kotlin/deckers/thibault/aves/metadata/XMP.kt b/android/app/src/main/kotlin/deckers/thibault/aves/metadata/XMP.kt index 4eeab81f4..8665bfffc 100644 --- a/android/app/src/main/kotlin/deckers/thibault/aves/metadata/XMP.kt +++ b/android/app/src/main/kotlin/deckers/thibault/aves/metadata/XMP.kt @@ -17,6 +17,7 @@ import deckers.thibault.aves.metadata.metadataextractor.SafeMp4UuidBoxHandler import deckers.thibault.aves.metadata.metadataextractor.SafeXmpReader import deckers.thibault.aves.utils.ContextUtils.queryContentResolverProp import deckers.thibault.aves.utils.LogUtils +import deckers.thibault.aves.utils.MemoryUtils import deckers.thibault.aves.utils.MimeTypes import deckers.thibault.aves.utils.StorageUtils import org.mp4parser.IsoFile @@ -150,12 +151,17 @@ object XMP { // creating `IsoFile` with a `File` or a `File.inputStream()` yields `No such device` IsoFile(channel, boxParser).use { isoFile -> isoFile.processBoxes(UserBox::class.java, true) { box, _ -> - val bytes = box.toBytes() - val payload = bytes.copyOfRange(8, bytes.size) + val boxSize = box.size + if (MemoryUtils.canAllocate(boxSize)) { + val bytes = box.toBytes() + val payload = bytes.copyOfRange(8, bytes.size) - val metadata = com.drew.metadata.Metadata() - SafeMp4UuidBoxHandler(metadata).processBox("", payload, -1, null) - processDirs(metadata.directories.filter { dir -> dir.tagCount > 0 }.toList()) + val metadata = com.drew.metadata.Metadata() + SafeMp4UuidBoxHandler(metadata).processBox("", payload, -1, null) + processDirs(metadata.directories.filter { dir -> dir.tagCount > 0 }.toList()) + } else { + Log.w(LOG_TAG, "MP4 box too large at $boxSize bytes, for mimeType=$mimeType uri=$uri") + } } } } diff --git a/lib/widgets/common/grid/sections/fixed/section_layout.dart b/lib/widgets/common/grid/sections/fixed/section_layout.dart index 2d29be8e0..5b38d8caf 100644 --- a/lib/widgets/common/grid/sections/fixed/section_layout.dart +++ b/lib/widgets/common/grid/sections/fixed/section_layout.dart @@ -28,14 +28,14 @@ class FixedExtentSectionLayout extends SectionLayout { @override int getMinChildIndexForScrollOffset(double scrollOffset) { scrollOffset -= bodyMinOffset; - if (scrollOffset < 0) return firstIndex; + if (scrollOffset < 0 || mainAxisStride == 0) return firstIndex; return bodyFirstIndex + scrollOffset ~/ mainAxisStride; } @override int getMaxChildIndexForScrollOffset(double scrollOffset) { scrollOffset -= bodyMinOffset; - if (scrollOffset < 0) return firstIndex; + if (scrollOffset < 0 || mainAxisStride == 0) return firstIndex; return bodyFirstIndex + (scrollOffset / mainAxisStride).ceil() - 1; } } diff --git a/plugins/aves_magnifier/lib/src/core/core.dart b/plugins/aves_magnifier/lib/src/core/core.dart index 8078939ee..47a762758 100644 --- a/plugins/aves_magnifier/lib/src/core/core.dart +++ b/plugins/aves_magnifier/lib/src/core/core.dart @@ -195,7 +195,7 @@ class _MagnifierCoreState extends State with TickerProviderStateM const t = 0.2; final animationVelocity = (tween.end! - tween.begin!).distance * curve.transform(t) / t; final gestureVelocity = targetPixelPerSecond.distance; - return Duration(milliseconds: (animationVelocity / gestureVelocity * 1000).round()); + return Duration(milliseconds: gestureVelocity != 0 ? (animationVelocity / gestureVelocity * 1000).round() : 0); } void onTap(TapUpDetails details) {