Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mob] Refactor

Neeraj Gupta375ab4e4b05f
diff --git a/mobile/lib/models/ml/face/face.dart b/mobile/lib/models/ml/face/face.dart
index 75c3549c41..7a9ee53583 100644
--- a/mobile/lib/models/ml/face/face.dart
+++ b/mobile/lib/models/ml/face/face.dart
@@ -4,6 +4,7 @@ import "package:photos/models/ml/face/dimension.dart";
import "package:photos/models/ml/face/landmark.dart";
import 'package:photos/services/machine_learning/face_ml/face_filtering/face_filtering_constants.dart';
import "package:photos/services/machine_learning/ml_result.dart";
+import "package:photos/utils/parse.dart";
// FileInfo contains the image width and height of the image the face was detected in.
class FileInfo {
@@ -115,28 +116,3 @@ class Face {
'blur': blur,
};
}
-
-double? parseIntOrDoubleAsDouble(dynamic value) {
- if (value == null) return null;
- if (value is int) return value * 1.0;
- if (value is double) return value;
- return null;
-}
-
-List<double> parseAsDoubleList(List<dynamic> inputList) {
- if (inputList.isEmpty) return const [];
-
- if (inputList is List<double>) return inputList;
- return List<double>.generate(
- inputList.length,
- (index) {
- final value = inputList[index];
- if (value is int) return value.toDouble();
- if (value is double) return value;
- throw FormatException(
- 'Invalid type at index $index: ${value.runtimeType}',
- );
- },
- growable: false,
- );
-}
diff --git a/mobile/lib/services/filedata/model/file_data.dart b/mobile/lib/services/filedata/model/file_data.dart
index 56bfe1cb4e..e9dd6fc14b 100644
--- a/mobile/lib/services/filedata/model/file_data.dart
+++ b/mobile/lib/services/filedata/model/file_data.dart
@@ -1,4 +1,5 @@
import "package:photos/models/ml/face/face.dart";
+import "package:photos/utils/parse.dart";
const _faceKey = 'face';
const _clipKey = 'clip';
diff --git a/mobile/lib/utils/parse.dart b/mobile/lib/utils/parse.dart
new file mode 100644
index 0000000000..5eb39d3cb1
--- /dev/null
+++ b/mobile/lib/utils/parse.dart
@@ -0,0 +1,24 @@
+double? parseIntOrDoubleAsDouble(dynamic value) {
+ if (value == null) return null;
+ if (value is int) return value * 1.0;
+ if (value is double) return value;
+ return null;
+}
+
+List<double> parseAsDoubleList(List<dynamic> inputList) {
+ if (inputList.isEmpty) return const [];
+
+ if (inputList is List<double>) return inputList;
+ return List<double>.generate(
+ inputList.length,
+ (index) {
+ final value = inputList[index];
+ if (value is int) return value.toDouble();
+ if (value is double) return value;
+ throw FormatException(
+ 'Invalid type at index $index: ${value.runtimeType}',
+ );
+ },
+ growable: false,
+ );
+}