Browse Source

Move fileTypeFromAsset to file_type

Neeraj Gupta 1 year ago
parent
commit
fe674effb4
2 changed files with 23 additions and 21 deletions
  1. 0 21
      lib/models/file.dart
  2. 23 0
      lib/models/file_type.dart

+ 0 - 21
lib/models/file.dart

@@ -110,27 +110,6 @@ class File extends EnteFile {
     return creationTime;
   }
 
-  static FileType _fileTypeFromAsset(AssetEntity asset) {
-    FileType type = FileType.image;
-    switch (asset.type) {
-      case AssetType.image:
-        type = FileType.image;
-        // PHAssetMediaSubtype.photoLive.rawValue is 8
-        // This hack should go away once photos_manager support livePhotos
-        if (asset.subtype > -1 && (asset.subtype & 8) != 0) {
-          type = FileType.livePhoto;
-        }
-        break;
-      case AssetType.video:
-        type = FileType.video;
-        break;
-      default:
-        type = FileType.other;
-        break;
-    }
-    return type;
-  }
-
   Future<AssetEntity?> get getAsset {
     if (localID == null) {
       return Future.value(null);

+ 23 - 0
lib/models/file_type.dart

@@ -1,3 +1,5 @@
+import "package:photo_manager/photo_manager.dart";
+
 enum FileType {
   image,
   video,
@@ -31,6 +33,27 @@ FileType getFileType(int fileType) {
   }
 }
 
+FileType fileTypeFromAsset(AssetEntity asset) {
+  FileType type = FileType.image;
+  switch (asset.type) {
+    case AssetType.image:
+      type = FileType.image;
+      // PHAssetMediaSubtype.photoLive.rawValue is 8
+      // This hack should go away once photos_manager support livePhotos
+      if (asset.subtype > -1 && (asset.subtype & 8) != 0) {
+        type = FileType.livePhoto;
+      }
+      break;
+    case AssetType.video:
+      type = FileType.video;
+      break;
+    default:
+      type = FileType.other;
+      break;
+  }
+  return type;
+}
+
 String getHumanReadableString(FileType fileType) {
   switch (fileType) {
     case FileType.image: