diff --git a/ScreenFlickerSolution/entry/.gitignore b/ScreenFlickerSolution/entry/.gitignore deleted file mode 100644 index e2713a2779c5a3e0eb879efe6115455592caeea5..0000000000000000000000000000000000000000 --- a/ScreenFlickerSolution/entry/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/ScreenFlickerSolution/entry/src/main/ets/pages/PullToRefreshError.ets b/ScreenFlickerSolution/entry/src/main/ets/pages/PullToRefreshError.ets index 54318fb8d0bc664f145b3382ac2b6f1c2bca5b25..ba891de2da13d2971f22560a1d6940ec019ba139 100644 --- a/ScreenFlickerSolution/entry/src/main/ets/pages/PullToRefreshError.ets +++ b/ScreenFlickerSolution/entry/src/main/ets/pages/PullToRefreshError.ets @@ -37,7 +37,7 @@ struct PullToRefreshError { @State loadText: ResourceStr = ''; private context: common.UIAbilityContext = this.getUIContext().getHostContext() as common.UIAbilityContext; - aboutToAppear() { + aboutToAppear(): void { const arrayModelMockData: Array = getNews('mockDataOne.json', this.context); this.newsData = arrayModelMockData; } @@ -89,7 +89,7 @@ struct PullToRefreshError { newsModelMockData = getNews('mockDataOne.json', this.context); } this.mockFlag = !this.mockFlag; - const array = this.newsData.slice(); + const array: NewsData[] = this.newsData.slice(); array.push(...newsModelMockData); this.newsData = array; // Page number to zero @@ -244,7 +244,7 @@ struct PullToRefreshError { } // [End get_list_view_error] - aboutToDisappear() { + aboutToDisappear(): void { this.newsData = []; } } @@ -352,16 +352,16 @@ class JsonObject { hilog.warn(0x000, 'testTag', `setColorMode failed, code=${err.code}, message=${err.message}`); } // Decode to utf-8 format - const textDecoder = util.TextDecoder.create('utf-8', { + const textDecoder: util.TextDecoder = util.TextDecoder.create('utf-8', { ignoreBOM: true }); - const textDecoderResult = textDecoder.decodeToString(new Uint8Array(value!.buffer)); + const textDecoderResult: string = textDecoder.decodeToString(new Uint8Array(value!.buffer)); const jsonObj: JsonObjType = JSON.parse(textDecoderResult) as JsonObjType; const newsModelBuckets: Array = []; // Map json data to NewsModel objects - const newsModelObj = jsonObj.newsList; + const newsModelObj: NewsData[] = jsonObj.newsList; for (let i = 0; i < newsModelObj.length; i++) { - const contactTemp = new NewsData(newsModelObj[i].newsId, newsModelObj[i].newsTitle, + const contactTemp: NewsData = new NewsData(newsModelObj[i].newsId, newsModelObj[i].newsTitle, newsModelObj[i].newsContent, newsModelObj[i].newsTime, newsModelObj[i].img); newsModelBuckets.push(contactTemp); } diff --git a/ScreenFlickerSolution/entry/src/main/ets/pages/PullToRefreshRight.ets b/ScreenFlickerSolution/entry/src/main/ets/pages/PullToRefreshRight.ets index 95cd501eab6be8f358a4c038e49bdd334135d8ba..b42662cf73568a7b4a0996f7c4100a5b8b66bba8 100644 --- a/ScreenFlickerSolution/entry/src/main/ets/pages/PullToRefreshRight.ets +++ b/ScreenFlickerSolution/entry/src/main/ets/pages/PullToRefreshRight.ets @@ -37,7 +37,7 @@ struct PullToRefreshError { @State loadText: ResourceStr = ''; private context: common.UIAbilityContext = this.getUIContext().getHostContext() as common.UIAbilityContext; - aboutToAppear() { + aboutToAppear(): void { const arrayModelMockData: Array = getNews('mockDataOne.json', this.context); this.newsData = arrayModelMockData; } @@ -89,7 +89,7 @@ struct PullToRefreshError { newsModelMockData = getNews('mockDataOne.json', this.context); } this.mockFlag = !this.mockFlag; - const array = this.newsData.slice(); + const array: NewsData[] = this.newsData.slice(); array.push(...newsModelMockData); this.newsData = array; // Page number to zero @@ -352,16 +352,16 @@ class JsonObject { hilog.warn(0x000, 'testTag', `setColorMode failed, code=${err.code}, message=${err.message}`); } // Decode to utf-8 format - const textDecoder = util.TextDecoder.create('utf-8', { + const textDecoder: util.TextDecoder = util.TextDecoder.create('utf-8', { ignoreBOM: true }); - const textDecoderResult = textDecoder.decodeToString(new Uint8Array(value!.buffer)); + const textDecoderResult: string = textDecoder.decodeToString(new Uint8Array(value!.buffer)); const jsonObj: JsonObjType = JSON.parse(textDecoderResult) as JsonObjType; const newsModelBuckets: Array = []; // Map json data to NewsModel objects - const newsModelObj = jsonObj.newsList; + const newsModelObj: NewsData[] = jsonObj.newsList; for (let i = 0; i < newsModelObj.length; i++) { - const contactTemp = new NewsData(newsModelObj[i].newsId, newsModelObj[i].newsTitle, + const contactTemp: NewsData = new NewsData(newsModelObj[i].newsId, newsModelObj[i].newsTitle, newsModelObj[i].newsContent, newsModelObj[i].newsTime, newsModelObj[i].img); newsModelBuckets.push(contactTemp); } diff --git a/ScreenFlickerSolution/entry/src/main/ets/pages/TabsRight.ets b/ScreenFlickerSolution/entry/src/main/ets/pages/TabsRight.ets index 6f97f9ce88e4e3e63f4087faf0898f9c4ef30213..0258d4bdb529da963c748e7727d3312f76cbc6ae 100644 --- a/ScreenFlickerSolution/entry/src/main/ets/pages/TabsRight.ets +++ b/ScreenFlickerSolution/entry/src/main/ets/pages/TabsRight.ets @@ -105,11 +105,11 @@ struct TabsRight { this.startAnimateTo(this.animationDuration, this.textInfos[targetIndex][0], this.textInfos[targetIndex][1]); }) .onAnimationEnd((index: number, event: TabsAnimationEvent) => { - let currentIndicatorInfo = this.getCurrentIndicatorInfo(index, event); + let currentIndicatorInfo: Record = this.getCurrentIndicatorInfo(index, event); this.startAnimateTo(0, currentIndicatorInfo.left, currentIndicatorInfo.width); }) .onGestureSwipe((index: number, event: TabsAnimationEvent) => { - let currentIndicatorInfo = this.getCurrentIndicatorInfo(index, event); + let currentIndicatorInfo: Record = this.getCurrentIndicatorInfo(index, event); this.currentIndex = currentIndicatorInfo.index; this.indicatorLeftMargin = currentIndicatorInfo.left; this.indicatorWidth = currentIndicatorInfo.width; @@ -135,13 +135,13 @@ struct TabsRight { nextIndex++; } - let indexInfo = this.textInfos[index]; - let nextIndexInfo = this.textInfos[nextIndex]; - let swipeRatio = Math.abs(event.currentOffset / this.tabsWidth); - let currentIndex = swipeRatio > 0.5 ? nextIndex : + let indexInfo: [number, number] = this.textInfos[index]; + let nextIndexInfo: [number, number] = this.textInfos[nextIndex]; + let swipeRatio: number = Math.abs(event.currentOffset / this.tabsWidth); + let currentIndex: number = swipeRatio > 0.5 ? nextIndex : index; // The page slides more than halfway and the tabBar switches to the next page. - let currentLeft = indexInfo[0] + (nextIndexInfo[0] - indexInfo[0]) * swipeRatio; - let currentWidth = indexInfo[1] + (nextIndexInfo[1] - indexInfo[1]) * swipeRatio; + let currentLeft: number = indexInfo[0] + (nextIndexInfo[0] - indexInfo[0]) * swipeRatio; + let currentWidth: number = indexInfo[1] + (nextIndexInfo[1] - indexInfo[1]) * swipeRatio; return { 'index': currentIndex, 'left': currentLeft, 'width': currentWidth }; }