更新说明:
1、优化了内存缓存策略,修复了内存缓存策略给布尔值不生效的问题 Signed-off-by: 明月清风 <2928139825@qq.com>
This commit is contained in:
parent
803b7c3bfe
commit
0d12aada09
|
@ -3,7 +3,7 @@
|
|||
"bundleName": "com.openharmony.imageknife",
|
||||
"vendor": "example",
|
||||
"versionCode": 1000000,
|
||||
"versionName": "2.0.4",
|
||||
"versionName": "2.0.5",
|
||||
"icon": "$media:app_icon",
|
||||
"label": "$string:app_name",
|
||||
"distributedNotificationEnabled": true
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
## 2.0.5
|
||||
|
||||
- 修复若干问题:
|
||||
|
||||
优化了内存缓存策略,修复了内存缓存策略给布尔值不生效的问题
|
||||
|
||||
## 2.0.4
|
||||
|
||||
- 修复若干问题:
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"name": "entry",
|
||||
"description": "example description",
|
||||
"repository": {},
|
||||
"version": "2.0.4",
|
||||
"version": "2.0.5",
|
||||
"dependencies": {
|
||||
"@ohos/imageknife": "file:../imageknife",
|
||||
"@ohos/disklrucache": "^2.0.0"
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { ImageKnifeComponent, ImageKnifeOption,NONE } from '@ohos/imageknife'
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct OptionTestPage {
|
||||
@State imageKnifeOption1: ImageKnifeOption =
|
||||
{
|
||||
loadSrc: $r('app.media.icon'),
|
||||
placeholderSrc: $r('app.media.icon_loading'),
|
||||
errorholderSrc: $r('app.media.icon_failed'),
|
||||
};
|
||||
@State imageKnifeOption2: ImageKnifeOption =
|
||||
{
|
||||
loadSrc: $r('app.media.icon'),
|
||||
placeholderSrc: $r('app.media.icon_loading'),
|
||||
errorholderSrc: $r('app.media.icon_failed')
|
||||
};
|
||||
|
||||
build() {
|
||||
Scroll() {
|
||||
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
|
||||
|
||||
Text("示例加载图片不进行缓存").fontSize(15)
|
||||
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
|
||||
Button("加载")
|
||||
.onClick(() => {
|
||||
this.imageKnifeOption1 = {
|
||||
loadSrc: 'https://img-blog.csdn.net/20140514114029140',
|
||||
placeholderSrc: $r('app.media.icon_loading'),
|
||||
errorholderSrc: $r('app.media.icon_failed'),
|
||||
onlyRetrieveFromCache: false,
|
||||
isCacheable: false,
|
||||
strategy: new NONE()
|
||||
}
|
||||
}).margin({ top: 5, left: 3 })
|
||||
ImageKnifeComponent({ imageKnifeOption: this.imageKnifeOption1 }).width(300).height(300)
|
||||
}.width('100%').backgroundColor(Color.Pink)
|
||||
|
||||
Text("示例:加载图片进行缓存").fontSize(15)
|
||||
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
|
||||
Button("加载")
|
||||
.onClick(() => {
|
||||
this.imageKnifeOption2 = {
|
||||
loadSrc: 'https://img-blog.csdn.net/20140514114029140',
|
||||
placeholderSrc: $r('app.media.icon_loading'),
|
||||
errorholderSrc: $r('app.media.icon_failed'),
|
||||
onlyRetrieveFromCache: true,
|
||||
isCacheable: true,
|
||||
strategy: new NONE()
|
||||
}
|
||||
}).margin({ top: 5, left: 3 })
|
||||
ImageKnifeComponent({ imageKnifeOption: this.imageKnifeOption2 }).width(300).height(300)
|
||||
}.width('100%').backgroundColor(Color.Pink)
|
||||
|
||||
|
||||
}
|
||||
|
||||
}.width('100%')
|
||||
.height('100%')
|
||||
|
||||
}
|
||||
}
|
|
@ -144,6 +144,11 @@ struct IndexFunctionDemo {
|
|||
console.log("加载媒体库uri")
|
||||
router.pushUrl({ url: "pages/dataShareUriLoadPage" });
|
||||
}).margin({ top: 5, left: 3 })
|
||||
Button("测试Option缓存是否生效")
|
||||
.onClick(() => {
|
||||
console.log("加载媒体库uri")
|
||||
router.pushUrl({ url: "pages/OptionTestPage" });
|
||||
}).margin({ top: 5, left: 3 })
|
||||
}.width('100%').height(60).backgroundColor(Color.Pink)
|
||||
|
||||
Text("测试pngj和裁剪").fontSize(15)
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
"pages/tempUrlTestPage",
|
||||
"pages/drawFactoryTestPage",
|
||||
"pages/testSingleFrameGifPage",
|
||||
"pages/testGifLoadWithWorkerPage"
|
||||
"pages/testGifLoadWithWorkerPage",
|
||||
"pages/OptionTestPage"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -14,7 +14,7 @@
|
|||
"main": "index.ets",
|
||||
"repository": "https://gitee.com/openharmony-tpc/ImageKnife",
|
||||
"type": "module",
|
||||
"version": "2.0.4",
|
||||
"version": "2.0.5",
|
||||
"dependencies": {
|
||||
"@ohos/disklrucache": "^2.0.0",
|
||||
"@ohos/svg": "^2.0.0",
|
||||
|
|
|
@ -33,7 +33,6 @@ export struct ImageKnifeComponent {
|
|||
private lastHeight: number = 0
|
||||
private currentWidth: number = 0
|
||||
private currentHeight: number = 0
|
||||
|
||||
// 定时器id
|
||||
private gifTimerId: number = 0
|
||||
// 完整gif播放时间
|
||||
|
@ -178,16 +177,20 @@ export struct ImageKnifeComponent {
|
|||
}
|
||||
|
||||
configCacheStrategy(request: RequestOption) {
|
||||
if (this.imageKnifeOption.onlyRetrieveFromCache) {
|
||||
if (this.imageKnifeOption.onlyRetrieveFromCache != null && this.imageKnifeOption.onlyRetrieveFromCache != undefined) {
|
||||
request.retrieveDataFromCache(this.imageKnifeOption.onlyRetrieveFromCache)
|
||||
}
|
||||
|
||||
request.skipMemoryCache(!this.imageKnifeOption.isCacheable)
|
||||
|
||||
if (this.imageKnifeOption.strategy) {
|
||||
if (this.imageKnifeOption.isCacheable != null && this.imageKnifeOption.isCacheable != undefined) {
|
||||
request.skipMemoryCache(!this.imageKnifeOption.isCacheable)
|
||||
console.log("内存缓存策略" + this.imageKnifeOption.isCacheable)
|
||||
}
|
||||
|
||||
|
||||
if (this.imageKnifeOption.strategy != null && this.imageKnifeOption.strategy != undefined) {
|
||||
request.diskCacheStrategy(this.imageKnifeOption.strategy)
|
||||
}
|
||||
if (this.imageKnifeOption.allCacheInfoCallback) {
|
||||
if (this.imageKnifeOption.allCacheInfoCallback != null && this.imageKnifeOption.allCacheInfoCallback != undefined) {
|
||||
request.addAllCacheInfoCallback(this.imageKnifeOption.allCacheInfoCallback)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,6 @@
|
|||
"name": "imageknife",
|
||||
"description": "example description",
|
||||
"repository": {},
|
||||
"version": "2.0.4",
|
||||
"version": "2.0.5",
|
||||
"dependencies": {}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue