فهرست منبع

[feat]调整加载方式

Destiny 1 سال پیش
والد
کامیت
69c037010a
3فایلهای تغییر یافته به همراه22 افزوده شده و 14 حذف شده
  1. 0 1
      lib/data/repositories/user_repository.dart
  2. 5 6
      lib/module/home/home_view.dart
  3. 17 7
      lib/module/image_picker/image_picker_util.dart

+ 0 - 1
lib/data/repositories/user_repository.dart

@@ -26,7 +26,6 @@ class UserRepository {
 
   // 检测是否为会员
   bool isVip() {
-
    if (Platform.isAndroid) {
       return true;
     }

+ 5 - 6
lib/module/home/home_view.dart

@@ -380,7 +380,7 @@ class HomePage extends BaseView<HomeController> {
                   mainAxisAlignment: MainAxisAlignment.spaceBetween,
                   children: List.generate(4, (index) {
 
-                    if (!controller.isSimilarScanned.value) {
+                    if (!controller.isSimilarScanned.value&&controller.similarPhotos.isEmpty) {
                       return ImageContainer(
                         size: 70.w,
                         image: Opacity(
@@ -398,8 +398,7 @@ class HomePage extends BaseView<HomeController> {
                       width: 70.w * 0.45,
                       height: 70.w * 0.45,
                     );
-                    if (controller.isSimilarScanned.value &&
-                        controller.similarPhotos.length > index) {
+                    if (controller.similarPhotos.length > index) {
 
                       image = AssetEntityImage(
                           width: 70.w,
@@ -478,7 +477,7 @@ class HomePage extends BaseView<HomeController> {
                     return Row(
                       mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                       children: List.generate(2, (index) {
-                        if (!controller.isPeopleScanned.value) {
+                        if (!controller.isPeopleScanned.value&&controller.peoplePhotos.isEmpty) {
                           return ImageContainer(
                             size: 146.w,
                             image: Opacity(
@@ -658,7 +657,7 @@ class HomePage extends BaseView<HomeController> {
                   : 'Clean up',
               ImagePickerUtil.formatFileSize(
                   ImagePickerUtil.screenshotsSize.value),
-              !controller.isScreenShotScanned.value
+              !controller.isScreenShotScanned.value&&controller.screenshotPhoto.value == null
                   ? Opacity(
                 opacity: 0.22,
                 child: Lottie.asset(Assets.anim.animLoadingPhoto,
@@ -692,7 +691,7 @@ class HomePage extends BaseView<HomeController> {
                 !controller.isBlurryScanned.value ? 'Scanning...' : 'Clean up',
                 ImagePickerUtil.formatFileSize(
                     ImagePickerUtil.blurrySize.value),
-                !controller.isBlurryScanned.value?
+                !controller.isBlurryScanned.value&&controller.blurryPhoto.value == null?
                 Opacity(
                   opacity: 0.22,
                   child: Lottie.asset(Assets.anim.animLoadingPhoto,

+ 17 - 7
lib/module/image_picker/image_picker_util.dart

@@ -56,6 +56,7 @@ class ImagePickerUtil {
   static final Rx<int> similarPhotosSize = 0.obs;
 
   static var similarResult = <ClassifiedImageGroup>[].obs;
+  static var allSimilarResult =<ClassifiedImageGroup>[].obs;
   static var peopleResult = <ClassifiedImage>[].obs;
   static var screenshotResult = <ClassifiedImage>[].obs;
   static var blurryResult = <ClassifiedImage>[].obs;
@@ -71,7 +72,7 @@ class ImagePickerUtil {
 
   static loadClassifiedPhotoData(ClassificationResult result) async {
     if (result.similarGroups != null) {
-      similarResult.assignAll(result.similarGroups ?? []);
+      similarResult(result.similarGroups ?? []);
       await newUpdatePhotoGroups("similar", similarResult);
     }
 
@@ -259,12 +260,15 @@ class ImagePickerUtil {
         .removeWhere((element) => selectedPhotosIds.contains(element.assetsId));
     blurrySize.value =
         blurryResult.fold(0, (sum, image) => sum + image.fileSize);
-    similarResult.map((group) => group.images.removeWhere(
-        (element) => selectedPhotosIds.contains(element.assetsId)));
-    similarPhotoCount.value =
-        similarResult.fold(0, (sum, group) => sum + group.groupImageCount);
-    similarPhotosSize.value =
-        similarResult.fold(0, (sum, group) => sum + group.groupFileSize);
+    similarPhotosSize.value=0;
+    similarPhotoCount.value=0;
+    for (var group in allSimilarResult) {
+      group.images.removeWhere(
+              (element) => selectedPhotosIds.contains(element.assetsId));
+
+    similarPhotosSize.value += group.images.fold(0, (sum, image) => sum + image.fileSize);
+    similarPhotoCount.value += group.images.length;
+    }
 
     debugPrint("ImagePickerUtil3  updatePhotoData $selectedPhotosIds");
     CalendarState.removePhotosData(selectedPhotosIds);
@@ -320,11 +324,15 @@ class ImagePickerUtil {
         similarPhotos.add(await _newConvertToAssetEntities(group.images));
         similarPhotosSize.value += group.groupFileSize;
         similarPhotoCount.value += group.groupImageCount;
+        allSimilarResult.add(group);
+
       }
       for (final group in ImagePickerUtil.similarPhotos) {
         for (final asset in group) {
           if (PhotoScanHandler.similarPhotos.length >= 4) break;
+          if(PhotoScanHandler.similarPhotos.contains(asset)) continue;
           PhotoScanHandler.similarPhotos.add(asset);
+
         }
         if (PhotoScanHandler.similarPhotos.length >= 4) break;
       }
@@ -353,8 +361,10 @@ class ImagePickerUtil {
         peoplePhotos.assignAll(await _newConvertToAssetEntities(photoGroup));
         peopleSize.value =
             photoGroup.fold(0, (sum, image) => sum + image.fileSize);
+
         for (final person in ImagePickerUtil.peoplePhotos) {
           if (PhotoScanHandler.peoplePhotos.length >= 2) break;
+          if(PhotoScanHandler.peoplePhotos.contains(person)) continue;
           PhotoScanHandler.peoplePhotos.add(person);
         }