1.新增ImageKnife加载Resource来自不同的sharedlibrary的用例
Signed-off-by: zhoulisheng <635547767@qq.com>
This commit is contained in:
parent
46bef4514d
commit
6144949b86
|
@ -49,6 +49,18 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "sharedlibrary2",
|
||||||
|
"srcPath": "./sharedlibrary2",
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"name": "default",
|
||||||
|
"applyToProducts": [
|
||||||
|
"default"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -7,6 +7,7 @@
|
||||||
"version": "2.1.2-rc.3",
|
"version": "2.1.2-rc.3",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ohos/libraryimageknife": "file:../sharedlibrary",
|
"@ohos/libraryimageknife": "file:../sharedlibrary",
|
||||||
|
"@ohos/sharedlibrary2": "file:../sharedlibrary2",
|
||||||
"@ohos/disklrucache": "^2.0.2-rc.0",
|
"@ohos/disklrucache": "^2.0.2-rc.0",
|
||||||
"@ohos/imageknife": "file:../library"
|
"@ohos/imageknife": "file:../library"
|
||||||
}
|
}
|
||||||
|
|
|
@ -269,10 +269,14 @@ struct IndexFunctionDemo {
|
||||||
}).margin({ top: 15 })
|
}).margin({ top: 15 })
|
||||||
Button("hsp加载后缓存情况,先点左侧按钮")
|
Button("hsp加载后缓存情况,先点左侧按钮")
|
||||||
.onClick(() => {
|
.onClick(() => {
|
||||||
console.log("pages/tempUrlTestPage 页面跳转")
|
console.log("pages/hspCacheTestPage 页面跳转")
|
||||||
router.pushUrl({ url: "pages/hspCacheTestPage" });
|
router.pushUrl({ url: "pages/hspCacheTestPage" });
|
||||||
}).margin({ top: 15 })
|
}).margin({ top: 15 })
|
||||||
|
Button("不同的hsp资源加载")
|
||||||
|
.onClick(()=>{
|
||||||
|
console.log("pages/multiHspTestPage 页面跳转")
|
||||||
|
router.pushUrl({ url: "pages/multiHspTestPage" });
|
||||||
|
})
|
||||||
|
|
||||||
}.width('100%').height(60).backgroundColor(Color.Pink)
|
}.width('100%').height(60).backgroundColor(Color.Pink)
|
||||||
Text("测试图片加载稳定").fontSize(15)
|
Text("测试图片加载稳定").fontSize(15)
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
/*
|
||||||
|
* 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, ImageKnifeGlobal, GetRes1 } from '@ohos/libraryimageknife'
|
||||||
|
import common from '@ohos.app.ability.common'
|
||||||
|
import { GetRes2 } from '@ohos/sharedlibrary2'
|
||||||
|
|
||||||
|
@Entry
|
||||||
|
@Component
|
||||||
|
struct Index {
|
||||||
|
@State imageOption1: ImageKnifeOption = {
|
||||||
|
loadSrc: $r('app.media.icon'),
|
||||||
|
}
|
||||||
|
@State imageOption2: ImageKnifeOption = {
|
||||||
|
loadSrc: $r('app.media.icon'),
|
||||||
|
}
|
||||||
|
|
||||||
|
build() {
|
||||||
|
Scroll() {
|
||||||
|
Column() {
|
||||||
|
Button('点击HSP1主图,HSP2占位,无context').onClick(() => {
|
||||||
|
let mainRes = GetRes1.getSample1();
|
||||||
|
let placeholderRes = GetRes2.getSample2();
|
||||||
|
this.imageOption1 = {
|
||||||
|
loadSrc:mainRes,
|
||||||
|
placeholderSrc:placeholderRes
|
||||||
|
}
|
||||||
|
})
|
||||||
|
ImageKnifeComponent({ imageKnifeOption: this.imageOption1 }).width(300).height(300).backgroundColor(Color.Pink)
|
||||||
|
Button('点击HSP1主图,HSP2占位,有context ').onClick(() => {
|
||||||
|
let mainRes = GetRes1.getSample1();
|
||||||
|
let placeholderRes = GetRes2.getSample2();
|
||||||
|
this.imageOption2 = {
|
||||||
|
loadSrc:mainRes,
|
||||||
|
placeholderSrc:placeholderRes,
|
||||||
|
context:getContext(this) as common.UIAbilityContext
|
||||||
|
}
|
||||||
|
})
|
||||||
|
ImageKnifeComponent({ imageKnifeOption: this.imageOption2 }).width(300).height(300).backgroundColor(Color.Pink)
|
||||||
|
|
||||||
|
|
||||||
|
}.width('100%')
|
||||||
|
|
||||||
|
}
|
||||||
|
.width('100%')
|
||||||
|
.height('100%')
|
||||||
|
}
|
||||||
|
}
|
|
@ -32,6 +32,7 @@
|
||||||
"pages/OptionTestPage",
|
"pages/OptionTestPage",
|
||||||
"pages/SignatureTestPage",
|
"pages/SignatureTestPage",
|
||||||
"pages/hspCacheTestPage",
|
"pages/hspCacheTestPage",
|
||||||
|
"pages/multiHspTestPage",
|
||||||
"pages/testManyNetImageLoadWithPage",
|
"pages/testManyNetImageLoadWithPage",
|
||||||
"pages/testManyGifLoadWithPage",
|
"pages/testManyGifLoadWithPage",
|
||||||
"pages/testImageAntiAliasingWithPage"
|
"pages/testImageAntiAliasingWithPage"
|
||||||
|
|
|
@ -130,4 +130,6 @@ export { IDrawLifeCycle } from '@ohos/imageknife'
|
||||||
export { LogUtil } from '@ohos/imageknife'
|
export { LogUtil } from '@ohos/imageknife'
|
||||||
|
|
||||||
// 额外开放初始化ImageKnife的方法
|
// 额外开放初始化ImageKnife的方法
|
||||||
export {InitImageKnife} from '../ets/pages/InitImageKnife'
|
export {InitImageKnife} from '../ets/pages/InitImageKnife'
|
||||||
|
|
||||||
|
export {GetRes1} from '../ets/pages/GetRes1'
|
|
@ -0,0 +1,21 @@
|
||||||
|
/*
|
||||||
|
* 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 common from '@ohos.app.ability.common'
|
||||||
|
|
||||||
|
export class GetRes1{
|
||||||
|
static getSample1():Resource {
|
||||||
|
return $r('app.media.setting');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
/node_modules
|
||||||
|
/oh_modules
|
||||||
|
/.preview
|
||||||
|
/build
|
||||||
|
/.cxx
|
||||||
|
/.test
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"apiType": 'stageMode',
|
||||||
|
"buildOption": {
|
||||||
|
},
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"name": "default"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,2 @@
|
||||||
|
// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
|
||||||
|
module.exports = require('@ohos/hvigor-ohos-plugin').hspTasks
|
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"devDependencies": {},
|
||||||
|
"author": "",
|
||||||
|
"name": "sharedlibrary2",
|
||||||
|
"description": "Please describe the basic information.",
|
||||||
|
"main": "./src/main/ets/Index.ets",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"dependencies": {
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
export {GetRes2} from '../ets/pages/GetRes2'
|
|
@ -0,0 +1,21 @@
|
||||||
|
/*
|
||||||
|
* 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 common from '@ohos.app.ability.common'
|
||||||
|
|
||||||
|
export class GetRes2{
|
||||||
|
static getSample2():Resource {
|
||||||
|
return $r('app.media.icon_loading');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@Entry
|
||||||
|
@Component
|
||||||
|
struct Index {
|
||||||
|
|
||||||
|
|
||||||
|
build() {
|
||||||
|
Column(){
|
||||||
|
Text('Hello world')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"module": {
|
||||||
|
"name": "sharedlibrary2",
|
||||||
|
"type": "shared",
|
||||||
|
"description": "$string:shared_desc",
|
||||||
|
"deviceTypes": [
|
||||||
|
"default",
|
||||||
|
"tablet"
|
||||||
|
],
|
||||||
|
"deliveryWithInstall": true,
|
||||||
|
"pages": "$profile:main_pages"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"color": [
|
||||||
|
{
|
||||||
|
"name": "white",
|
||||||
|
"value": "#FFFFFF"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"string": [
|
||||||
|
{
|
||||||
|
"name": "shared_desc",
|
||||||
|
"value": "description"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 2.1 KiB |
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"src": [
|
||||||
|
"pages/Index"
|
||||||
|
]
|
||||||
|
}
|
Loading…
Reference in New Issue