@momo-kits/native-kits 0.0.1-beta.5 → 0.89.1-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/android/.gradle/8.0/checksums/checksums.lock +0 -0
- package/android/.gradle/8.0/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/8.0/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/8.0/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.0/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.0/gc.properties +0 -0
- package/android/.gradle/config.properties +2 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/.idea/gradle.xml +12 -0
- package/android/.idea/migrations.xml +10 -0
- package/android/.idea/misc.xml +10 -0
- package/android/.idea/vcs.xml +6 -0
- package/android/.idea/workspace.xml +50 -0
- package/android/build.gradle +35 -69
- package/android/local.properties +8 -0
- package/android/proguard-rules.pro +21 -0
- package/android/src/main/AndroidManifest.xml +2 -2
- package/android/src/main/java/com/momoplatform/nativekits/foundations/Button.kt +16 -0
- package/android/src/main/java/com/momoplatform/nativekits/libs/Logo.kt +63 -0
- package/android/src/main/java/com/momoplatform/nativekits/libs/TrustBanner.kt +246 -0
- package/android/src/main/res/drawable/ic_launcher_background.xml +170 -0
- package/android/src/main/res/drawable-v24/ic_launcher_foreground.xml +30 -0
- package/android/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +6 -0
- package/android/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +6 -0
- package/android/src/main/res/mipmap-hdpi/ic_launcher.webp +0 -0
- package/android/src/main/res/mipmap-hdpi/ic_launcher_round.webp +0 -0
- package/android/src/main/res/mipmap-mdpi/ic_launcher.webp +0 -0
- package/android/src/main/res/mipmap-mdpi/ic_launcher_round.webp +0 -0
- package/android/src/main/res/mipmap-xhdpi/ic_launcher.webp +0 -0
- package/android/src/main/res/mipmap-xhdpi/ic_launcher_round.webp +0 -0
- package/android/src/main/res/mipmap-xxhdpi/ic_launcher.webp +0 -0
- package/android/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp +0 -0
- package/android/src/main/res/mipmap-xxxhdpi/ic_launcher.webp +0 -0
- package/android/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp +0 -0
- package/android/src/main/res/values/colors.xml +10 -0
- package/android/src/main/res/values/strings.xml +3 -0
- package/android/src/main/res/values/themes.xml +3 -0
- package/android/src/main/res/values-night/themes.xml +3 -0
- package/android/src/main/res/xml/backup_rules.xml +13 -0
- package/android/src/main/res/xml/data_extraction_rules.xml +19 -0
- package/build.gradle.kts +18 -0
- package/compose/build.gradle.kts +82 -0
- package/compose/src/androidMain/AndroidManifest.xml +2 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/utils/Platform.kt +3 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/utils/SetMaskFilter.kt +8 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/utils/Utils.android.kt +14 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Components.kt +194 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +197 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +133 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +62 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +27 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +288 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +80 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +23 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +42 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +126 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +51 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +299 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +246 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +223 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +244 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +281 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PromotionPopup.kt +72 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +65 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +64 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +63 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +73 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +42 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +150 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +12 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +13 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +173 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +242 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +2 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +2 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +2 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +50 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +1321 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Platform.kt +3 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/SetMaskFilter.kt +5 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +97 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/utils/Platform.kt +3 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/utils/SetMaskFilter.kt +9 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/utils/Utils.ios.kt +18 -0
- package/gradle.properties +19 -0
- package/gradlew +240 -0
- package/gradlew.bat +91 -0
- package/ios/Button/Button.swift +9 -2
- package/ios/CalculatorKeyboard/CalculatorKeyboard.swift +126 -0
- package/ios/Colors+Radius+Spacing/Colors.swift +21 -19
- package/ios/Input/Input.swift +1 -0
- package/ios/OTPKeyboard/KeyboardButton.swift +12 -4
- package/ios/Popup/PopupDisplay.swift +72 -81
- package/ios/Popup/PopupInput.swift +96 -0
- package/ios/Popup/PopupPromotion.swift +52 -0
- package/ios/ScrollIndicator/ScrollIndicator.swift +79 -0
- package/ios/Template/Logo/Logo.swift +75 -0
- package/ios/Template/TrustBanner/TrustBanner.swift +189 -0
- package/ios/native-kits.podspec +1 -1
- package/local.properties +8 -0
- package/package.json +6 -6
- package/publish.sh +1 -10
- package/settings.gradle.kts +41 -0
- package/android/gradle.properties +0 -5
- package/android/src/main/java/com/momoplatform/nativekits/NativeKitsPackage.kt +0 -17
- package/android/src/main/java/com/momoplatform/nativekits/NativeKitsViewManager.kt +0 -20
- package/example/ios/Example/Assets.xcassets/AppIcon.appiconset/Contents.json +0 -63
- package/example/ios/Example/Assets.xcassets/Background.colorset/Contents.json +0 -38
- package/example/ios/Example/Assets.xcassets/Border.colorset/Contents.json +0 -38
- package/example/ios/Example/Assets.xcassets/Card.colorset/Contents.json +0 -38
- package/example/ios/Example/Assets.xcassets/Contents.json +0 -6
- package/example/ios/Example/Assets.xcassets/Error.colorset/Contents.json +0 -38
- package/example/ios/Example/Assets.xcassets/Primary.colorset/Contents.json +0 -38
- package/example/ios/Example/Assets.xcassets/PrimaryDark.colorset/Contents.json +0 -38
- package/example/ios/Example/Assets.xcassets/PrimaryLight.colorset/Contents.json +0 -38
- package/example/ios/Example/Assets.xcassets/Secondary.colorset/Contents.json +0 -38
- package/example/ios/Example/Assets.xcassets/Success.colorset/Contents.json +0 -38
- package/example/ios/Example/Assets.xcassets/Text.colorset/Contents.json +0 -38
- package/example/ios/Example/Assets.xcassets/TextSecondary.colorset/Contents.json +0 -38
- package/example/ios/Example/Assets.xcassets/Warning.colorset/Contents.json +0 -38
- package/example/ios/Example/ComponentDetail.swift +0 -35
- package/example/ios/Example/ComponentItem.swift +0 -24
- package/example/ios/Example/ComponentModel.swift +0 -38
- package/example/ios/Example/ContentView.swift +0 -39
- package/example/ios/Example/Example.entitlements +0 -10
- package/example/ios/Example/Foundation/ButtonDemo.swift +0 -80
- package/example/ios/Example/Foundation/ImageDemo.swift +0 -43
- package/example/ios/Example/Foundation/Popup/ActionSheets.swift +0 -136
- package/example/ios/Example/Foundation/Popup/Floats.swift +0 -127
- package/example/ios/Example/Foundation/Popup/Popups.swift +0 -51
- package/example/ios/Example/Foundation/PopupDemo.swift +0 -389
- package/example/ios/Example/Foundation/TextInputDemo.swift +0 -36
- package/example/ios/Example/Foundation/TypographyDemo.swift +0 -53
- package/example/ios/Example/Foundation.swift +0 -26
- package/example/ios/Example/Info.plist +0 -18
- package/example/ios/Example/Library/CheckboxDemo.swift +0 -19
- package/example/ios/Example/Library/SwipeableDemo.swift +0 -105
- package/example/ios/Example/Library/SwitchDemo.swift +0 -19
- package/example/ios/Example/Library.swift +0 -26
- package/example/ios/Example/Main.swift +0 -27
- package/example/ios/Example/Overview.swift +0 -20
- package/example/ios/Example/Preview Content/Preview Assets.xcassets/Contents.json +0 -6
- package/example/ios/Example/Resource/SFProText-Black.ttf +0 -0
- package/example/ios/Example/Resource/SFProText-Bold.ttf +0 -0
- package/example/ios/Example/Resource/SFProText-Heavy.ttf +0 -0
- package/example/ios/Example/Resource/SFProText-Light.ttf +0 -0
- package/example/ios/Example/Resource/SFProText-Medium.ttf +0 -0
- package/example/ios/Example/Resource/SFProText-Regular.ttf +0 -0
- package/example/ios/Example/Resource/SFProText-Semibold.ttf +0 -0
- package/example/ios/Example/Resource/SFProText-Thin.ttf +0 -0
- package/example/ios/Example/Resource/SFProText-Ultralight.ttf +0 -0
- package/example/ios/Example/Resource/foundation.json +0 -33
- package/example/ios/Example/Resource/library.json +0 -18
- package/example/ios/Example/Utils.swift +0 -30
- package/example/ios/Example/ViewModifier/DarkViewModifier.swift +0 -22
- package/example/ios/Example.xcodeproj/project.pbxproj +0 -581
- package/example/ios/Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/example/ios/Example.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/example/ios/Example.xcodeproj/project.xcworkspace/xcuserdata/wem.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/example/ios/Example.xcodeproj/xcuserdata/wem.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
- package/example/ios/Example.xcworkspace/contents.xcworkspacedata +0 -10
- package/example/ios/Example.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/example/ios/Example.xcworkspace/xcuserdata/wem.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/example/ios/Example.xcworkspace/xcuserdata/wem.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +0 -6
- package/example/ios/Podfile +0 -7
- package/example/ios/Podfile.lock +0 -35
- package/example/ios/Pods/Local Podspecs/MoMoUIKits.podspec.json +0 -37
- package/example/ios/Pods/Manifest.lock +0 -35
- package/example/ios/Pods/Pods.xcodeproj/project.pbxproj +0 -2047
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/wem.xcuserdatad/xcschemes/MoMoUIKits.xcscheme +0 -58
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/wem.xcuserdatad/xcschemes/Pods-Example.xcscheme +0 -58
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/wem.xcuserdatad/xcschemes/SDWebImage.xcscheme +0 -58
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/wem.xcuserdatad/xcschemes/SDWebImageSwiftUI.xcscheme +0 -58
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/wem.xcuserdatad/xcschemes/SkeletonUI.xcscheme +0 -58
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/wem.xcuserdatad/xcschemes/xcschememanagement.plist +0 -46
- package/example/ios/Pods/SDWebImage/LICENSE +0 -20
- package/example/ios/Pods/SDWebImage/README.md +0 -352
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/NSButton+WebCache.h +0 -340
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/NSButton+WebCache.m +0 -172
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/NSData+ImageContentType.h +0 -63
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/NSData+ImageContentType.m +0 -165
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/NSImage+Compatibility.h +0 -67
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/NSImage+Compatibility.m +0 -120
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDAnimatedImage.h +0 -114
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDAnimatedImage.m +0 -392
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDAnimatedImagePlayer.h +0 -112
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDAnimatedImagePlayer.m +0 -420
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDAnimatedImageRep.h +0 -23
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDAnimatedImageRep.m +0 -133
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDAnimatedImageView+WebCache.h +0 -168
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDAnimatedImageView+WebCache.m +0 -79
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDAnimatedImageView.h +0 -110
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDAnimatedImageView.m +0 -540
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDDiskCache.h +0 -145
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDDiskCache.m +0 -326
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDGraphicsImageRenderer.h +0 -73
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDGraphicsImageRenderer.m +0 -256
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageAPNGCoder.h +0 -19
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageAPNGCoder.m +0 -58
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageAWebPCoder.h +0 -23
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageAWebPCoder.m +0 -98
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageCache.h +0 -450
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageCache.m +0 -1030
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageCacheConfig.h +0 -153
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageCacheConfig.m +0 -68
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageCacheDefine.h +0 -156
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageCacheDefine.m +0 -138
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageCachesManager.h +0 -81
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageCachesManager.m +0 -556
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageCoder.h +0 -297
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageCoder.m +0 -26
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageCoderHelper.h +0 -153
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageCoderHelper.m +0 -822
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageCodersManager.h +0 -58
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageCodersManager.m +0 -130
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageFrame.h +0 -36
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageFrame.m +0 -28
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageGIFCoder.h +0 -22
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageGIFCoder.m +0 -58
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageGraphics.h +0 -28
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageGraphics.m +0 -127
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageHEICCoder.h +0 -25
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageHEICCoder.m +0 -101
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageIOAnimatedCoder.h +0 -58
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageIOAnimatedCoder.m +0 -807
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageIOCoder.h +0 -30
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageIOCoder.m +0 -420
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageLoader.h +0 -146
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageLoader.m +0 -170
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageLoadersManager.h +0 -40
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageLoadersManager.m +0 -123
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageTransformer.h +0 -241
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDImageTransformer.m +0 -331
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDMemoryCache.h +0 -78
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDMemoryCache.m +0 -158
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageCacheKeyFilter.h +0 -32
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageCacheKeyFilter.m +0 -39
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageCacheSerializer.h +0 -36
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageCacheSerializer.m +0 -39
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageCompat.h +0 -95
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageCompat.m +0 -17
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageDefine.h +0 -352
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageDefine.m +0 -149
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageDownloader.h +0 -314
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageDownloader.m +0 -658
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageDownloaderConfig.h +0 -113
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageDownloaderConfig.m +0 -60
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageDownloaderDecryptor.h +0 -49
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageDownloaderDecryptor.m +0 -55
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageDownloaderOperation.h +0 -191
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageDownloaderOperation.m +0 -722
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageDownloaderRequestModifier.h +0 -69
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageDownloaderRequestModifier.m +0 -71
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageDownloaderResponseModifier.h +0 -69
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageDownloaderResponseModifier.m +0 -73
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageError.h +0 -32
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageError.m +0 -16
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageIndicator.h +0 -115
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageIndicator.m +0 -275
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageManager.h +0 -290
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageManager.m +0 -775
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageOperation.h +0 -27
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageOperation.m +0 -14
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageOptionsProcessor.h +0 -72
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageOptionsProcessor.m +0 -59
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImagePrefetcher.h +0 -143
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImagePrefetcher.m +0 -303
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageTransition.h +0 -131
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/SDWebImageTransition.m +0 -194
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIButton+WebCache.h +0 -387
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIButton+WebCache.m +0 -234
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImage+ExtendedCacheData.h +0 -24
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImage+ExtendedCacheData.m +0 -23
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImage+ForceDecode.h +0 -46
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImage+ForceDecode.m +0 -60
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImage+GIF.h +0 -26
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImage+GIF.m +0 -22
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImage+MemoryCacheCost.h +0 -27
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImage+MemoryCacheCost.m +0 -47
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImage+Metadata.h +0 -89
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImage+Metadata.m +0 -221
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImage+MultiFormat.h +0 -80
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImage+MultiFormat.m +0 -47
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImage+Transform.h +0 -146
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImage+Transform.m +0 -824
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImageView+HighlightedWebCache.h +0 -129
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImageView+HighlightedWebCache.m +0 -76
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImageView+WebCache.h +0 -194
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIImageView+WebCache.m +0 -67
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIView+WebCache.h +0 -110
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIView+WebCache.m +0 -446
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIView+WebCacheOperation.h +0 -48
- package/example/ios/Pods/SDWebImage/SDWebImage/Core/UIView+WebCacheOperation.m +0 -82
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/NSBezierPath+SDRoundedCorners.h +0 -24
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/NSBezierPath+SDRoundedCorners.m +0 -42
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDAssociatedObject.h +0 -14
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDAssociatedObject.m +0 -29
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDAsyncBlockOperation.h +0 -21
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDAsyncBlockOperation.m +0 -92
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDDeviceHelper.h +0 -18
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDDeviceHelper.m +0 -32
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDDisplayLink.h +0 -29
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDDisplayLink.m +0 -227
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDFileAttributeHelper.h +0 -19
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDFileAttributeHelper.m +0 -127
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDImageAssetManager.h +0 -23
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDImageAssetManager.m +0 -164
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDImageCachesManagerOperation.h +0 -21
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDImageCachesManagerOperation.m +0 -83
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDImageIOAnimatedCoderInternal.h +0 -39
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDInternalMacros.h +0 -122
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDInternalMacros.m +0 -13
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDWeakProxy.h +0 -20
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDWeakProxy.m +0 -79
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDWebImageTransitionInternal.h +0 -19
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/SDmetamacros.h +0 -667
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/UIColor+SDHexString.h +0 -18
- package/example/ios/Pods/SDWebImage/SDWebImage/Private/UIColor+SDHexString.m +0 -42
- package/example/ios/Pods/SDWebImage/WebImage/SDWebImage.h +0 -89
- package/example/ios/Pods/SDWebImageSwiftUI/LICENSE +0 -19
- package/example/ios/Pods/SDWebImageSwiftUI/README.md +0 -690
- package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Classes/AnimatedImage.swift +0 -870
- package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Classes/Backports/Backport.swift +0 -59
- package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Classes/Backports/OnChange.swift +0 -52
- package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Classes/Backports/Overlay.swift +0 -124
- package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Classes/Backports/StateObject.swift +0 -151
- package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Classes/Image.swift +0 -78
- package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Classes/ImageManager.swift +0 -132
- package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Classes/ImagePlayer.swift +0 -122
- package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Classes/ImageViewWrapper.swift +0 -133
- package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Classes/Indicator/ActivityIndicator.swift +0 -82
- package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Classes/Indicator/Indicator.swift +0 -97
- package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Classes/Indicator/ProgressIndicator.swift +0 -114
- package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Classes/SDWebImageSwiftUI.swift +0 -64
- package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Classes/SwiftUICompatibility.swift +0 -92
- package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Classes/Transition/Transition.swift +0 -93
- package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Classes/WebImage.swift +0 -509
- package/example/ios/Pods/SDWebImageSwiftUI/SDWebImageSwiftUI/Module/SDWebImageSwiftUI.h +0 -15
- package/example/ios/Pods/SkeletonUI/LICENSE +0 -21
- package/example/ios/Pods/SkeletonUI/README.md +0 -137
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Angle/AngleInteractor.swift +0 -29
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Angle/AnglePresenter.swift +0 -7
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Animation/AnimationInteractor.swift +0 -56
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Appearance/AppearanceInteractor.swift +0 -58
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Appearance/AppearancePresenter.swift +0 -5
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Extensions/ClosedRange+Normalize.swift +0 -16
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Extensions/Image+OptionalType.swift +0 -102
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Extensions/ModifiedContent+SkeletonModifier.swift +0 -26
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Extensions/Optional+OptionalType.swift +0 -5
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Extensions/SecureField+OptionalType.swift +0 -19
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Extensions/Text+OptionalType.swift +0 -27
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Extensions/TextField+OptionalType.swift +0 -35
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Extensions/Toggle+OptionalType.swift +0 -29
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Extensions/UnitPoint+Angle.swift +0 -8
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Extensions/View+SkeletonModifier.swift +0 -8
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Modifiers/SkeletonModifier.swift +0 -52
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Multiline/MultilineInteractor.swift +0 -41
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Multiline/MultilinePresenter.swift +0 -9
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Opacity/OpacityInteractor.swift +0 -29
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Opacity/OpacityPresenter.swift +0 -7
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Position/PositionInteractor.swift +0 -29
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Position/PositionPresenter.swift +0 -7
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Protocols/OptionalType.swift +0 -4
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Radius/RadiusInteractor.swift +0 -29
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Radius/RadiusPresenter.swift +0 -7
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Shape/ShapeInteractor.swift +0 -33
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Shape/ShapePresenter.swift +0 -5
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Skeleton/SkeletonForEach.swift +0 -20
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Skeleton/SkeletonInteractor.swift +0 -27
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Skeleton/SkeletonList.swift +0 -20
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Skeleton/SkeletonPresenter.swift +0 -15
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Skeleton/SkeletonShape.swift +0 -64
- package/example/ios/Pods/SkeletonUI/Sources/SkeletonUI/Skeleton/SkeletonView.swift +0 -25
- package/example/ios/Pods/Target Support Files/MoMoUIKits/MoMoUIKits-dummy.m +0 -5
- package/example/ios/Pods/Target Support Files/MoMoUIKits/MoMoUIKits-prefix.pch +0 -12
- package/example/ios/Pods/Target Support Files/MoMoUIKits/MoMoUIKits-umbrella.h +0 -16
- package/example/ios/Pods/Target Support Files/MoMoUIKits/MoMoUIKits.debug.xcconfig +0 -15
- package/example/ios/Pods/Target Support Files/MoMoUIKits/MoMoUIKits.modulemap +0 -6
- package/example/ios/Pods/Target Support Files/MoMoUIKits/MoMoUIKits.release.xcconfig +0 -15
- package/example/ios/Pods/Target Support Files/Pods-Example/Pods-Example-acknowledgements.markdown +0 -75
- package/example/ios/Pods/Target Support Files/Pods-Example/Pods-Example-acknowledgements.plist +0 -119
- package/example/ios/Pods/Target Support Files/Pods-Example/Pods-Example-dummy.m +0 -5
- package/example/ios/Pods/Target Support Files/Pods-Example/Pods-Example-umbrella.h +0 -16
- package/example/ios/Pods/Target Support Files/Pods-Example/Pods-Example.debug.xcconfig +0 -15
- package/example/ios/Pods/Target Support Files/Pods-Example/Pods-Example.modulemap +0 -6
- package/example/ios/Pods/Target Support Files/Pods-Example/Pods-Example.release.xcconfig +0 -15
- package/example/ios/Pods/Target Support Files/SDWebImage/SDWebImage-dummy.m +0 -5
- package/example/ios/Pods/Target Support Files/SDWebImage/SDWebImage-prefix.pch +0 -12
- package/example/ios/Pods/Target Support Files/SDWebImage/SDWebImage-umbrella.h +0 -75
- package/example/ios/Pods/Target Support Files/SDWebImage/SDWebImage.debug.xcconfig +0 -14
- package/example/ios/Pods/Target Support Files/SDWebImage/SDWebImage.modulemap +0 -6
- package/example/ios/Pods/Target Support Files/SDWebImage/SDWebImage.release.xcconfig +0 -14
- package/example/ios/Pods/Target Support Files/SDWebImageSwiftUI/SDWebImageSwiftUI-dummy.m +0 -5
- package/example/ios/Pods/Target Support Files/SDWebImageSwiftUI/SDWebImageSwiftUI-prefix.pch +0 -12
- package/example/ios/Pods/Target Support Files/SDWebImageSwiftUI/SDWebImageSwiftUI-umbrella.h +0 -17
- package/example/ios/Pods/Target Support Files/SDWebImageSwiftUI/SDWebImageSwiftUI.debug.xcconfig +0 -17
- package/example/ios/Pods/Target Support Files/SDWebImageSwiftUI/SDWebImageSwiftUI.modulemap +0 -6
- package/example/ios/Pods/Target Support Files/SDWebImageSwiftUI/SDWebImageSwiftUI.release.xcconfig +0 -17
- package/example/ios/Pods/Target Support Files/SkeletonUI/SkeletonUI-dummy.m +0 -5
- package/example/ios/Pods/Target Support Files/SkeletonUI/SkeletonUI-prefix.pch +0 -12
- package/example/ios/Pods/Target Support Files/SkeletonUI/SkeletonUI-umbrella.h +0 -16
- package/example/ios/Pods/Target Support Files/SkeletonUI/SkeletonUI.debug.xcconfig +0 -12
- package/example/ios/Pods/Target Support Files/SkeletonUI/SkeletonUI.modulemap +0 -6
- package/example/ios/Pods/Target Support Files/SkeletonUI/SkeletonUI.release.xcconfig +0 -12
- package/ios/Extensions/View++.swift +0 -9
|
@@ -1,1030 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* This file is part of the SDWebImage package.
|
|
3
|
-
* (c) Olivier Poitrey <rs@dailymotion.com>
|
|
4
|
-
*
|
|
5
|
-
* For the full copyright and license information, please view the LICENSE
|
|
6
|
-
* file that was distributed with this source code.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
#import "SDImageCache.h"
|
|
10
|
-
#import "NSImage+Compatibility.h"
|
|
11
|
-
#import "SDImageCodersManager.h"
|
|
12
|
-
#import "SDImageCoderHelper.h"
|
|
13
|
-
#import "SDAnimatedImage.h"
|
|
14
|
-
#import "UIImage+MemoryCacheCost.h"
|
|
15
|
-
#import "UIImage+Metadata.h"
|
|
16
|
-
#import "UIImage+ExtendedCacheData.h"
|
|
17
|
-
|
|
18
|
-
@interface SDImageCacheToken ()
|
|
19
|
-
|
|
20
|
-
@property (nonatomic, strong, nullable, readwrite) NSString *key;
|
|
21
|
-
@property (nonatomic, assign, getter=isCancelled) BOOL cancelled;
|
|
22
|
-
@property (nonatomic, copy, nullable) SDImageCacheQueryCompletionBlock doneBlock;
|
|
23
|
-
|
|
24
|
-
@end
|
|
25
|
-
|
|
26
|
-
@implementation SDImageCacheToken
|
|
27
|
-
|
|
28
|
-
-(instancetype)initWithDoneBlock:(nullable SDImageCacheQueryCompletionBlock)doneBlock {
|
|
29
|
-
self = [super init];
|
|
30
|
-
if (self) {
|
|
31
|
-
self.doneBlock = doneBlock;
|
|
32
|
-
}
|
|
33
|
-
return self;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
- (void)cancel {
|
|
37
|
-
@synchronized (self) {
|
|
38
|
-
if (self.isCancelled) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
self.cancelled = YES;
|
|
42
|
-
|
|
43
|
-
SDImageCacheQueryCompletionBlock doneBlock = self.doneBlock;
|
|
44
|
-
self.doneBlock = nil;
|
|
45
|
-
if (doneBlock) {
|
|
46
|
-
dispatch_main_async_safe(^{
|
|
47
|
-
doneBlock(nil, nil, SDImageCacheTypeNone);
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
@end
|
|
54
|
-
|
|
55
|
-
static NSString * _defaultDiskCacheDirectory;
|
|
56
|
-
|
|
57
|
-
@interface SDImageCache ()
|
|
58
|
-
|
|
59
|
-
#pragma mark - Properties
|
|
60
|
-
@property (nonatomic, strong, readwrite, nonnull) id<SDMemoryCache> memoryCache;
|
|
61
|
-
@property (nonatomic, strong, readwrite, nonnull) id<SDDiskCache> diskCache;
|
|
62
|
-
@property (nonatomic, copy, readwrite, nonnull) SDImageCacheConfig *config;
|
|
63
|
-
@property (nonatomic, copy, readwrite, nonnull) NSString *diskCachePath;
|
|
64
|
-
@property (nonatomic, strong, nullable) dispatch_queue_t ioQueue;
|
|
65
|
-
|
|
66
|
-
@end
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
@implementation SDImageCache
|
|
70
|
-
|
|
71
|
-
#pragma mark - Singleton, init, dealloc
|
|
72
|
-
|
|
73
|
-
+ (nonnull instancetype)sharedImageCache {
|
|
74
|
-
static dispatch_once_t once;
|
|
75
|
-
static id instance;
|
|
76
|
-
dispatch_once(&once, ^{
|
|
77
|
-
instance = [self new];
|
|
78
|
-
});
|
|
79
|
-
return instance;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
+ (NSString *)defaultDiskCacheDirectory {
|
|
83
|
-
if (!_defaultDiskCacheDirectory) {
|
|
84
|
-
_defaultDiskCacheDirectory = [[self userCacheDirectory] stringByAppendingPathComponent:@"com.hackemist.SDImageCache"];
|
|
85
|
-
}
|
|
86
|
-
return _defaultDiskCacheDirectory;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
+ (void)setDefaultDiskCacheDirectory:(NSString *)defaultDiskCacheDirectory {
|
|
90
|
-
_defaultDiskCacheDirectory = [defaultDiskCacheDirectory copy];
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
- (instancetype)init {
|
|
94
|
-
return [self initWithNamespace:@"default"];
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
- (nonnull instancetype)initWithNamespace:(nonnull NSString *)ns {
|
|
98
|
-
return [self initWithNamespace:ns diskCacheDirectory:nil];
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
- (nonnull instancetype)initWithNamespace:(nonnull NSString *)ns
|
|
102
|
-
diskCacheDirectory:(nullable NSString *)directory {
|
|
103
|
-
return [self initWithNamespace:ns diskCacheDirectory:directory config:SDImageCacheConfig.defaultCacheConfig];
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
- (nonnull instancetype)initWithNamespace:(nonnull NSString *)ns
|
|
107
|
-
diskCacheDirectory:(nullable NSString *)directory
|
|
108
|
-
config:(nullable SDImageCacheConfig *)config {
|
|
109
|
-
if ((self = [super init])) {
|
|
110
|
-
NSAssert(ns, @"Cache namespace should not be nil");
|
|
111
|
-
|
|
112
|
-
if (!config) {
|
|
113
|
-
config = SDImageCacheConfig.defaultCacheConfig;
|
|
114
|
-
}
|
|
115
|
-
_config = [config copy];
|
|
116
|
-
|
|
117
|
-
// Create IO queue
|
|
118
|
-
dispatch_queue_attr_t ioQueueAttributes = _config.ioQueueAttributes;
|
|
119
|
-
_ioQueue = dispatch_queue_create("com.hackemist.SDImageCache", ioQueueAttributes);
|
|
120
|
-
NSAssert(_ioQueue, @"The IO queue should not be nil. Your configured `ioQueueAttributes` may be wrong");
|
|
121
|
-
|
|
122
|
-
// Init the memory cache
|
|
123
|
-
NSAssert([config.memoryCacheClass conformsToProtocol:@protocol(SDMemoryCache)], @"Custom memory cache class must conform to `SDMemoryCache` protocol");
|
|
124
|
-
_memoryCache = [[config.memoryCacheClass alloc] initWithConfig:_config];
|
|
125
|
-
|
|
126
|
-
// Init the disk cache
|
|
127
|
-
if (!directory) {
|
|
128
|
-
// Use default disk cache directory
|
|
129
|
-
directory = [self.class defaultDiskCacheDirectory];
|
|
130
|
-
}
|
|
131
|
-
_diskCachePath = [directory stringByAppendingPathComponent:ns];
|
|
132
|
-
|
|
133
|
-
NSAssert([config.diskCacheClass conformsToProtocol:@protocol(SDDiskCache)], @"Custom disk cache class must conform to `SDDiskCache` protocol");
|
|
134
|
-
_diskCache = [[config.diskCacheClass alloc] initWithCachePath:_diskCachePath config:_config];
|
|
135
|
-
|
|
136
|
-
// Check and migrate disk cache directory if need
|
|
137
|
-
[self migrateDiskCacheDirectory];
|
|
138
|
-
|
|
139
|
-
#if SD_UIKIT
|
|
140
|
-
// Subscribe to app events
|
|
141
|
-
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
142
|
-
selector:@selector(applicationWillTerminate:)
|
|
143
|
-
name:UIApplicationWillTerminateNotification
|
|
144
|
-
object:nil];
|
|
145
|
-
|
|
146
|
-
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
147
|
-
selector:@selector(applicationDidEnterBackground:)
|
|
148
|
-
name:UIApplicationDidEnterBackgroundNotification
|
|
149
|
-
object:nil];
|
|
150
|
-
#endif
|
|
151
|
-
#if SD_MAC
|
|
152
|
-
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
153
|
-
selector:@selector(applicationWillTerminate:)
|
|
154
|
-
name:NSApplicationWillTerminateNotification
|
|
155
|
-
object:nil];
|
|
156
|
-
#endif
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
return self;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
- (void)dealloc {
|
|
163
|
-
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
#pragma mark - Cache paths
|
|
167
|
-
|
|
168
|
-
- (nullable NSString *)cachePathForKey:(nullable NSString *)key {
|
|
169
|
-
if (!key) {
|
|
170
|
-
return nil;
|
|
171
|
-
}
|
|
172
|
-
return [self.diskCache cachePathForKey:key];
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
+ (nullable NSString *)userCacheDirectory {
|
|
176
|
-
NSArray<NSString *> *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
|
|
177
|
-
return paths.firstObject;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
- (void)migrateDiskCacheDirectory {
|
|
181
|
-
if ([self.diskCache isKindOfClass:[SDDiskCache class]]) {
|
|
182
|
-
static dispatch_once_t onceToken;
|
|
183
|
-
dispatch_once(&onceToken, ^{
|
|
184
|
-
// ~/Library/Caches/com.hackemist.SDImageCache/default/
|
|
185
|
-
NSString *newDefaultPath = [[[self.class userCacheDirectory] stringByAppendingPathComponent:@"com.hackemist.SDImageCache"] stringByAppendingPathComponent:@"default"];
|
|
186
|
-
// ~/Library/Caches/default/com.hackemist.SDWebImageCache.default/
|
|
187
|
-
NSString *oldDefaultPath = [[[self.class userCacheDirectory] stringByAppendingPathComponent:@"default"] stringByAppendingPathComponent:@"com.hackemist.SDWebImageCache.default"];
|
|
188
|
-
dispatch_async(self.ioQueue, ^{
|
|
189
|
-
[((SDDiskCache *)self.diskCache) moveCacheDirectoryFromPath:oldDefaultPath toPath:newDefaultPath];
|
|
190
|
-
});
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
#pragma mark - Store Ops
|
|
196
|
-
|
|
197
|
-
- (void)storeImage:(nullable UIImage *)image
|
|
198
|
-
forKey:(nullable NSString *)key
|
|
199
|
-
completion:(nullable SDWebImageNoParamsBlock)completionBlock {
|
|
200
|
-
[self storeImage:image imageData:nil forKey:key toDisk:YES completion:completionBlock];
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
- (void)storeImage:(nullable UIImage *)image
|
|
204
|
-
forKey:(nullable NSString *)key
|
|
205
|
-
toDisk:(BOOL)toDisk
|
|
206
|
-
completion:(nullable SDWebImageNoParamsBlock)completionBlock {
|
|
207
|
-
[self storeImage:image imageData:nil forKey:key toDisk:toDisk completion:completionBlock];
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
- (void)storeImageData:(nullable NSData *)imageData
|
|
211
|
-
forKey:(nullable NSString *)key
|
|
212
|
-
completion:(nullable SDWebImageNoParamsBlock)completionBlock {
|
|
213
|
-
[self storeImage:nil imageData:imageData forKey:key toDisk:YES completion:completionBlock];
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
- (void)storeImage:(nullable UIImage *)image
|
|
217
|
-
imageData:(nullable NSData *)imageData
|
|
218
|
-
forKey:(nullable NSString *)key
|
|
219
|
-
toDisk:(BOOL)toDisk
|
|
220
|
-
completion:(nullable SDWebImageNoParamsBlock)completionBlock {
|
|
221
|
-
return [self storeImage:image imageData:imageData forKey:key toMemory:YES toDisk:toDisk completion:completionBlock];
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
- (void)storeImage:(nullable UIImage *)image
|
|
225
|
-
imageData:(nullable NSData *)imageData
|
|
226
|
-
forKey:(nullable NSString *)key
|
|
227
|
-
toMemory:(BOOL)toMemory
|
|
228
|
-
toDisk:(BOOL)toDisk
|
|
229
|
-
completion:(nullable SDWebImageNoParamsBlock)completionBlock {
|
|
230
|
-
if ((!image && !imageData) || !key) {
|
|
231
|
-
if (completionBlock) {
|
|
232
|
-
completionBlock();
|
|
233
|
-
}
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
236
|
-
// if memory cache is enabled
|
|
237
|
-
if (image && toMemory && self.config.shouldCacheImagesInMemory) {
|
|
238
|
-
NSUInteger cost = image.sd_memoryCost;
|
|
239
|
-
[self.memoryCache setObject:image forKey:key cost:cost];
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
if (!toDisk) {
|
|
243
|
-
if (completionBlock) {
|
|
244
|
-
completionBlock();
|
|
245
|
-
}
|
|
246
|
-
return;
|
|
247
|
-
}
|
|
248
|
-
dispatch_async(self.ioQueue, ^{
|
|
249
|
-
@autoreleasepool {
|
|
250
|
-
NSData *data = imageData;
|
|
251
|
-
if (!data && [image respondsToSelector:@selector(animatedImageData)]) {
|
|
252
|
-
// If image is custom animated image class, prefer its original animated data
|
|
253
|
-
data = [((id<SDAnimatedImage>)image) animatedImageData];
|
|
254
|
-
}
|
|
255
|
-
if (!data && image) {
|
|
256
|
-
// Check image's associated image format, may return .undefined
|
|
257
|
-
SDImageFormat format = image.sd_imageFormat;
|
|
258
|
-
if (format == SDImageFormatUndefined) {
|
|
259
|
-
// If image is animated, use GIF (APNG may be better, but has bugs before macOS 10.14)
|
|
260
|
-
if (image.sd_isAnimated) {
|
|
261
|
-
format = SDImageFormatGIF;
|
|
262
|
-
} else {
|
|
263
|
-
// If we do not have any data to detect image format, check whether it contains alpha channel to use PNG or JPEG format
|
|
264
|
-
format = [SDImageCoderHelper CGImageContainsAlpha:image.CGImage] ? SDImageFormatPNG : SDImageFormatJPEG;
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
data = [[SDImageCodersManager sharedManager] encodedDataWithImage:image format:format options:nil];
|
|
268
|
-
}
|
|
269
|
-
[self _storeImageDataToDisk:data forKey:key];
|
|
270
|
-
[self _archivedDataWithImage:image forKey:key];
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
if (completionBlock) {
|
|
274
|
-
dispatch_async(dispatch_get_main_queue(), ^{
|
|
275
|
-
completionBlock();
|
|
276
|
-
});
|
|
277
|
-
}
|
|
278
|
-
});
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
- (void)_archivedDataWithImage:(UIImage *)image forKey:(NSString *)key {
|
|
282
|
-
if (!image || !key) {
|
|
283
|
-
return;
|
|
284
|
-
}
|
|
285
|
-
// Check extended data
|
|
286
|
-
id extendedObject = image.sd_extendedObject;
|
|
287
|
-
if (![extendedObject conformsToProtocol:@protocol(NSCoding)]) {
|
|
288
|
-
return;
|
|
289
|
-
}
|
|
290
|
-
NSData *extendedData;
|
|
291
|
-
if (@available(iOS 11, tvOS 11, macOS 10.13, watchOS 4, *)) {
|
|
292
|
-
NSError *error;
|
|
293
|
-
extendedData = [NSKeyedArchiver archivedDataWithRootObject:extendedObject requiringSecureCoding:NO error:&error];
|
|
294
|
-
if (error) {
|
|
295
|
-
NSLog(@"NSKeyedArchiver archive failed with error: %@", error);
|
|
296
|
-
}
|
|
297
|
-
} else {
|
|
298
|
-
@try {
|
|
299
|
-
#pragma clang diagnostic push
|
|
300
|
-
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
|
301
|
-
extendedData = [NSKeyedArchiver archivedDataWithRootObject:extendedObject];
|
|
302
|
-
#pragma clang diagnostic pop
|
|
303
|
-
} @catch (NSException *exception) {
|
|
304
|
-
NSLog(@"NSKeyedArchiver archive failed with exception: %@", exception);
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
if (extendedData) {
|
|
308
|
-
[self.diskCache setExtendedData:extendedData forKey:key];
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
- (void)storeImageToMemory:(UIImage *)image forKey:(NSString *)key {
|
|
313
|
-
if (!image || !key) {
|
|
314
|
-
return;
|
|
315
|
-
}
|
|
316
|
-
NSUInteger cost = image.sd_memoryCost;
|
|
317
|
-
[self.memoryCache setObject:image forKey:key cost:cost];
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
- (void)storeImageDataToDisk:(nullable NSData *)imageData
|
|
321
|
-
forKey:(nullable NSString *)key {
|
|
322
|
-
if (!imageData || !key) {
|
|
323
|
-
return;
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
dispatch_sync(self.ioQueue, ^{
|
|
327
|
-
[self _storeImageDataToDisk:imageData forKey:key];
|
|
328
|
-
});
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
// Make sure to call from io queue by caller
|
|
332
|
-
- (void)_storeImageDataToDisk:(nullable NSData *)imageData forKey:(nullable NSString *)key {
|
|
333
|
-
if (!imageData || !key) {
|
|
334
|
-
return;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
[self.diskCache setData:imageData forKey:key];
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
#pragma mark - Query and Retrieve Ops
|
|
341
|
-
|
|
342
|
-
- (void)diskImageExistsWithKey:(nullable NSString *)key completion:(nullable SDImageCacheCheckCompletionBlock)completionBlock {
|
|
343
|
-
dispatch_async(self.ioQueue, ^{
|
|
344
|
-
BOOL exists = [self _diskImageDataExistsWithKey:key];
|
|
345
|
-
if (completionBlock) {
|
|
346
|
-
dispatch_async(dispatch_get_main_queue(), ^{
|
|
347
|
-
completionBlock(exists);
|
|
348
|
-
});
|
|
349
|
-
}
|
|
350
|
-
});
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
- (BOOL)diskImageDataExistsWithKey:(nullable NSString *)key {
|
|
354
|
-
if (!key) {
|
|
355
|
-
return NO;
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
__block BOOL exists = NO;
|
|
359
|
-
dispatch_sync(self.ioQueue, ^{
|
|
360
|
-
exists = [self _diskImageDataExistsWithKey:key];
|
|
361
|
-
});
|
|
362
|
-
|
|
363
|
-
return exists;
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
// Make sure to call from io queue by caller
|
|
367
|
-
- (BOOL)_diskImageDataExistsWithKey:(nullable NSString *)key {
|
|
368
|
-
if (!key) {
|
|
369
|
-
return NO;
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
return [self.diskCache containsDataForKey:key];
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
- (void)diskImageDataQueryForKey:(NSString *)key completion:(SDImageCacheQueryDataCompletionBlock)completionBlock {
|
|
376
|
-
dispatch_async(self.ioQueue, ^{
|
|
377
|
-
NSData *imageData = [self diskImageDataBySearchingAllPathsForKey:key];
|
|
378
|
-
if (completionBlock) {
|
|
379
|
-
dispatch_async(dispatch_get_main_queue(), ^{
|
|
380
|
-
completionBlock(imageData);
|
|
381
|
-
});
|
|
382
|
-
}
|
|
383
|
-
});
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
- (nullable NSData *)diskImageDataForKey:(nullable NSString *)key {
|
|
387
|
-
if (!key) {
|
|
388
|
-
return nil;
|
|
389
|
-
}
|
|
390
|
-
__block NSData *imageData = nil;
|
|
391
|
-
dispatch_sync(self.ioQueue, ^{
|
|
392
|
-
imageData = [self diskImageDataBySearchingAllPathsForKey:key];
|
|
393
|
-
});
|
|
394
|
-
|
|
395
|
-
return imageData;
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
- (nullable UIImage *)imageFromMemoryCacheForKey:(nullable NSString *)key {
|
|
399
|
-
return [self.memoryCache objectForKey:key];
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
- (nullable UIImage *)imageFromDiskCacheForKey:(nullable NSString *)key {
|
|
403
|
-
return [self imageFromDiskCacheForKey:key options:0 context:nil];
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
- (nullable UIImage *)imageFromDiskCacheForKey:(nullable NSString *)key options:(SDImageCacheOptions)options context:(nullable SDWebImageContext *)context {
|
|
407
|
-
NSData *data = [self diskImageDataForKey:key];
|
|
408
|
-
UIImage *diskImage = [self diskImageForKey:key data:data options:options context:context];
|
|
409
|
-
|
|
410
|
-
BOOL shouldCacheToMomery = YES;
|
|
411
|
-
if (context[SDWebImageContextStoreCacheType]) {
|
|
412
|
-
SDImageCacheType cacheType = [context[SDWebImageContextStoreCacheType] integerValue];
|
|
413
|
-
shouldCacheToMomery = (cacheType == SDImageCacheTypeAll || cacheType == SDImageCacheTypeMemory);
|
|
414
|
-
}
|
|
415
|
-
CGSize thumbnailSize = CGSizeZero;
|
|
416
|
-
NSValue *thumbnailSizeValue = context[SDWebImageContextImageThumbnailPixelSize];
|
|
417
|
-
if (thumbnailSizeValue != nil) {
|
|
418
|
-
#if SD_MAC
|
|
419
|
-
thumbnailSize = thumbnailSizeValue.sizeValue;
|
|
420
|
-
#else
|
|
421
|
-
thumbnailSize = thumbnailSizeValue.CGSizeValue;
|
|
422
|
-
#endif
|
|
423
|
-
}
|
|
424
|
-
if (thumbnailSize.width > 0 && thumbnailSize.height > 0) {
|
|
425
|
-
// Query full size cache key which generate a thumbnail, should not write back to full size memory cache
|
|
426
|
-
shouldCacheToMomery = NO;
|
|
427
|
-
}
|
|
428
|
-
if (shouldCacheToMomery && diskImage && self.config.shouldCacheImagesInMemory) {
|
|
429
|
-
NSUInteger cost = diskImage.sd_memoryCost;
|
|
430
|
-
[self.memoryCache setObject:diskImage forKey:key cost:cost];
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
return diskImage;
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
- (nullable UIImage *)imageFromCacheForKey:(nullable NSString *)key {
|
|
437
|
-
return [self imageFromCacheForKey:key options:0 context:nil];
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
- (nullable UIImage *)imageFromCacheForKey:(nullable NSString *)key options:(SDImageCacheOptions)options context:(nullable SDWebImageContext *)context {
|
|
441
|
-
// First check the in-memory cache...
|
|
442
|
-
UIImage *image = [self imageFromMemoryCacheForKey:key];
|
|
443
|
-
if (image) {
|
|
444
|
-
if (options & SDImageCacheDecodeFirstFrameOnly) {
|
|
445
|
-
// Ensure static image
|
|
446
|
-
if (image.sd_isAnimated) {
|
|
447
|
-
#if SD_MAC
|
|
448
|
-
image = [[NSImage alloc] initWithCGImage:image.CGImage scale:image.scale orientation:kCGImagePropertyOrientationUp];
|
|
449
|
-
#else
|
|
450
|
-
image = [[UIImage alloc] initWithCGImage:image.CGImage scale:image.scale orientation:image.imageOrientation];
|
|
451
|
-
#endif
|
|
452
|
-
}
|
|
453
|
-
} else if (options & SDImageCacheMatchAnimatedImageClass) {
|
|
454
|
-
// Check image class matching
|
|
455
|
-
Class animatedImageClass = image.class;
|
|
456
|
-
Class desiredImageClass = context[SDWebImageContextAnimatedImageClass];
|
|
457
|
-
if (desiredImageClass && ![animatedImageClass isSubclassOfClass:desiredImageClass]) {
|
|
458
|
-
image = nil;
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
// Since we don't need to query imageData, return image if exist
|
|
464
|
-
if (image) {
|
|
465
|
-
return image;
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
// Second check the disk cache...
|
|
469
|
-
image = [self imageFromDiskCacheForKey:key options:options context:context];
|
|
470
|
-
return image;
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
- (nullable NSData *)diskImageDataBySearchingAllPathsForKey:(nullable NSString *)key {
|
|
474
|
-
if (!key) {
|
|
475
|
-
return nil;
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
NSData *data = [self.diskCache dataForKey:key];
|
|
479
|
-
if (data) {
|
|
480
|
-
return data;
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
// Addtional cache path for custom pre-load cache
|
|
484
|
-
if (self.additionalCachePathBlock) {
|
|
485
|
-
NSString *filePath = self.additionalCachePathBlock(key);
|
|
486
|
-
if (filePath) {
|
|
487
|
-
data = [NSData dataWithContentsOfFile:filePath options:self.config.diskCacheReadingOptions error:nil];
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
return data;
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
- (nullable UIImage *)diskImageForKey:(nullable NSString *)key {
|
|
495
|
-
NSData *data = [self diskImageDataForKey:key];
|
|
496
|
-
return [self diskImageForKey:key data:data];
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
- (nullable UIImage *)diskImageForKey:(nullable NSString *)key data:(nullable NSData *)data {
|
|
500
|
-
return [self diskImageForKey:key data:data options:0 context:nil];
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
- (nullable UIImage *)diskImageForKey:(nullable NSString *)key data:(nullable NSData *)data options:(SDImageCacheOptions)options context:(SDWebImageContext *)context {
|
|
504
|
-
if (!data) {
|
|
505
|
-
return nil;
|
|
506
|
-
}
|
|
507
|
-
UIImage *image = SDImageCacheDecodeImageData(data, key, [[self class] imageOptionsFromCacheOptions:options], context);
|
|
508
|
-
[self _unarchiveObjectWithImage:image forKey:key];
|
|
509
|
-
return image;
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
- (void)_unarchiveObjectWithImage:(UIImage *)image forKey:(NSString *)key {
|
|
513
|
-
if (!image) {
|
|
514
|
-
return;
|
|
515
|
-
}
|
|
516
|
-
// Check extended data
|
|
517
|
-
NSData *extendedData = [self.diskCache extendedDataForKey:key];
|
|
518
|
-
if (!extendedData) {
|
|
519
|
-
return;
|
|
520
|
-
}
|
|
521
|
-
id extendedObject;
|
|
522
|
-
if (@available(iOS 11, tvOS 11, macOS 10.13, watchOS 4, *)) {
|
|
523
|
-
NSError *error;
|
|
524
|
-
NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingFromData:extendedData error:&error];
|
|
525
|
-
unarchiver.requiresSecureCoding = NO;
|
|
526
|
-
extendedObject = [unarchiver decodeTopLevelObjectForKey:NSKeyedArchiveRootObjectKey error:&error];
|
|
527
|
-
if (error) {
|
|
528
|
-
NSLog(@"NSKeyedUnarchiver unarchive failed with error: %@", error);
|
|
529
|
-
}
|
|
530
|
-
} else {
|
|
531
|
-
@try {
|
|
532
|
-
#pragma clang diagnostic push
|
|
533
|
-
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
|
534
|
-
extendedObject = [NSKeyedUnarchiver unarchiveObjectWithData:extendedData];
|
|
535
|
-
#pragma clang diagnostic pop
|
|
536
|
-
} @catch (NSException *exception) {
|
|
537
|
-
NSLog(@"NSKeyedUnarchiver unarchive failed with exception: %@", exception);
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
image.sd_extendedObject = extendedObject;
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
- (nullable SDImageCacheToken *)queryCacheOperationForKey:(NSString *)key done:(SDImageCacheQueryCompletionBlock)doneBlock {
|
|
544
|
-
return [self queryCacheOperationForKey:key options:0 done:doneBlock];
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
- (nullable SDImageCacheToken *)queryCacheOperationForKey:(NSString *)key options:(SDImageCacheOptions)options done:(SDImageCacheQueryCompletionBlock)doneBlock {
|
|
548
|
-
return [self queryCacheOperationForKey:key options:options context:nil done:doneBlock];
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
- (nullable SDImageCacheToken *)queryCacheOperationForKey:(nullable NSString *)key options:(SDImageCacheOptions)options context:(nullable SDWebImageContext *)context done:(nullable SDImageCacheQueryCompletionBlock)doneBlock {
|
|
552
|
-
return [self queryCacheOperationForKey:key options:options context:context cacheType:SDImageCacheTypeAll done:doneBlock];
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
- (nullable SDImageCacheToken *)queryCacheOperationForKey:(nullable NSString *)key options:(SDImageCacheOptions)options context:(nullable SDWebImageContext *)context cacheType:(SDImageCacheType)queryCacheType done:(nullable SDImageCacheQueryCompletionBlock)doneBlock {
|
|
556
|
-
if (!key) {
|
|
557
|
-
if (doneBlock) {
|
|
558
|
-
doneBlock(nil, nil, SDImageCacheTypeNone);
|
|
559
|
-
}
|
|
560
|
-
return nil;
|
|
561
|
-
}
|
|
562
|
-
// Invalid cache type
|
|
563
|
-
if (queryCacheType == SDImageCacheTypeNone) {
|
|
564
|
-
if (doneBlock) {
|
|
565
|
-
doneBlock(nil, nil, SDImageCacheTypeNone);
|
|
566
|
-
}
|
|
567
|
-
return nil;
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
// First check the in-memory cache...
|
|
571
|
-
UIImage *image;
|
|
572
|
-
if (queryCacheType != SDImageCacheTypeDisk) {
|
|
573
|
-
image = [self imageFromMemoryCacheForKey:key];
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
if (image) {
|
|
577
|
-
if (options & SDImageCacheDecodeFirstFrameOnly) {
|
|
578
|
-
// Ensure static image
|
|
579
|
-
if (image.sd_isAnimated) {
|
|
580
|
-
#if SD_MAC
|
|
581
|
-
image = [[NSImage alloc] initWithCGImage:image.CGImage scale:image.scale orientation:kCGImagePropertyOrientationUp];
|
|
582
|
-
#else
|
|
583
|
-
image = [[UIImage alloc] initWithCGImage:image.CGImage scale:image.scale orientation:image.imageOrientation];
|
|
584
|
-
#endif
|
|
585
|
-
}
|
|
586
|
-
} else if (options & SDImageCacheMatchAnimatedImageClass) {
|
|
587
|
-
// Check image class matching
|
|
588
|
-
Class animatedImageClass = image.class;
|
|
589
|
-
Class desiredImageClass = context[SDWebImageContextAnimatedImageClass];
|
|
590
|
-
if (desiredImageClass && ![animatedImageClass isSubclassOfClass:desiredImageClass]) {
|
|
591
|
-
image = nil;
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
BOOL shouldQueryMemoryOnly = (queryCacheType == SDImageCacheTypeMemory) || (image && !(options & SDImageCacheQueryMemoryData));
|
|
597
|
-
if (shouldQueryMemoryOnly) {
|
|
598
|
-
if (doneBlock) {
|
|
599
|
-
doneBlock(image, nil, SDImageCacheTypeMemory);
|
|
600
|
-
}
|
|
601
|
-
return nil;
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
// Second check the disk cache...
|
|
605
|
-
SDImageCacheToken *operation = [[SDImageCacheToken alloc] initWithDoneBlock:doneBlock];
|
|
606
|
-
operation.key = key;
|
|
607
|
-
// Check whether we need to synchronously query disk
|
|
608
|
-
// 1. in-memory cache hit & memoryDataSync
|
|
609
|
-
// 2. in-memory cache miss & diskDataSync
|
|
610
|
-
BOOL shouldQueryDiskSync = ((image && options & SDImageCacheQueryMemoryDataSync) ||
|
|
611
|
-
(!image && options & SDImageCacheQueryDiskDataSync));
|
|
612
|
-
NSData* (^queryDiskDataBlock)(void) = ^NSData* {
|
|
613
|
-
@synchronized (operation) {
|
|
614
|
-
if (operation.isCancelled) {
|
|
615
|
-
return nil;
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
return [self diskImageDataBySearchingAllPathsForKey:key];
|
|
620
|
-
};
|
|
621
|
-
|
|
622
|
-
UIImage* (^queryDiskImageBlock)(NSData*) = ^UIImage*(NSData* diskData) {
|
|
623
|
-
@synchronized (operation) {
|
|
624
|
-
if (operation.isCancelled) {
|
|
625
|
-
return nil;
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
UIImage *diskImage;
|
|
630
|
-
if (image) {
|
|
631
|
-
// the image is from in-memory cache, but need image data
|
|
632
|
-
diskImage = image;
|
|
633
|
-
} else if (diskData) {
|
|
634
|
-
BOOL shouldCacheToMomery = YES;
|
|
635
|
-
if (context[SDWebImageContextStoreCacheType]) {
|
|
636
|
-
SDImageCacheType cacheType = [context[SDWebImageContextStoreCacheType] integerValue];
|
|
637
|
-
shouldCacheToMomery = (cacheType == SDImageCacheTypeAll || cacheType == SDImageCacheTypeMemory);
|
|
638
|
-
}
|
|
639
|
-
CGSize thumbnailSize = CGSizeZero;
|
|
640
|
-
NSValue *thumbnailSizeValue = context[SDWebImageContextImageThumbnailPixelSize];
|
|
641
|
-
if (thumbnailSizeValue != nil) {
|
|
642
|
-
#if SD_MAC
|
|
643
|
-
thumbnailSize = thumbnailSizeValue.sizeValue;
|
|
644
|
-
#else
|
|
645
|
-
thumbnailSize = thumbnailSizeValue.CGSizeValue;
|
|
646
|
-
#endif
|
|
647
|
-
}
|
|
648
|
-
if (thumbnailSize.width > 0 && thumbnailSize.height > 0) {
|
|
649
|
-
// Query full size cache key which generate a thumbnail, should not write back to full size memory cache
|
|
650
|
-
shouldCacheToMomery = NO;
|
|
651
|
-
}
|
|
652
|
-
// decode image data only if in-memory cache missed
|
|
653
|
-
diskImage = [self diskImageForKey:key data:diskData options:options context:context];
|
|
654
|
-
if (shouldCacheToMomery && diskImage && self.config.shouldCacheImagesInMemory) {
|
|
655
|
-
NSUInteger cost = diskImage.sd_memoryCost;
|
|
656
|
-
[self.memoryCache setObject:diskImage forKey:key cost:cost];
|
|
657
|
-
}
|
|
658
|
-
}
|
|
659
|
-
return diskImage;
|
|
660
|
-
};
|
|
661
|
-
|
|
662
|
-
// Query in ioQueue to keep IO-safe
|
|
663
|
-
if (shouldQueryDiskSync) {
|
|
664
|
-
__block NSData* diskData;
|
|
665
|
-
__block UIImage* diskImage;
|
|
666
|
-
dispatch_sync(self.ioQueue, ^{
|
|
667
|
-
diskData = queryDiskDataBlock();
|
|
668
|
-
diskImage = queryDiskImageBlock(diskData);
|
|
669
|
-
});
|
|
670
|
-
if (doneBlock) {
|
|
671
|
-
doneBlock(diskImage, diskData, SDImageCacheTypeDisk);
|
|
672
|
-
}
|
|
673
|
-
} else {
|
|
674
|
-
dispatch_async(self.ioQueue, ^{
|
|
675
|
-
NSData* diskData = queryDiskDataBlock();
|
|
676
|
-
UIImage* diskImage = queryDiskImageBlock(diskData);
|
|
677
|
-
@synchronized (operation) {
|
|
678
|
-
if (operation.isCancelled) {
|
|
679
|
-
return;
|
|
680
|
-
}
|
|
681
|
-
}
|
|
682
|
-
if (doneBlock) {
|
|
683
|
-
dispatch_async(dispatch_get_main_queue(), ^{
|
|
684
|
-
// Dispatch from IO queue to main queue need time, user may call cancel during the dispatch timing
|
|
685
|
-
// This check is here to avoid double callback (one is from `SDImageCacheToken` in sync)
|
|
686
|
-
@synchronized (operation) {
|
|
687
|
-
if (operation.isCancelled) {
|
|
688
|
-
return;
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
doneBlock(diskImage, diskData, SDImageCacheTypeDisk);
|
|
692
|
-
});
|
|
693
|
-
}
|
|
694
|
-
});
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
return operation;
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
#pragma mark - Remove Ops
|
|
701
|
-
|
|
702
|
-
- (void)removeImageForKey:(nullable NSString *)key withCompletion:(nullable SDWebImageNoParamsBlock)completion {
|
|
703
|
-
[self removeImageForKey:key fromDisk:YES withCompletion:completion];
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
- (void)removeImageForKey:(nullable NSString *)key fromDisk:(BOOL)fromDisk withCompletion:(nullable SDWebImageNoParamsBlock)completion {
|
|
707
|
-
[self removeImageForKey:key fromMemory:YES fromDisk:fromDisk withCompletion:completion];
|
|
708
|
-
}
|
|
709
|
-
|
|
710
|
-
- (void)removeImageForKey:(nullable NSString *)key fromMemory:(BOOL)fromMemory fromDisk:(BOOL)fromDisk withCompletion:(nullable SDWebImageNoParamsBlock)completion {
|
|
711
|
-
if (key == nil) {
|
|
712
|
-
return;
|
|
713
|
-
}
|
|
714
|
-
|
|
715
|
-
if (fromMemory && self.config.shouldCacheImagesInMemory) {
|
|
716
|
-
[self.memoryCache removeObjectForKey:key];
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
if (fromDisk) {
|
|
720
|
-
dispatch_async(self.ioQueue, ^{
|
|
721
|
-
[self.diskCache removeDataForKey:key];
|
|
722
|
-
|
|
723
|
-
if (completion) {
|
|
724
|
-
dispatch_async(dispatch_get_main_queue(), ^{
|
|
725
|
-
completion();
|
|
726
|
-
});
|
|
727
|
-
}
|
|
728
|
-
});
|
|
729
|
-
} else if (completion) {
|
|
730
|
-
completion();
|
|
731
|
-
}
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
- (void)removeImageFromMemoryForKey:(NSString *)key {
|
|
735
|
-
if (!key) {
|
|
736
|
-
return;
|
|
737
|
-
}
|
|
738
|
-
|
|
739
|
-
[self.memoryCache removeObjectForKey:key];
|
|
740
|
-
}
|
|
741
|
-
|
|
742
|
-
- (void)removeImageFromDiskForKey:(NSString *)key {
|
|
743
|
-
if (!key) {
|
|
744
|
-
return;
|
|
745
|
-
}
|
|
746
|
-
dispatch_sync(self.ioQueue, ^{
|
|
747
|
-
[self _removeImageFromDiskForKey:key];
|
|
748
|
-
});
|
|
749
|
-
}
|
|
750
|
-
|
|
751
|
-
// Make sure to call from io queue by caller
|
|
752
|
-
- (void)_removeImageFromDiskForKey:(NSString *)key {
|
|
753
|
-
if (!key) {
|
|
754
|
-
return;
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
[self.diskCache removeDataForKey:key];
|
|
758
|
-
}
|
|
759
|
-
|
|
760
|
-
#pragma mark - Cache clean Ops
|
|
761
|
-
|
|
762
|
-
- (void)clearMemory {
|
|
763
|
-
[self.memoryCache removeAllObjects];
|
|
764
|
-
}
|
|
765
|
-
|
|
766
|
-
- (void)clearDiskOnCompletion:(nullable SDWebImageNoParamsBlock)completion {
|
|
767
|
-
dispatch_async(self.ioQueue, ^{
|
|
768
|
-
[self.diskCache removeAllData];
|
|
769
|
-
if (completion) {
|
|
770
|
-
dispatch_async(dispatch_get_main_queue(), ^{
|
|
771
|
-
completion();
|
|
772
|
-
});
|
|
773
|
-
}
|
|
774
|
-
});
|
|
775
|
-
}
|
|
776
|
-
|
|
777
|
-
- (void)deleteOldFilesWithCompletionBlock:(nullable SDWebImageNoParamsBlock)completionBlock {
|
|
778
|
-
dispatch_async(self.ioQueue, ^{
|
|
779
|
-
[self.diskCache removeExpiredData];
|
|
780
|
-
if (completionBlock) {
|
|
781
|
-
dispatch_async(dispatch_get_main_queue(), ^{
|
|
782
|
-
completionBlock();
|
|
783
|
-
});
|
|
784
|
-
}
|
|
785
|
-
});
|
|
786
|
-
}
|
|
787
|
-
|
|
788
|
-
#pragma mark - UIApplicationWillTerminateNotification
|
|
789
|
-
|
|
790
|
-
#if SD_UIKIT || SD_MAC
|
|
791
|
-
- (void)applicationWillTerminate:(NSNotification *)notification {
|
|
792
|
-
// On iOS/macOS, the async opeartion to remove exipred data will be terminated quickly
|
|
793
|
-
// Try using the sync operation to ensure we reomve the exipred data
|
|
794
|
-
if (!self.config.shouldRemoveExpiredDataWhenTerminate) {
|
|
795
|
-
return;
|
|
796
|
-
}
|
|
797
|
-
dispatch_sync(self.ioQueue, ^{
|
|
798
|
-
[self.diskCache removeExpiredData];
|
|
799
|
-
});
|
|
800
|
-
}
|
|
801
|
-
#endif
|
|
802
|
-
|
|
803
|
-
#pragma mark - UIApplicationDidEnterBackgroundNotification
|
|
804
|
-
|
|
805
|
-
#if SD_UIKIT
|
|
806
|
-
- (void)applicationDidEnterBackground:(NSNotification *)notification {
|
|
807
|
-
if (!self.config.shouldRemoveExpiredDataWhenEnterBackground) {
|
|
808
|
-
return;
|
|
809
|
-
}
|
|
810
|
-
Class UIApplicationClass = NSClassFromString(@"UIApplication");
|
|
811
|
-
if(!UIApplicationClass || ![UIApplicationClass respondsToSelector:@selector(sharedApplication)]) {
|
|
812
|
-
return;
|
|
813
|
-
}
|
|
814
|
-
UIApplication *application = [UIApplication performSelector:@selector(sharedApplication)];
|
|
815
|
-
__block UIBackgroundTaskIdentifier bgTask = [application beginBackgroundTaskWithExpirationHandler:^{
|
|
816
|
-
// Clean up any unfinished task business by marking where you
|
|
817
|
-
// stopped or ending the task outright.
|
|
818
|
-
[application endBackgroundTask:bgTask];
|
|
819
|
-
bgTask = UIBackgroundTaskInvalid;
|
|
820
|
-
}];
|
|
821
|
-
|
|
822
|
-
// Start the long-running task and return immediately.
|
|
823
|
-
[self deleteOldFilesWithCompletionBlock:^{
|
|
824
|
-
[application endBackgroundTask:bgTask];
|
|
825
|
-
bgTask = UIBackgroundTaskInvalid;
|
|
826
|
-
}];
|
|
827
|
-
}
|
|
828
|
-
#endif
|
|
829
|
-
|
|
830
|
-
#pragma mark - Cache Info
|
|
831
|
-
|
|
832
|
-
- (NSUInteger)totalDiskSize {
|
|
833
|
-
__block NSUInteger size = 0;
|
|
834
|
-
dispatch_sync(self.ioQueue, ^{
|
|
835
|
-
size = [self.diskCache totalSize];
|
|
836
|
-
});
|
|
837
|
-
return size;
|
|
838
|
-
}
|
|
839
|
-
|
|
840
|
-
- (NSUInteger)totalDiskCount {
|
|
841
|
-
__block NSUInteger count = 0;
|
|
842
|
-
dispatch_sync(self.ioQueue, ^{
|
|
843
|
-
count = [self.diskCache totalCount];
|
|
844
|
-
});
|
|
845
|
-
return count;
|
|
846
|
-
}
|
|
847
|
-
|
|
848
|
-
- (void)calculateSizeWithCompletionBlock:(nullable SDImageCacheCalculateSizeBlock)completionBlock {
|
|
849
|
-
dispatch_async(self.ioQueue, ^{
|
|
850
|
-
NSUInteger fileCount = [self.diskCache totalCount];
|
|
851
|
-
NSUInteger totalSize = [self.diskCache totalSize];
|
|
852
|
-
if (completionBlock) {
|
|
853
|
-
dispatch_async(dispatch_get_main_queue(), ^{
|
|
854
|
-
completionBlock(fileCount, totalSize);
|
|
855
|
-
});
|
|
856
|
-
}
|
|
857
|
-
});
|
|
858
|
-
}
|
|
859
|
-
|
|
860
|
-
#pragma mark - Helper
|
|
861
|
-
+ (SDWebImageOptions)imageOptionsFromCacheOptions:(SDImageCacheOptions)cacheOptions {
|
|
862
|
-
SDWebImageOptions options = 0;
|
|
863
|
-
if (cacheOptions & SDImageCacheScaleDownLargeImages) options |= SDWebImageScaleDownLargeImages;
|
|
864
|
-
if (cacheOptions & SDImageCacheDecodeFirstFrameOnly) options |= SDWebImageDecodeFirstFrameOnly;
|
|
865
|
-
if (cacheOptions & SDImageCachePreloadAllFrames) options |= SDWebImagePreloadAllFrames;
|
|
866
|
-
if (cacheOptions & SDImageCacheAvoidDecodeImage) options |= SDWebImageAvoidDecodeImage;
|
|
867
|
-
if (cacheOptions & SDImageCacheMatchAnimatedImageClass) options |= SDWebImageMatchAnimatedImageClass;
|
|
868
|
-
|
|
869
|
-
return options;
|
|
870
|
-
}
|
|
871
|
-
|
|
872
|
-
@end
|
|
873
|
-
|
|
874
|
-
@implementation SDImageCache (SDImageCache)
|
|
875
|
-
|
|
876
|
-
#pragma mark - SDImageCache
|
|
877
|
-
|
|
878
|
-
- (id<SDWebImageOperation>)queryImageForKey:(NSString *)key options:(SDWebImageOptions)options context:(nullable SDWebImageContext *)context completion:(nullable SDImageCacheQueryCompletionBlock)completionBlock {
|
|
879
|
-
return [self queryImageForKey:key options:options context:context cacheType:SDImageCacheTypeAll completion:completionBlock];
|
|
880
|
-
}
|
|
881
|
-
|
|
882
|
-
- (id<SDWebImageOperation>)queryImageForKey:(NSString *)key options:(SDWebImageOptions)options context:(nullable SDWebImageContext *)context cacheType:(SDImageCacheType)cacheType completion:(nullable SDImageCacheQueryCompletionBlock)completionBlock {
|
|
883
|
-
SDImageCacheOptions cacheOptions = 0;
|
|
884
|
-
if (options & SDWebImageQueryMemoryData) cacheOptions |= SDImageCacheQueryMemoryData;
|
|
885
|
-
if (options & SDWebImageQueryMemoryDataSync) cacheOptions |= SDImageCacheQueryMemoryDataSync;
|
|
886
|
-
if (options & SDWebImageQueryDiskDataSync) cacheOptions |= SDImageCacheQueryDiskDataSync;
|
|
887
|
-
if (options & SDWebImageScaleDownLargeImages) cacheOptions |= SDImageCacheScaleDownLargeImages;
|
|
888
|
-
if (options & SDWebImageAvoidDecodeImage) cacheOptions |= SDImageCacheAvoidDecodeImage;
|
|
889
|
-
if (options & SDWebImageDecodeFirstFrameOnly) cacheOptions |= SDImageCacheDecodeFirstFrameOnly;
|
|
890
|
-
if (options & SDWebImagePreloadAllFrames) cacheOptions |= SDImageCachePreloadAllFrames;
|
|
891
|
-
if (options & SDWebImageMatchAnimatedImageClass) cacheOptions |= SDImageCacheMatchAnimatedImageClass;
|
|
892
|
-
|
|
893
|
-
return [self queryCacheOperationForKey:key options:cacheOptions context:context cacheType:cacheType done:completionBlock];
|
|
894
|
-
}
|
|
895
|
-
|
|
896
|
-
- (void)storeImage:(UIImage *)image imageData:(NSData *)imageData forKey:(nullable NSString *)key cacheType:(SDImageCacheType)cacheType completion:(nullable SDWebImageNoParamsBlock)completionBlock {
|
|
897
|
-
switch (cacheType) {
|
|
898
|
-
case SDImageCacheTypeNone: {
|
|
899
|
-
[self storeImage:image imageData:imageData forKey:key toMemory:NO toDisk:NO completion:completionBlock];
|
|
900
|
-
}
|
|
901
|
-
break;
|
|
902
|
-
case SDImageCacheTypeMemory: {
|
|
903
|
-
[self storeImage:image imageData:imageData forKey:key toMemory:YES toDisk:NO completion:completionBlock];
|
|
904
|
-
}
|
|
905
|
-
break;
|
|
906
|
-
case SDImageCacheTypeDisk: {
|
|
907
|
-
[self storeImage:image imageData:imageData forKey:key toMemory:NO toDisk:YES completion:completionBlock];
|
|
908
|
-
}
|
|
909
|
-
break;
|
|
910
|
-
case SDImageCacheTypeAll: {
|
|
911
|
-
[self storeImage:image imageData:imageData forKey:key toMemory:YES toDisk:YES completion:completionBlock];
|
|
912
|
-
}
|
|
913
|
-
break;
|
|
914
|
-
default: {
|
|
915
|
-
if (completionBlock) {
|
|
916
|
-
completionBlock();
|
|
917
|
-
}
|
|
918
|
-
}
|
|
919
|
-
break;
|
|
920
|
-
}
|
|
921
|
-
}
|
|
922
|
-
|
|
923
|
-
- (void)removeImageForKey:(NSString *)key cacheType:(SDImageCacheType)cacheType completion:(nullable SDWebImageNoParamsBlock)completionBlock {
|
|
924
|
-
switch (cacheType) {
|
|
925
|
-
case SDImageCacheTypeNone: {
|
|
926
|
-
[self removeImageForKey:key fromMemory:NO fromDisk:NO withCompletion:completionBlock];
|
|
927
|
-
}
|
|
928
|
-
break;
|
|
929
|
-
case SDImageCacheTypeMemory: {
|
|
930
|
-
[self removeImageForKey:key fromMemory:YES fromDisk:NO withCompletion:completionBlock];
|
|
931
|
-
}
|
|
932
|
-
break;
|
|
933
|
-
case SDImageCacheTypeDisk: {
|
|
934
|
-
[self removeImageForKey:key fromMemory:NO fromDisk:YES withCompletion:completionBlock];
|
|
935
|
-
}
|
|
936
|
-
break;
|
|
937
|
-
case SDImageCacheTypeAll: {
|
|
938
|
-
[self removeImageForKey:key fromMemory:YES fromDisk:YES withCompletion:completionBlock];
|
|
939
|
-
}
|
|
940
|
-
break;
|
|
941
|
-
default: {
|
|
942
|
-
if (completionBlock) {
|
|
943
|
-
completionBlock();
|
|
944
|
-
}
|
|
945
|
-
}
|
|
946
|
-
break;
|
|
947
|
-
}
|
|
948
|
-
}
|
|
949
|
-
|
|
950
|
-
- (void)containsImageForKey:(NSString *)key cacheType:(SDImageCacheType)cacheType completion:(nullable SDImageCacheContainsCompletionBlock)completionBlock {
|
|
951
|
-
switch (cacheType) {
|
|
952
|
-
case SDImageCacheTypeNone: {
|
|
953
|
-
if (completionBlock) {
|
|
954
|
-
completionBlock(SDImageCacheTypeNone);
|
|
955
|
-
}
|
|
956
|
-
}
|
|
957
|
-
break;
|
|
958
|
-
case SDImageCacheTypeMemory: {
|
|
959
|
-
BOOL isInMemoryCache = ([self imageFromMemoryCacheForKey:key] != nil);
|
|
960
|
-
if (completionBlock) {
|
|
961
|
-
completionBlock(isInMemoryCache ? SDImageCacheTypeMemory : SDImageCacheTypeNone);
|
|
962
|
-
}
|
|
963
|
-
}
|
|
964
|
-
break;
|
|
965
|
-
case SDImageCacheTypeDisk: {
|
|
966
|
-
[self diskImageExistsWithKey:key completion:^(BOOL isInDiskCache) {
|
|
967
|
-
if (completionBlock) {
|
|
968
|
-
completionBlock(isInDiskCache ? SDImageCacheTypeDisk : SDImageCacheTypeNone);
|
|
969
|
-
}
|
|
970
|
-
}];
|
|
971
|
-
}
|
|
972
|
-
break;
|
|
973
|
-
case SDImageCacheTypeAll: {
|
|
974
|
-
BOOL isInMemoryCache = ([self imageFromMemoryCacheForKey:key] != nil);
|
|
975
|
-
if (isInMemoryCache) {
|
|
976
|
-
if (completionBlock) {
|
|
977
|
-
completionBlock(SDImageCacheTypeMemory);
|
|
978
|
-
}
|
|
979
|
-
return;
|
|
980
|
-
}
|
|
981
|
-
[self diskImageExistsWithKey:key completion:^(BOOL isInDiskCache) {
|
|
982
|
-
if (completionBlock) {
|
|
983
|
-
completionBlock(isInDiskCache ? SDImageCacheTypeDisk : SDImageCacheTypeNone);
|
|
984
|
-
}
|
|
985
|
-
}];
|
|
986
|
-
}
|
|
987
|
-
break;
|
|
988
|
-
default:
|
|
989
|
-
if (completionBlock) {
|
|
990
|
-
completionBlock(SDImageCacheTypeNone);
|
|
991
|
-
}
|
|
992
|
-
break;
|
|
993
|
-
}
|
|
994
|
-
}
|
|
995
|
-
|
|
996
|
-
- (void)clearWithCacheType:(SDImageCacheType)cacheType completion:(SDWebImageNoParamsBlock)completionBlock {
|
|
997
|
-
switch (cacheType) {
|
|
998
|
-
case SDImageCacheTypeNone: {
|
|
999
|
-
if (completionBlock) {
|
|
1000
|
-
completionBlock();
|
|
1001
|
-
}
|
|
1002
|
-
}
|
|
1003
|
-
break;
|
|
1004
|
-
case SDImageCacheTypeMemory: {
|
|
1005
|
-
[self clearMemory];
|
|
1006
|
-
if (completionBlock) {
|
|
1007
|
-
completionBlock();
|
|
1008
|
-
}
|
|
1009
|
-
}
|
|
1010
|
-
break;
|
|
1011
|
-
case SDImageCacheTypeDisk: {
|
|
1012
|
-
[self clearDiskOnCompletion:completionBlock];
|
|
1013
|
-
}
|
|
1014
|
-
break;
|
|
1015
|
-
case SDImageCacheTypeAll: {
|
|
1016
|
-
[self clearMemory];
|
|
1017
|
-
[self clearDiskOnCompletion:completionBlock];
|
|
1018
|
-
}
|
|
1019
|
-
break;
|
|
1020
|
-
default: {
|
|
1021
|
-
if (completionBlock) {
|
|
1022
|
-
completionBlock();
|
|
1023
|
-
}
|
|
1024
|
-
}
|
|
1025
|
-
break;
|
|
1026
|
-
}
|
|
1027
|
-
}
|
|
1028
|
-
|
|
1029
|
-
@end
|
|
1030
|
-
|