diff --git a/build-profile.json5 b/build-profile.json5 index eca7ce7..fa5c415 100644 --- a/build-profile.json5 +++ b/build-profile.json5 @@ -8,12 +8,12 @@ "compatibleSdkVersion": 9 } ], - "buildModeSet":[ + "buildModeSet": [ { - "name":"debug" + "name": "debug" }, { - "name":"release" + "name": "release" } ] }, @@ -37,6 +37,18 @@ { "name": "gpu_transform", "srcPath": "./gpu_transform" + }, + { + "name": "library", + "srcPath": "./library", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] } ] } \ No newline at end of file diff --git a/entry/src/main/ets/pages/hspCacheTestPage.ets b/entry/src/main/ets/pages/hspCacheTestPage.ets new file mode 100644 index 0000000..f5a981c --- /dev/null +++ b/entry/src/main/ets/pages/hspCacheTestPage.ets @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2023 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, FileUtils } from '@ohos/imageknife' + +@Entry +@Component +struct Index { + + + @State imageOption1:ImageKnifeOption = { + loadSrc: $r('app.media.icon'), + + } + @State imageOption2:ImageKnifeOption = { + loadSrc: $r('app.media.icon'), + + } + @State imageOption3:ImageKnifeOption = { + loadSrc: $r('app.media.icon'), + + } + + build() { + Scroll() { + Column() { + Button('点击加载网络图片').onClick(()=>{ + this.imageOption2 = { + loadSrc: 'https://hbimg.huabanimg.com/cc6af25f8d782d3cf3122bef4e61571378271145735e9-vEVggB', + } + }) + ImageKnifeComponent({imageKnifeOption:this.imageOption2}).width(300).height(300).backgroundColor(Color.Pink) + + Button('点击加载本地文件').onClick(()=>{ + let path = globalThis.ImageKnife.getImageKnifeContext().filesDir+"/set.jpeg"; + FileUtils.getInstance().readFilePicAsync(path).then(buffer=>{ + this.imageOption3 = { + loadSrc: path + } + }) + + }) + ImageKnifeComponent({imageKnifeOption:this.imageOption3}).width(300).height(300).backgroundColor(Color.Pink) + + + + }.width('100%') + + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/imageknifeTestCaseIndex.ets b/entry/src/main/ets/pages/imageknifeTestCaseIndex.ets index 5683d4d..87a9c56 100644 --- a/entry/src/main/ets/pages/imageknifeTestCaseIndex.ets +++ b/entry/src/main/ets/pages/imageknifeTestCaseIndex.ets @@ -248,6 +248,26 @@ struct IndexFunctionDemo { router.pushUrl({ url: "pages/testGifLoadWithWorkerPage" }); }).margin({ top: 5, left: 3 }) }.width('100%').height(60).backgroundColor(Color.Pink) + Text("HSP相关测试").fontSize(15) + Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + + Button("进入HSP的library共享包") + .onClick(() => { + router.pushUrl({url:'@bundle:com.openharmony.imageknife/library/ets/pages/Index'}) + .then(()=>{ + console.log('push page suceess') + }).catch(err => { + console.log(`pushUrl failed, code is ${err.code}, message is ${err.message}`) + }) + }).margin({ top: 15 }) + Button("hsp加载后缓存情况,先点左侧按钮") + .onClick(() => { + console.log("pages/tempUrlTestPage 页面跳转") + router.pushUrl({ url: "pages/hspCacheTestPage" }); + }).margin({ top: 15 }) + + + }.width('100%').height(60).backgroundColor(Color.Pink) } } .width('100%') diff --git a/entry/src/main/ets/pages/manyPhotoShowPage.ets b/entry/src/main/ets/pages/manyPhotoShowPage.ets index c07919f..ed8d488 100644 --- a/entry/src/main/ets/pages/manyPhotoShowPage.ets +++ b/entry/src/main/ets/pages/manyPhotoShowPage.ets @@ -36,7 +36,7 @@ struct ManyPhotoShowPage { .onClick(()=>{ let imageKnife = ImageKnifeGlobal.getInstance().getImageKnife(); if(imageKnife!= undefined){ - imageKnife.pauseRequests() + imageKnife.pauseRequest() } }) diff --git a/entry/src/main/resources/base/profile/main_pages.json b/entry/src/main/resources/base/profile/main_pages.json index 87811b4..d387c99 100644 --- a/entry/src/main/resources/base/profile/main_pages.json +++ b/entry/src/main/resources/base/profile/main_pages.json @@ -31,6 +31,7 @@ "pages/testSingleFrameGifPage", "pages/testGifLoadWithWorkerPage", "pages/OptionTestPage", - "pages/SignatureTestPage" + "pages/SignatureTestPage", + "pages/hspCacheTestPage" ] } \ No newline at end of file diff --git a/imageknife/src/main/ets/components/imageknife/ImageKnife.ets b/imageknife/src/main/ets/components/imageknife/ImageKnife.ets index 3b9af37..03575be 100644 --- a/imageknife/src/main/ets/components/imageknife/ImageKnife.ets +++ b/imageknife/src/main/ets/components/imageknife/ImageKnife.ets @@ -212,7 +212,7 @@ export class ImageKnife { } // 暂停所有请求 - async pauseRequests(): Promise { + async pauseRequest(): Promise { await this.mutex.lock(async () => { this.isPaused = true;