forked from floraachy/ImageKnife
1.LogUtil add grade all print log;
2.clean others codecheck problems Signed-off-by: zhoulisheng1 <zhoulisheng1@huawei.com>
This commit is contained in:
parent
42ee70ec08
commit
884b06bb32
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License",
|
||||
* 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
|
||||
*
|
||||
|
|
|
@ -84,7 +84,7 @@ export struct ImageKnifeComponent {
|
|||
}
|
||||
private canvasHasReady:boolean = false;
|
||||
private firstDrawFlag:boolean = false;
|
||||
private onReadyNext:Function = undefined
|
||||
private onReadyNext:()=>void = undefined
|
||||
build() {
|
||||
Canvas(this.context)
|
||||
.width('100%')
|
||||
|
@ -98,7 +98,7 @@ export struct ImageKnifeComponent {
|
|||
// 前提:宽高值均有效,值>0. 条件1:当前宽高与上一次宽高不同 条件2:当前是第一次绘制
|
||||
if( (this.currentHeight != this.lastHeight || this.currentWidth != this.lastWidth) || this.firstDrawFlag){
|
||||
this.firstDrawFlag = false;
|
||||
LogUtil.log('ImageKnifeComponent onAreaChange isValid Canvas currentWidth =' + this.currentWidth + ' currentHeight=' + this.currentHeight)
|
||||
LogUtil.log('ImageKnifeComponent onAreaChange And Next To Execute. Canvas currentWidth =' + this.currentWidth + ' currentHeight=' + this.currentHeight)
|
||||
this.lastWidth = this.currentWidth
|
||||
this.lastHeight = this.currentHeight
|
||||
this.imageKnifeExecute()
|
||||
|
@ -126,11 +126,11 @@ export struct ImageKnifeComponent {
|
|||
|
||||
watchImageKnifeOption() {
|
||||
LogUtil.log('ImageKnifeComponent watchImageKnifeOption is happened!')
|
||||
this.whetherWaitSize();
|
||||
this.whetherWaitSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断当前是否由宽高,有直接重绘,没有则等待onAreaChange回调,当出现aboutToAppear第一次绘制的时候
|
||||
* 判断当前是否有宽高,有直接重绘,没有则等待onAreaChange回调,当出现aboutToAppear第一次绘制的时候
|
||||
* 给firstDrawFlag置为true,保证size即使没有变化也要进入 请求绘制流程
|
||||
* @param drawFirst 是否是aboutToAppear第一次绘制
|
||||
*/
|
||||
|
@ -157,7 +157,7 @@ export struct ImageKnifeComponent {
|
|||
* 待onReady执行的时候执行
|
||||
* @param nextFunction 下一个方法
|
||||
*/
|
||||
runNextFunction(nextFunction:Function){
|
||||
runNextFunction(nextFunction:()=>void){
|
||||
if(!this.canvasHasReady){
|
||||
// canvas未初始化完成
|
||||
this.onReadyNext = nextFunction;
|
||||
|
@ -309,8 +309,6 @@ export struct ImageKnifeComponent {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
displayMainSource(data: ImageKnifeData) {
|
||||
|
|
|
@ -13,34 +13,43 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
export class LogUtil {
|
||||
public static isDebug = false;
|
||||
public static OFF: number = 1
|
||||
public static LOG: number = 2
|
||||
public static DEBUG: number = 3
|
||||
public static INFO: number = 4
|
||||
public static WARN: number = 5
|
||||
public static ERROR: number = 6
|
||||
public static ALL: number = 7
|
||||
public static mLogLevel:number = LogUtil.OFF;
|
||||
|
||||
public static debug(info: string) {
|
||||
if (this.isDebug) {
|
||||
console.debug(info)
|
||||
public static debug(message: string, ...args: any[]) {
|
||||
if (LogUtil.mLogLevel >= LogUtil.DEBUG) {
|
||||
console.debug(message, args)
|
||||
}
|
||||
}
|
||||
|
||||
public static info(info: string) {
|
||||
if (this.isDebug) {
|
||||
console.info(info)
|
||||
public static info(message: string, ...args: any[]) {
|
||||
if (LogUtil.mLogLevel >= LogUtil.INFO) {
|
||||
console.info(message, args)
|
||||
}
|
||||
}
|
||||
|
||||
public static log(info: string) {
|
||||
if (this.isDebug) {
|
||||
console.log(info)
|
||||
public static log(message: string, ...args: any[]) {
|
||||
if (LogUtil.mLogLevel >= LogUtil.LOG) {
|
||||
console.log(message, args)
|
||||
}
|
||||
}
|
||||
|
||||
public static warn(info: string) {
|
||||
if (this.isDebug) {
|
||||
console.warn(info)
|
||||
public static warn(message: string, ...args: any[]) {
|
||||
if (LogUtil.mLogLevel >= LogUtil.WARN) {
|
||||
console.warn(message, args)
|
||||
}
|
||||
}
|
||||
|
||||
// error 不做拦截
|
||||
public static error(info: string) {
|
||||
console.error(info)
|
||||
public static error(message: string, ...args: any[]) {
|
||||
if(LogUtil.mLogLevel >= LogUtil.ERROR) {
|
||||
console.error(message, args)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue