forked from floraachy/ImageKnife
commit
db7f176084
|
@ -233,6 +233,39 @@ struct IndexFunctionDemo {
|
||||||
|
|
||||||
}.width('100%').height(60).backgroundColor(Color.Pink)
|
}.width('100%').height(60).backgroundColor(Color.Pink)
|
||||||
|
|
||||||
|
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
|
||||||
|
|
||||||
|
Button("大量照片和重复数据")
|
||||||
|
.onClick(() => {
|
||||||
|
console.log("pages/manyPhotoShowPage 页面跳转")
|
||||||
|
router.pushUrl({ url: "pages/manyPhotoShowPage" });
|
||||||
|
}).margin({ top: 15 })
|
||||||
|
Button("部分url测试")
|
||||||
|
.onClick(() => {
|
||||||
|
console.log("pages/tempUrlTestPage 页面跳转")
|
||||||
|
router.pushUrl({ url: "pages/tempUrlTestPage" });
|
||||||
|
}).margin({ top: 15 })
|
||||||
|
Button("测试drawFactory")
|
||||||
|
.onClick(() => {
|
||||||
|
console.log("pages/drawFactoryTestPage 页面跳转")
|
||||||
|
router.pushUrl({ url: "pages/drawFactoryTestPage" });
|
||||||
|
}).margin({ top: 15 })
|
||||||
|
|
||||||
|
}.width('100%').height(60).backgroundColor(Color.Pink)
|
||||||
|
|
||||||
|
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
|
||||||
|
Button("图片加载暂停和恢复")
|
||||||
|
.onClick(() => {
|
||||||
|
console.log("pages/photosPausedResumedPage 页面跳转")
|
||||||
|
router.pushUrl({ url: "pages/photosPausedResumedPage" });
|
||||||
|
}).margin({ top: 15 })
|
||||||
|
Button("List滑动时暂停图片加载,滑动结束恢复图片加载")
|
||||||
|
.onClick(() => {
|
||||||
|
console.log("pages/photosPausedResumedPage2 页面跳转")
|
||||||
|
router.pushUrl({ url: "pages/photosPausedResumedPage2" });
|
||||||
|
}).margin({ top: 15 })
|
||||||
|
}.width('100%').height(60).backgroundColor(Color.Pink)
|
||||||
|
|
||||||
Text("单帧gif测试").fontSize(15)
|
Text("单帧gif测试").fontSize(15)
|
||||||
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
|
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
|
||||||
Button("单帧gif测试")
|
Button("单帧gif测试")
|
||||||
|
|
|
@ -0,0 +1,104 @@
|
||||||
|
/*
|
||||||
|
* 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,ImageKnife} from '@ohos/libraryimageknife'
|
||||||
|
import {ImageKnifeOption} from '@ohos/libraryimageknife'
|
||||||
|
import {ImageKnifeGlobal} from '@ohos/libraryimageknife'
|
||||||
|
import {RotateImageTransformation} from '@ohos/libraryimageknife'
|
||||||
|
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('这个List通过监听: 开始滑动,停止加载图片;滑动结束,恢复加载图片')
|
||||||
|
.margin({top:10,bottom:5})
|
||||||
|
.onClick(()=>{
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
.onScrollStart(()=>{
|
||||||
|
let imageKnife:ImageKnife|undefined = ImageKnifeGlobal.getInstance().getImageKnife();
|
||||||
|
if(imageKnife!= undefined){
|
||||||
|
imageKnife.pauseRequests()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.onScrollStop(()=>{
|
||||||
|
let imageKnife:ImageKnife|undefined = ImageKnifeGlobal.getInstance().getImageKnife();
|
||||||
|
if(imageKnife!= undefined){
|
||||||
|
imageKnife.resumeRequests()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.listDirection(Axis.Horizontal)
|
||||||
|
.width('100%')
|
||||||
|
.height(72)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
aboutToDisappear(){
|
||||||
|
// 如果用户滑动过程中就退出了页面我们需要恢复图片加载能力
|
||||||
|
let imageKnife:ImageKnife|undefined = ImageKnifeGlobal.getInstance().getImageKnife();
|
||||||
|
if(imageKnife!= undefined){
|
||||||
|
imageKnife.resumeRequests()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
"pages/dataShareUriLoadPage",
|
"pages/dataShareUriLoadPage",
|
||||||
"pages/manyPhotoShowPage",
|
"pages/manyPhotoShowPage",
|
||||||
"pages/photosPausedResumedPage",
|
"pages/photosPausedResumedPage",
|
||||||
|
"pages/photosPausedResumedPage2",
|
||||||
"pages/tempUrlTestPage",
|
"pages/tempUrlTestPage",
|
||||||
"pages/drawFactoryTestPage",
|
"pages/drawFactoryTestPage",
|
||||||
"pages/testSingleFrameGifPage",
|
"pages/testSingleFrameGifPage",
|
||||||
|
|
|
@ -217,7 +217,6 @@ export class ImageKnife {
|
||||||
this.isPaused = true;
|
this.isPaused = true;
|
||||||
|
|
||||||
// 将未删除的所有request [run pend] 放入 [pause]
|
// 将未删除的所有request [run pend] 放入 [pause]
|
||||||
this.pausedMaps.clear()
|
|
||||||
LogUtil.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
|
||||||
|
|
Loading…
Reference in New Issue