!65 1.ImageKnife新增暂停加载全局接口,恢复加载全局接口。
Merge pull request !65 from zhoulisheng2/master
This commit is contained in:
commit
7ced243367
|
@ -3,7 +3,7 @@
|
||||||
"bundleName": "com.openharmony.imageknife",
|
"bundleName": "com.openharmony.imageknife",
|
||||||
"vendor": "example",
|
"vendor": "example",
|
||||||
"versionCode": 1000000,
|
"versionCode": 1000000,
|
||||||
"versionName": "2.1.1-rc.1",
|
"versionName": "2.1.1-rc.3",
|
||||||
"icon": "$media:app_icon",
|
"icon": "$media:app_icon",
|
||||||
"label": "$string:app_name",
|
"label": "$string:app_name",
|
||||||
"distributedNotificationEnabled": true
|
"distributedNotificationEnabled": true
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
## 2.1.1-rc.3
|
||||||
|
|
||||||
|
- 门面类ImageKnife新增pauseRequests接口,全局暂停请求
|
||||||
|
- 门面类ImageKnife新增resumeRequests接口,全局恢复暂停
|
||||||
|
|
||||||
## 2.1.1-rc.2
|
## 2.1.1-rc.2
|
||||||
|
|
||||||
- gif解码改为imageSource解码,不在对worker强依赖
|
- gif解码改为imageSource解码,不在对worker强依赖
|
||||||
|
|
12
README.md
12
README.md
|
@ -37,7 +37,7 @@ ohpm install @ohos/imageknife
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "",
|
"license": "",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ohos/imageknife": "^2.1.1-rc.1"
|
"@ohos/imageknife": "^2.1.1-rc.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -462,15 +462,17 @@ request.skipMemoryCache(true)
|
||||||
| skipMemoryCache(skip: boolean) | skip: boolean | 配置是否跳过内存缓存 |
|
| skipMemoryCache(skip: boolean) | skip: boolean | 配置是否跳过内存缓存 |
|
||||||
| retrieveDataFromCache(flag: boolean) | flag: boolean | 配置仅从缓存中加载数据 |
|
| retrieveDataFromCache(flag: boolean) | flag: boolean | 配置仅从缓存中加载数据 |
|
||||||
| signature | ObjectKey | 自定义key |
|
| signature | ObjectKey | 自定义key |
|
||||||
|
|
||||||
同时支持[图片变换相关](#图片变换相关)接口。
|
同时支持[图片变换相关](#图片变换相关)接口。
|
||||||
|
|
||||||
### ImageKnife 启动器/门面类
|
### ImageKnife 启动器/门面类
|
||||||
|
|
||||||
| 方法名 | 入参 | 接口描述 |
|
| 方法名 | 入参 | 接口描述 |
|
||||||
|---------------------------------|------------------------|-------------------|
|
| ------------------------------- | ---------------------- | ---------------------------------- |
|
||||||
| call(request: RequestOption) | request: RequestOption | 根据用户配置参数具体执行加载流程 |
|
| call(request: RequestOption) | request: RequestOption | 根据用户配置参数具体执行加载流程 |
|
||||||
| preload(request: RequestOption) | request: RequestOption | 根据用户配置参数具体执行预加载流程 |
|
| preload(request: RequestOption) | request: RequestOption | 根据用户配置参数具体执行预加载流程 |
|
||||||
|
| pauseRequests() | | 全局暂停请求 |
|
||||||
|
| resumeRequests() | | 全局恢复暂停 |
|
||||||
|
|
||||||
### 缓存策略相关
|
### 缓存策略相关
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
"name": "entry",
|
"name": "entry",
|
||||||
"description": "example description",
|
"description": "example description",
|
||||||
"repository": {},
|
"repository": {},
|
||||||
"version": "2.1.1-rc.1",
|
"version": "2.1.1-rc.3",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ohos/imageknife": "file:../imageknife",
|
"@ohos/imageknife": "file:../imageknife",
|
||||||
"@ohos/disklrucache": "^2.0.2-rc.0"
|
"@ohos/disklrucache": "^2.0.2-rc.0"
|
||||||
|
|
|
@ -220,6 +220,11 @@ struct IndexFunctionDemo {
|
||||||
console.log("pages/manyPhotoShowPage 页面跳转")
|
console.log("pages/manyPhotoShowPage 页面跳转")
|
||||||
router.pushUrl({ url: "pages/manyPhotoShowPage" });
|
router.pushUrl({ url: "pages/manyPhotoShowPage" });
|
||||||
}).margin({ top: 15 })
|
}).margin({ top: 15 })
|
||||||
|
Button("图片加载暂停和恢复")
|
||||||
|
.onClick(() => {
|
||||||
|
console.log("pages/manyPhotoShowPage 页面跳转")
|
||||||
|
router.pushUrl({ url: "pages/photosPausedResumedPage" });
|
||||||
|
}).margin({ top: 15 })
|
||||||
Button("部分url测试")
|
Button("部分url测试")
|
||||||
.onClick(() => {
|
.onClick(() => {
|
||||||
console.log("pages/tempUrlTestPage 页面跳转")
|
console.log("pages/tempUrlTestPage 页面跳转")
|
||||||
|
|
|
@ -31,36 +31,6 @@ struct ManyPhotoShowPage {
|
||||||
build() {
|
build() {
|
||||||
Column() {
|
Column() {
|
||||||
|
|
||||||
// Button('点击暂停加载')
|
|
||||||
// .margin({top:10,bottom:5})
|
|
||||||
// .onClick(()=>{
|
|
||||||
// let imageKnife = ImageKnifeGlobal.getInstance().getImageKnife();
|
|
||||||
// if(imageKnife!= undefined){
|
|
||||||
// imageKnife.pauseRequests()
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
//
|
|
||||||
// Button('点击重新加载')
|
|
||||||
// .margin({top:10,bottom:5})
|
|
||||||
// .onClick(()=>{
|
|
||||||
// let imageKnife = ImageKnifeGlobal.getInstance().getImageKnife();
|
|
||||||
// if(imageKnife!= undefined){
|
|
||||||
// imageKnife.resumeRequests()
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
//
|
|
||||||
// Button('设置磁盘存储为50M')
|
|
||||||
// .margin({top:10,bottom:5})
|
|
||||||
// .onClick(()=>{
|
|
||||||
// if(ImageKnifeGlobal.getInstance().getImageKnife() != undefined) {
|
|
||||||
// let disk: DiskLruCache | undefined = (ImageKnifeGlobal.getInstance().getImageKnife())?.getDiskMemoryCache();
|
|
||||||
// if(disk != undefined) {
|
|
||||||
// disk.setMaxSize(50 * 1024 * 1024)
|
|
||||||
// Prompt.showToast({ message: "设置成功" })
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
|
|
||||||
List({ space: 20, scroller: this.elementScroller }) {
|
List({ space: 20, scroller: this.elementScroller }) {
|
||||||
LazyForEach(this.data, (item: Material, index) => {
|
LazyForEach(this.data, (item: Material, index) => {
|
||||||
ListItem() {
|
ListItem() {
|
||||||
|
|
|
@ -0,0 +1,93 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2021 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, ScaleType} from '@ohos/imageknife'
|
||||||
|
import {ImageKnifeOption} from '@ohos/imageknife'
|
||||||
|
import {ImageKnifeGlobal} from '@ohos/imageknife'
|
||||||
|
import {RotateImageTransformation} from '@ohos/imageknife'
|
||||||
|
import {Material} from './model/Material'
|
||||||
|
import {TestDataSource} from './model/TestDataSource'
|
||||||
|
import {DiskLruCache} from '@ohos/disklrucache'
|
||||||
|
import ArkWorker from '@ohos.worker'
|
||||||
|
import Prompt from '@system.prompt'
|
||||||
|
@Entry
|
||||||
|
@Component
|
||||||
|
struct photosPausedResumedPage {
|
||||||
|
private data: TestDataSource = new TestDataSource();
|
||||||
|
|
||||||
|
private elementScroller: Scroller = new Scroller()
|
||||||
|
|
||||||
|
build() {
|
||||||
|
Column() {
|
||||||
|
|
||||||
|
Button('点击暂停加载')
|
||||||
|
.margin({top:10,bottom:5})
|
||||||
|
.onClick(()=>{
|
||||||
|
let imageKnife = ImageKnifeGlobal.getInstance().getImageKnife();
|
||||||
|
if(imageKnife!= undefined){
|
||||||
|
imageKnife.pauseRequests()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
Button('点击重新加载')
|
||||||
|
.margin({top:10,bottom:5})
|
||||||
|
.onClick(()=>{
|
||||||
|
let imageKnife = ImageKnifeGlobal.getInstance().getImageKnife();
|
||||||
|
if(imageKnife!= undefined){
|
||||||
|
imageKnife.resumeRequests()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
List({ space: 20, scroller: this.elementScroller }) {
|
||||||
|
LazyForEach(this.data, (item: Material, index) => {
|
||||||
|
ListItem() {
|
||||||
|
Column() {
|
||||||
|
Stack({ alignContent: Alignment.BottomEnd }) {
|
||||||
|
// 滤镜图片
|
||||||
|
ImageKnifeComponent({ imageKnifeOption: {
|
||||||
|
loadSrc: item.thumbnail,
|
||||||
|
mainScaleType: ScaleType.FIT_XY,
|
||||||
|
} })
|
||||||
|
}
|
||||||
|
.width(56).height(56)
|
||||||
|
//滤镜标题
|
||||||
|
Text(item.name)
|
||||||
|
.fontSize(10)
|
||||||
|
.maxLines(1)
|
||||||
|
.fontColor(Color.White)
|
||||||
|
.textAlign(TextAlign.Center)
|
||||||
|
.layoutWeight(1)
|
||||||
|
.width('100%')
|
||||||
|
.backgroundColor(Color.Orange)
|
||||||
|
}
|
||||||
|
.width(56)
|
||||||
|
.height(72)
|
||||||
|
.clip(true)
|
||||||
|
.borderRadius(4)
|
||||||
|
}
|
||||||
|
}, (item: Material) => item.material_id)
|
||||||
|
}
|
||||||
|
.listDirection(Axis.Horizontal)
|
||||||
|
.width('100%')
|
||||||
|
.height(72)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
"pages/imageknifeTestCaseIndex",
|
"pages/imageknifeTestCaseIndex",
|
||||||
"pages/dataShareUriLoadPage",
|
"pages/dataShareUriLoadPage",
|
||||||
"pages/manyPhotoShowPage",
|
"pages/manyPhotoShowPage",
|
||||||
|
"pages/photosPausedResumedPage",
|
||||||
"pages/tempUrlTestPage",
|
"pages/tempUrlTestPage",
|
||||||
"pages/drawFactoryTestPage",
|
"pages/drawFactoryTestPage",
|
||||||
"pages/testSingleFrameGifPage",
|
"pages/testSingleFrameGifPage",
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
"main": "index.ets",
|
"main": "index.ets",
|
||||||
"repository": "https://gitee.com/openharmony-tpc/ImageKnife",
|
"repository": "https://gitee.com/openharmony-tpc/ImageKnife",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "2.1.1-rc.2",
|
"version": "2.1.1-rc.3",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ohos/disklrucache": "^2.0.2-rc.0",
|
"@ohos/disklrucache": "^2.0.2-rc.0",
|
||||||
"@ohos/svg": "^2.1.1-rc.0",
|
"@ohos/svg": "^2.1.1-rc.0",
|
||||||
|
|
|
@ -211,52 +211,52 @@ export class ImageKnife {
|
||||||
return this.parseSource(request);
|
return this.parseSource(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
// // 暂停所有请求
|
// 暂停所有请求
|
||||||
// async pauseRequests(): Promise<void> {
|
async pauseRequests(): Promise<void> {
|
||||||
// await this.mutex.lock(async () => {
|
await this.mutex.lock(async () => {
|
||||||
// this.isPaused = true;
|
this.isPaused = true;
|
||||||
//
|
|
||||||
// // 将未删除的所有request [run pend] 放入 [pause]
|
// 将未删除的所有request [run pend] 放入 [pause]
|
||||||
// this.pausedMaps.clear()
|
this.pausedMaps.clear()
|
||||||
// console.log('dodo pauseRequests start1 pausedMaps size=' + this.pausedMaps.size() + ' runMaps Size=' + this.runningMaps.size() + ' pendMaps Size=' + this.pendingMaps.size())
|
LogUtil.log('dodo pauseRequests start1 pausedMaps size=' + this.pausedMaps.size() + ' runMaps Size=' + this.runningMaps.size() + ' pendMaps Size=' + this.pendingMaps.size())
|
||||||
//
|
|
||||||
// // 将run存入pause
|
// 将run存入pause
|
||||||
// let runNode = this.runningMaps.getHead();
|
let runNode = this.runningMaps.getHead();
|
||||||
// while (runNode) {
|
while (runNode) {
|
||||||
// let request = runNode.value;
|
let request = runNode.value;
|
||||||
// this.pausedMaps.put(request.uuid, request)
|
this.pausedMaps.put(request.uuid, request)
|
||||||
// runNode = runNode.next;
|
runNode = runNode.next;
|
||||||
// }
|
}
|
||||||
// this.runningMaps.clear();
|
this.runningMaps.clear();
|
||||||
// console.log('dodo pauseRequests start2 pausedMaps size=' + this.pausedMaps.size() + ' runMaps Size=' + this.runningMaps.size() + ' pendMaps Size=' + this.pendingMaps.size())
|
LogUtil.log('dodo pauseRequests start2 pausedMaps size=' + this.pausedMaps.size() + ' runMaps Size=' + this.runningMaps.size() + ' pendMaps Size=' + this.pendingMaps.size())
|
||||||
//
|
|
||||||
// let pendNode = this.pendingMaps.getHead();
|
let pendNode = this.pendingMaps.getHead();
|
||||||
// while (pendNode) {
|
while (pendNode) {
|
||||||
// let request = pendNode.value;
|
let request = pendNode.value;
|
||||||
// this.pausedMaps.put(request.uuid, request)
|
this.pausedMaps.put(request.uuid, request)
|
||||||
// pendNode = pendNode.next
|
pendNode = pendNode.next
|
||||||
// }
|
}
|
||||||
// this.pendingMaps.clear()
|
this.pendingMaps.clear()
|
||||||
// console.log('dodo pauseRequests start3 pausedMaps size=' + this.pausedMaps.size() + ' runMaps Size=' + this.runningMaps.size() + ' pendMaps Size=' + this.pendingMaps.size())
|
LogUtil.log('dodo pauseRequests start3 pausedMaps size=' + this.pausedMaps.size() + ' runMaps Size=' + this.runningMaps.size() + ' pendMaps Size=' + this.pendingMaps.size())
|
||||||
// })
|
})
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// // 恢复所有被暂停的请求
|
// 恢复所有被暂停的请求
|
||||||
// async resumeRequests(): Promise<void> {
|
async resumeRequests(): Promise<void> {
|
||||||
// await this.mutex.lock(async () => {
|
await this.mutex.lock(async () => {
|
||||||
// this.isPaused = false;
|
this.isPaused = false;
|
||||||
// console.log('dodo resumeRequest start1 pausedMaps size=' + this.pausedMaps.size() + ' runMaps Size=' + this.runningMaps.size() + ' pendMaps Size=' + this.pendingMaps.size())
|
LogUtil.log('dodo resumeRequest start1 pausedMaps size=' + this.pausedMaps.size() + ' runMaps Size=' + this.runningMaps.size() + ' pendMaps Size=' + this.pendingMaps.size())
|
||||||
// // 重启了之后需要把paused 里面的所有request重新发送
|
// 重启了之后需要把paused 里面的所有request重新发送
|
||||||
// let headNode = this.pausedMaps.getHead();
|
let headNode = this.pausedMaps.getHead();
|
||||||
// while (headNode) {
|
while (headNode) {
|
||||||
// let request = headNode.value
|
let request = headNode.value
|
||||||
// this.loadCacheManager(request)
|
this.loadCacheManager(request)
|
||||||
// headNode = headNode.next
|
headNode = headNode.next
|
||||||
// }
|
}
|
||||||
// this.pausedMaps.clear()
|
this.pausedMaps.clear()
|
||||||
// console.log('dodo resumeRequest start1 pausedMaps size=' + this.pausedMaps.size() + ' runMaps Size=' + this.runningMaps.size() + ' pendMaps Size=' + this.pendingMaps.size())
|
LogUtil.log('dodo resumeRequest start1 pausedMaps size=' + this.pausedMaps.size() + ' runMaps Size=' + this.runningMaps.size() + ' pendMaps Size=' + this.pendingMaps.size())
|
||||||
// })
|
})
|
||||||
// }
|
}
|
||||||
|
|
||||||
// 删除 请求
|
// 删除 请求
|
||||||
remove(uuid: string) {
|
remove(uuid: string) {
|
||||||
|
|
|
@ -16,7 +16,7 @@ import {ImageKnife} from './ImageKnife'
|
||||||
import { DiskStrategy } from "../cache/diskstrategy/DiskStrategy"
|
import { DiskStrategy } from "../cache/diskstrategy/DiskStrategy"
|
||||||
import { AsyncCallback } from "../imageknife/interface/AsyncCallback"
|
import { AsyncCallback } from "../imageknife/interface/AsyncCallback"
|
||||||
import { AsyncSuccess } from "../imageknife/interface/AsyncSuccess"
|
import { AsyncSuccess } from "../imageknife/interface/AsyncSuccess"
|
||||||
import { IAllCacheInfoCallback } from "../imageknife/interface/IAllCacheInfoCallback"
|
import { IAllCacheInfoCallback } from "../imageknife/interface/IAllCacheInfoCallback"
|
||||||
import { AUTOMATIC } from "../cache/diskstrategy/enum/AUTOMATIC"
|
import { AUTOMATIC } from "../cache/diskstrategy/enum/AUTOMATIC"
|
||||||
import { BaseTransform } from "../imageknife/transform/BaseTransform"
|
import { BaseTransform } from "../imageknife/transform/BaseTransform"
|
||||||
import { RotateImageTransformation } from "../imageknife/transform/RotateImageTransformation"
|
import { RotateImageTransformation } from "../imageknife/transform/RotateImageTransformation"
|
||||||
|
|
|
@ -6,6 +6,6 @@
|
||||||
"name": "imageknife",
|
"name": "imageknife",
|
||||||
"description": "example description",
|
"description": "example description",
|
||||||
"repository": {},
|
"repository": {},
|
||||||
"version": "2.1.1-rc.1",
|
"version": "2.1.1-rc.3",
|
||||||
"dependencies": {}
|
"dependencies": {}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue