1.新增hps 共享包library
Signed-off-by: zhoulisheng <635547767@qq.com>
This commit is contained in:
parent
219504ea8a
commit
1027156627
|
@ -37,6 +37,18 @@
|
|||
{
|
||||
"name": "gpu_transform",
|
||||
"srcPath": "./gpu_transform"
|
||||
},
|
||||
{
|
||||
"name": "library",
|
||||
"srcPath": "./library",
|
||||
"targets": [
|
||||
{
|
||||
"name": "default",
|
||||
"applyToProducts": [
|
||||
"default"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -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%')
|
||||
}
|
||||
}
|
|
@ -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%')
|
||||
|
|
|
@ -36,7 +36,7 @@ struct ManyPhotoShowPage {
|
|||
.onClick(()=>{
|
||||
let imageKnife = ImageKnifeGlobal.getInstance().getImageKnife();
|
||||
if(imageKnife!= undefined){
|
||||
imageKnife.pauseRequests()
|
||||
imageKnife.pauseRequest()
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
"pages/testSingleFrameGifPage",
|
||||
"pages/testGifLoadWithWorkerPage",
|
||||
"pages/OptionTestPage",
|
||||
"pages/SignatureTestPage"
|
||||
"pages/SignatureTestPage",
|
||||
"pages/hspCacheTestPage"
|
||||
]
|
||||
}
|
|
@ -212,7 +212,7 @@ export class ImageKnife {
|
|||
}
|
||||
|
||||
// 暂停所有请求
|
||||
async pauseRequests(): Promise<void> {
|
||||
async pauseRequest(): Promise<void> {
|
||||
await this.mutex.lock(async () => {
|
||||
this.isPaused = true;
|
||||
|
||||
|
|
Loading…
Reference in New Issue