From 4d731b27d9a6f340a121467e15423fe01c786c11 Mon Sep 17 00:00:00 2001 From: wangqixu Date: Sat, 16 Dec 2023 10:41:56 +0800 Subject: [PATCH] =?UTF-8?q?1=20=E6=B7=BB=E5=8A=A0picker=E7=85=A7=E7=89=87?= =?UTF-8?q?=E6=8E=A8=E8=8D=90=E8=83=BD=E5=8A=9B=202=20=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E8=A7=84=E8=8C=83=E9=97=AE=E9=A2=98=E5=A4=84=E7=90=86=EF=BC=8C?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangqixu --- .../model/browser/photo/GetItemsCallback.ts | 4 +- .../browser/photo/GetMediaCountCallback.ts | 4 +- .../model/browser/photo/MediaDataSource.ts | 6 +-- .../default/model/browser/photo/MediaItem.ts | 8 ++-- .../default/common/PickerMediaDataSource.ts | 2 +- .../default/common/SmartPickerConstants.ts | 37 +++++++++---------- .../default/common/SmartPickerDataAdapter.ts | 22 +++++------ .../ets/default/common/SmartPickerDataImpl.ts | 13 ++++--- .../ets/default/common/SmartPickerManager.ts | 14 +------ .../common/SmartPickerRecommendInfo.ts | 6 +-- .../SmartPickerRecommendInfoCallback.ts | 6 +-- .../SmartPickerRecommendInfoListener.ts | 4 +- .../SmartPickerRecommendInfoObserver.ts | 10 ++--- .../common/SmartPickerRecommendTabInfo.ts | 6 +-- .../dataimpl/SmartPickerPhotosDataImpl.ts | 18 ++++----- .../interface/SmartPickerDataFactory.ts | 8 ++-- .../interface/SmartPickerDataInterface.ts | 13 ++++--- .../ets/default/utils/SmartPickerUtils.ts | 5 ++- .../default/view/ThirdSelectPhotoGridBase.ets | 6 +-- .../view/ThirdSelectSmartRecommendTabBar.ets | 6 +-- 20 files changed, 96 insertions(+), 102 deletions(-) diff --git a/common/src/main/ets/default/model/browser/photo/GetItemsCallback.ts b/common/src/main/ets/default/model/browser/photo/GetItemsCallback.ts index da28128f..039fe2b2 100644 --- a/common/src/main/ets/default/model/browser/photo/GetItemsCallback.ts +++ b/common/src/main/ets/default/model/browser/photo/GetItemsCallback.ts @@ -33,10 +33,10 @@ export class GetItemsCallback implements AsyncCallback { TraceControllerUtils.startTraceWithTaskId('getMediaItems', this.requestTime); } - callback(assets: MediaItem[], dataAlbumUri?: string) { + callback(assets: MediaItem[], dataAlbumUri?: string): void { TraceControllerUtils.finishTraceWithTaskId('getMediaItems', this.requestTime); if (this.source?.isInvalidData(this.source?.getAlbumUri(), dataAlbumUri)) { - Log.error(TAG, 'GetItemsCallback callback isInvalidData:this.albumUri:' + this.source?.getAlbumUri() + ' dataAlbumUri:' + dataAlbumUri) + Log.error(TAG, 'GetItemsCallback callback isInvalidData:this.albumUri:' + this.source?.getAlbumUri() + ' dataAlbumUri:' + dataAlbumUri); return; } Log.info(TAG, `took ${Date.now() - this.requestTime} milliseconds to load data: ${assets.length}`); diff --git a/common/src/main/ets/default/model/browser/photo/GetMediaCountCallback.ts b/common/src/main/ets/default/model/browser/photo/GetMediaCountCallback.ts index ff110cd5..95fe800d 100644 --- a/common/src/main/ets/default/model/browser/photo/GetMediaCountCallback.ts +++ b/common/src/main/ets/default/model/browser/photo/GetMediaCountCallback.ts @@ -33,10 +33,10 @@ export class GetMediaCountCallback implements AsyncCallback { } // Data callback - callback(count: number, dataAlbumUri?: string) { + callback(count: number, dataAlbumUri?: string): void { TraceControllerUtils.finishTraceWithTaskId('getMediaCount', this.requestTime); if (this.source?.isInvalidData(this.source?.getAlbumUri(), dataAlbumUri)) { - Log.error(TAG, 'GetMediaCountCallback callback isInvalidData:this.albumUri:' + this.source?.getAlbumUri() + ' dataAlbumUri:' + dataAlbumUri) + Log.error(TAG, 'GetMediaCountCallback callback isInvalidData:this.albumUri:' + this.source?.getAlbumUri() + ' dataAlbumUri:' + dataAlbumUri); return; } this.source.updateMediaCount(this.requestTime, count); diff --git a/common/src/main/ets/default/model/browser/photo/MediaDataSource.ts b/common/src/main/ets/default/model/browser/photo/MediaDataSource.ts index aa0bf5d2..4674bbd5 100644 --- a/common/src/main/ets/default/model/browser/photo/MediaDataSource.ts +++ b/common/src/main/ets/default/model/browser/photo/MediaDataSource.ts @@ -33,7 +33,7 @@ import type { QueryParam } from '../BrowserDataImpl'; import type { ViewData } from './ViewData'; import { GetItemIndexCallback } from './GetItemIndexCallback'; import { FileAsset } from '../../../access/UserFileManagerAccess'; -import { PhotoDataImpl } from './PhotoDataImpl'; +import type { PhotoDataImpl } from './PhotoDataImpl'; const TAG: string = 'common_MediaDataSource'; @@ -242,7 +242,7 @@ export class MediaDataSource extends AbsDataSource { Log.info(TAG, `took ${(Date.now() - this.firstPatchDataRequestTime)}\ milliseconds to load first batch: ${(assets == null ? 0 : assets.length)}`); if (this.isInvalidData(this.albumUri, dataAlbumUri)) { - Log.error(TAG, 'initData callback isInvalidData:this.albumUri:' + this.albumUri + ' dataAlbumUri:' + dataAlbumUri) + Log.error(TAG, 'initData callback isInvalidData:this.albumUri:' + this.albumUri + ' dataAlbumUri:' + dataAlbumUri); return; } if (assets?.length > 0) { @@ -527,7 +527,7 @@ export class MediaDataSource extends AbsDataSource { Log.info(TAG, `took ${(Date.now() - this.firstPatchDataRequestTime)}\ milliseconds to load first batch: ${(assets == null ? 0 : assets.length)}`); if (this.isInvalidData(this.albumUri, dataAlbumUri)) { - Log.error(TAG, 'updateSlidingWindow callback isInvalidData:this.albumUri:' + this.getAlbumUri() + ' dataAlbumUri:' + dataAlbumUri) + Log.error(TAG, 'updateSlidingWindow callback isInvalidData:this.albumUri:' + this.getAlbumUri() + ' dataAlbumUri:' + dataAlbumUri); return; } if (assets?.length > 0) { diff --git a/common/src/main/ets/default/model/browser/photo/MediaItem.ts b/common/src/main/ets/default/model/browser/photo/MediaItem.ts index ed66a18a..bb2ca5ff 100644 --- a/common/src/main/ets/default/model/browser/photo/MediaItem.ts +++ b/common/src/main/ets/default/model/browser/photo/MediaItem.ts @@ -18,7 +18,7 @@ import { FileAsset, UserFileManagerAccess } from '../../../access/UserFileManage import { DateUtil } from '../../../utils/DateUtil'; import { Constants } from '../../common/Constants'; import { AlbumDefine } from '../AlbumDefine'; -import photoAccessHelper from '@ohos.file.photoAccessHelper'; +import type photoAccessHelper from '@ohos.file.photoAccessHelper'; const TAG: string = 'common_MediaItem'; @@ -52,7 +52,7 @@ export class MediaItem { this.initialize(data); } - initialize(data?: userFileManager.FileAsset | photoAccessHelper.PhotoAsset) { + initialize(data?: userFileManager.FileAsset | photoAccessHelper.PhotoAsset): void { if (!data) { return; } @@ -63,7 +63,7 @@ export class MediaItem { if (this.mediaType == UserFileManagerAccess.MEDIA_TYPE_VIDEO) { this.duration = Number(data.get(userFileManager.ImageVideoKey.DURATION.toString())); } - this.size = Number(data.get("size")); + this.size = Number(data.get('size')); this.orientation = Number(data.get(userFileManager.ImageVideoKey.ORIENTATION.toString())); if (this.orientation == Constants.ANGLE_90 || this.orientation == Constants.ANGLE_270) { this.width = Number(data.get(userFileManager.ImageVideoKey.HEIGHT.toString())); @@ -78,7 +78,7 @@ export class MediaItem { this.imgHeight = this.height; this.dateTrashed = Number(data.get(userFileManager.ImageVideoKey.DATE_TRASHED.toString())); this.isFavor = Boolean(data.get(userFileManager.ImageVideoKey.FAVORITE.toString())); - this.hashCode = `${this.uri}_${this.size}_${this.orientation}_${this.isFavor}` + this.hashCode = `${this.uri}_${this.size}_${this.orientation}_${this.isFavor}`; } async getObject(fetchOpt): Promise { diff --git a/feature/thirdselect/src/main/ets/default/common/PickerMediaDataSource.ts b/feature/thirdselect/src/main/ets/default/common/PickerMediaDataSource.ts index 2b45a020..cc12e719 100644 --- a/feature/thirdselect/src/main/ets/default/common/PickerMediaDataSource.ts +++ b/feature/thirdselect/src/main/ets/default/common/PickerMediaDataSource.ts @@ -14,7 +14,7 @@ */ import { MediaDataSource } from '@ohos/common/src/main/ets/default/model/browser/photo/MediaDataSource'; -import { PhotoDataImpl } from '@ohos/common/src/main/ets/default/model/browser/photo/PhotoDataImpl'; +import type { PhotoDataImpl } from '@ohos/common/src/main/ets/default/model/browser/photo/PhotoDataImpl'; import type { BrowserDataInterface } from '@ohos/common/src/main/ets/default/interface/BrowserDataInterface'; export class PickerMediaDataSource extends MediaDataSource { diff --git a/feature/thirdselect/src/main/ets/default/common/SmartPickerConstants.ts b/feature/thirdselect/src/main/ets/default/common/SmartPickerConstants.ts index a712af7e..0e3db496 100644 --- a/feature/thirdselect/src/main/ets/default/common/SmartPickerConstants.ts +++ b/feature/thirdselect/src/main/ets/default/common/SmartPickerConstants.ts @@ -49,29 +49,28 @@ export default class SmartPickerConstants { [SmartPickerConstants.NAME_QR_CODE, SmartPickerConstants.LABEL_QR_CODE], [SmartPickerConstants.NAME_BAR_CODE, SmartPickerConstants.LABEL_BAR_CODE], [SmartPickerConstants.NAME_AVATAR, SmartPickerConstants.LABEL_AVATAR], - ]) + ]); static readonly LABEL_ID_KEY: string = 'album_name'; static readonly RECOMMEND_TAB_BORDER_RADIUS: number = 20; - static readonly ALL_IMAGE_VIDEO_FETCH_COLUMNS: Array = [ - photoAccessHelper.PhotoKeys.URI.toString(), - photoAccessHelper.PhotoKeys.PHOTO_TYPE.toString(), - photoAccessHelper.PhotoKeys.DISPLAY_NAME.toString(), - photoAccessHelper.PhotoKeys.DATE_ADDED.toString(), - photoAccessHelper.PhotoKeys.DATE_MODIFIED.toString(), - photoAccessHelper.PhotoKeys.TITLE.toString(), - photoAccessHelper.PhotoKeys.DURATION.toString(), - photoAccessHelper.PhotoKeys.WIDTH.toString(), - photoAccessHelper.PhotoKeys.HEIGHT.toString(), - photoAccessHelper.PhotoKeys.DATE_TAKEN.toString(), - photoAccessHelper.PhotoKeys.ORIENTATION.toString(), - photoAccessHelper.PhotoKeys.FAVORITE.toString(), - photoAccessHelper.PhotoKeys.POSITION.toString(), - photoAccessHelper.PhotoKeys.DATE_TRASHED.toString(), - photoAccessHelper.PhotoKeys.HIDDEN.toString(), - photoAccessHelper.PhotoKeys.SIZE.toString() - ] + photoAccessHelper.PhotoKeys.URI.toString(), + photoAccessHelper.PhotoKeys.PHOTO_TYPE.toString(), + photoAccessHelper.PhotoKeys.DISPLAY_NAME.toString(), + photoAccessHelper.PhotoKeys.DATE_ADDED.toString(), + photoAccessHelper.PhotoKeys.DATE_MODIFIED.toString(), + photoAccessHelper.PhotoKeys.TITLE.toString(), + photoAccessHelper.PhotoKeys.DURATION.toString(), + photoAccessHelper.PhotoKeys.WIDTH.toString(), + photoAccessHelper.PhotoKeys.HEIGHT.toString(), + photoAccessHelper.PhotoKeys.DATE_TAKEN.toString(), + photoAccessHelper.PhotoKeys.ORIENTATION.toString(), + photoAccessHelper.PhotoKeys.FAVORITE.toString(), + photoAccessHelper.PhotoKeys.POSITION.toString(), + photoAccessHelper.PhotoKeys.DATE_TRASHED.toString(), + photoAccessHelper.PhotoKeys.HIDDEN.toString(), + photoAccessHelper.PhotoKeys.SIZE.toString() + ]; } diff --git a/feature/thirdselect/src/main/ets/default/common/SmartPickerDataAdapter.ts b/feature/thirdselect/src/main/ets/default/common/SmartPickerDataAdapter.ts index 3101c403..cd04b655 100644 --- a/feature/thirdselect/src/main/ets/default/common/SmartPickerDataAdapter.ts +++ b/feature/thirdselect/src/main/ets/default/common/SmartPickerDataAdapter.ts @@ -16,13 +16,13 @@ import SmartPickerRecommendInfo from './SmartPickerRecommendInfo'; import { Log } from '@ohos/common/src/main/ets/default/utils/Log'; import { StringUtil } from '@ohos/common/src/main/ets/default/utils/StringUtil'; -import { SmartPickerDataInterface } from '../interface/SmartPickerDataInterface'; +import type { SmartPickerDataInterface } from '../interface/SmartPickerDataInterface'; import SmartPickerConstants from './SmartPickerConstants'; -import { AsyncCallback } from '@ohos/common/src/main/ets/default/model/common/AsyncCallback'; +import type { AsyncCallback } from '@ohos/common/src/main/ets/default/model/common/AsyncCallback'; import { SmartPickerDataFactory } from '../interface/SmartPickerDataFactory'; -import { MediaItem } from '@ohos/common'; -import { QueryParam } from '@ohos/common/src/main/ets/default/model/browser/BrowserDataImpl'; -import { RecommendationOptions } from './SmartPickerManager'; +import type { MediaItem } from '@ohos/common'; +import type { QueryParam } from '@ohos/common/src/main/ets/default/model/browser/BrowserDataImpl'; +import type { RecommendationOptions } from './SmartPickerManager'; const TAG: string = 'SmartPickerDataAdapter'; @@ -34,14 +34,14 @@ export default class SmartPickerDataAdapter { } static getInstance(): SmartPickerDataAdapter { - if (AppStorage.get(SmartPickerConstants.SMART_PICKER_DATA_ADAPTER) == null) { + if (AppStorage.get(SmartPickerConstants.SMART_PICKER_DATA_ADAPTER) === null) { AppStorage.setOrCreate(SmartPickerConstants.SMART_PICKER_DATA_ADAPTER, new SmartPickerDataAdapter()); } let manager: SmartPickerDataAdapter = AppStorage.get(SmartPickerConstants.SMART_PICKER_DATA_ADAPTER); return manager; } - getTabInfoList(callback: AsyncCallback, recommendationOptions: RecommendationOptions, param?: string) { + getTabInfoList(callback: AsyncCallback, recommendationOptions: RecommendationOptions, param?: string): void { try { let recommendationType = recommendationOptions.recommendationType; if (recommendationType >= SmartPickerConstants.QR_OR_BAR_CODE && recommendationType <= SmartPickerConstants.PROFILE_PICTURE) { @@ -55,7 +55,7 @@ export default class SmartPickerDataAdapter { } else { Log.error(TAG, 'getTabInfoList tabInfoList is undefined'); } - }) + }); } } catch (err) { Log.error(TAG, 'getTabInfoList err:' + err); @@ -72,10 +72,10 @@ export default class SmartPickerDataAdapter { this.uriDataImplMap.set(tabInfo.getAlbumUri(), dataImpl); } else { } - }) + }); } - getData(callback: AsyncCallback, param: QueryParam) { + getData(callback: AsyncCallback, param: QueryParam): void { try { let albumUri = param?.albumUri; if (StringUtil.isEmpty(albumUri)) { @@ -101,7 +101,7 @@ export default class SmartPickerDataAdapter { } else { return new Promise((resolve): void => { resolve(count); - }) + }); } } } diff --git a/feature/thirdselect/src/main/ets/default/common/SmartPickerDataImpl.ts b/feature/thirdselect/src/main/ets/default/common/SmartPickerDataImpl.ts index ce6f3b6c..72d8e026 100644 --- a/feature/thirdselect/src/main/ets/default/common/SmartPickerDataImpl.ts +++ b/feature/thirdselect/src/main/ets/default/common/SmartPickerDataImpl.ts @@ -15,9 +15,10 @@ import { Log } from '@ohos/common/src/main/ets/default/utils/Log'; import { PhotoDataImpl } from '@ohos/common/src/main/ets/default/model/browser/photo/PhotoDataImpl'; -import { AsyncCallback, MediaItem, StringUtil } from '@ohos/common'; -import { QueryParam } from '@ohos/common/src/main/ets/default/model/browser/BrowserDataImpl'; -import SmartPickerDataAdapter from './SmartPickerDataAdapter'; +import type { AsyncCallback, MediaItem } from '@ohos/common'; +import { StringUtil } from '@ohos/common'; +import type { QueryParam } from '@ohos/common/src/main/ets/default/model/browser/BrowserDataImpl'; +import type SmartPickerDataAdapter from './SmartPickerDataAdapter'; const TAG: string = 'SmartPickerDataImpl'; @@ -34,12 +35,12 @@ export default class SmartPickerDataImpl extends PhotoDataImpl { getData(callback: AsyncCallback, param: QueryParam): void { Log.info(TAG, `getData start ${JSON.stringify(param)}`); - if (callback == null || callback == undefined) { + if (callback === null || callback === undefined) { Log.error(TAG, 'getData, param or callback is null, return!'); return; } if (StringUtil.isEmpty(param?.albumUri)) { - return + return; } this.dataAdapter.getData(callback, param); } @@ -48,7 +49,7 @@ export default class SmartPickerDataImpl extends PhotoDataImpl { Log.debug(TAG, `getDataCount: ${JSON.stringify(param)}`); this.dataAdapter.getDataCount(param.albumUri, param.filterMediaType).then((count): void => { callback.callback(count); - }) + }); } } diff --git a/feature/thirdselect/src/main/ets/default/common/SmartPickerManager.ts b/feature/thirdselect/src/main/ets/default/common/SmartPickerManager.ts index 7560a8f1..0ac12387 100644 --- a/feature/thirdselect/src/main/ets/default/common/SmartPickerManager.ts +++ b/feature/thirdselect/src/main/ets/default/common/SmartPickerManager.ts @@ -14,8 +14,8 @@ */ import { Log } from '@ohos/common/src/main/ets/default/utils/Log'; -import SmartPickerRecommendInfo from './SmartPickerRecommendInfo'; -import SmartPickerRecommendInfoListener from './SmartPickerRecommendInfoListener'; +import type SmartPickerRecommendInfo from './SmartPickerRecommendInfo'; +import type SmartPickerRecommendInfoListener from './SmartPickerRecommendInfoListener'; import SmartPickerConstants from './SmartPickerConstants'; import SmartPickerRecommendInfoCallback from './SmartPickerRecommendInfoCallback'; import SmartPickerDataAdapter from './SmartPickerDataAdapter'; @@ -57,21 +57,12 @@ export class SmartPickerManager { Log.info(TAG, 'addPickerRecommendInfoListener listener:' + listener); if (listener && this.pickerInfoListeners.indexOf(listener) === SmartPickerConstants.INVALID) { this.pickerInfoListeners.push(listener); - this.printTabInfoArray(); if (!this.hansNotify && this.tabInfoArray !== undefined && this.tabInfoArray.length > 0) { this.notifyTabInfoFinished(this.tabInfoArray); } } } - private printTabInfoArray() { - Log.error(TAG, 'printTabInfoArray tabInfoArray.length:' + this.tabInfoArray.length); - for (let i = 0;i < this.tabInfoArray.length; i++) { - let tabInfo = this.tabInfoArray[i]; - Log.info(TAG, 'printTabInfoArray getAlbumUri:' + tabInfo.getAlbumUri() + ' getLabelId:' + tabInfo.getLabelId()); - } - } - removePickerRecommendInfoListener(listener: SmartPickerRecommendInfoListener): void { if (!listener) { return; @@ -95,7 +86,6 @@ export class SmartPickerManager { return; } if (!this.hansNotify) { - this.printTabInfoArray(); for (let listener of this.pickerInfoListeners) { listener.onPickerRecommendInfoListReady(this.tabInfoArray, this.dataAdapter); break; diff --git a/feature/thirdselect/src/main/ets/default/common/SmartPickerRecommendInfo.ts b/feature/thirdselect/src/main/ets/default/common/SmartPickerRecommendInfo.ts index 1022dbf3..09cf0d43 100644 --- a/feature/thirdselect/src/main/ets/default/common/SmartPickerRecommendInfo.ts +++ b/feature/thirdselect/src/main/ets/default/common/SmartPickerRecommendInfo.ts @@ -17,9 +17,9 @@ import SmartPickerConstants from './SmartPickerConstants'; export default class SmartPickerRecommendInfo { private recommendType: number = SmartPickerConstants.INVALID; - private labelId: string = '' - private recommendContent: string = '' - private albumUri: string = '' + private labelId: string = ''; + private recommendContent: string = ''; + private albumUri: string = ''; private totalCount: number = SmartPickerConstants.INVALID; constructor() { diff --git a/feature/thirdselect/src/main/ets/default/common/SmartPickerRecommendInfoCallback.ts b/feature/thirdselect/src/main/ets/default/common/SmartPickerRecommendInfoCallback.ts index 89716136..ff5c76b2 100644 --- a/feature/thirdselect/src/main/ets/default/common/SmartPickerRecommendInfoCallback.ts +++ b/feature/thirdselect/src/main/ets/default/common/SmartPickerRecommendInfoCallback.ts @@ -13,10 +13,10 @@ * limitations under the License. */ -import { AsyncCallback } from '@ohos/common/src/main/ets/default/model/common/AsyncCallback'; -import { SmartPickerManager } from './SmartPickerManager'; +import type { AsyncCallback } from '@ohos/common/src/main/ets/default/model/common/AsyncCallback'; +import type { SmartPickerManager } from './SmartPickerManager'; -import SmartPickerRecommendInfo from './SmartPickerRecommendInfo'; +import type SmartPickerRecommendInfo from './SmartPickerRecommendInfo'; export default class SmartPickerRecommendInfoCallback implements AsyncCallback { private manager: SmartPickerManager; diff --git a/feature/thirdselect/src/main/ets/default/common/SmartPickerRecommendInfoListener.ts b/feature/thirdselect/src/main/ets/default/common/SmartPickerRecommendInfoListener.ts index 4950fd2d..ffb94bec 100644 --- a/feature/thirdselect/src/main/ets/default/common/SmartPickerRecommendInfoListener.ts +++ b/feature/thirdselect/src/main/ets/default/common/SmartPickerRecommendInfoListener.ts @@ -13,8 +13,8 @@ * limitations under the License. */ -import SmartPickerDataAdapter from './SmartPickerDataAdapter'; -import SmartPickerRecommendInfo from './SmartPickerRecommendInfo'; +import type SmartPickerDataAdapter from './SmartPickerDataAdapter'; +import type SmartPickerRecommendInfo from './SmartPickerRecommendInfo'; export default interface SmartPickerRecommendInfoListener { onPickerRecommendInfoListReady(smartPickerRecommendInfoList: Array, dataAdapter: SmartPickerDataAdapter): void; diff --git a/feature/thirdselect/src/main/ets/default/common/SmartPickerRecommendInfoObserver.ts b/feature/thirdselect/src/main/ets/default/common/SmartPickerRecommendInfoObserver.ts index 492138e6..91e1d838 100644 --- a/feature/thirdselect/src/main/ets/default/common/SmartPickerRecommendInfoObserver.ts +++ b/feature/thirdselect/src/main/ets/default/common/SmartPickerRecommendInfoObserver.ts @@ -13,16 +13,16 @@ * limitations under the License. */ -import SmartPickerDataAdapter from './SmartPickerDataAdapter'; -import SmartPickerRecommendInfo from './SmartPickerRecommendInfo'; -import SmartPickerRecommendInfoListener from './SmartPickerRecommendInfoListener'; +import type SmartPickerDataAdapter from './SmartPickerDataAdapter'; +import type SmartPickerRecommendInfo from './SmartPickerRecommendInfo'; +import type SmartPickerRecommendInfoListener from './SmartPickerRecommendInfoListener'; interface SmartPickerRecommendInfoReadyCallback { onSmartPickerRecommendInfoListReady(smartPickerRecommendInfoList: SmartPickerRecommendInfo[], dataAdapter: SmartPickerDataAdapter) : void; } export default class SmartPickerRecommendInfoObserver implements SmartPickerRecommendInfoListener { - source: SmartPickerRecommendInfoReadyCallback + source: SmartPickerRecommendInfoReadyCallback; constructor(source: SmartPickerRecommendInfoReadyCallback) { this.source = source; @@ -32,6 +32,6 @@ export default class SmartPickerRecommendInfoObserver implements SmartPickerReco this.source.onSmartPickerRecommendInfoListReady(smartPickerRecommendInfoList, dataAdapter); } - onDataChanged(smartPickerRecommendInfo: SmartPickerRecommendInfo) { + onDataChanged(smartPickerRecommendInfo: SmartPickerRecommendInfo): void { } } diff --git a/feature/thirdselect/src/main/ets/default/common/SmartPickerRecommendTabInfo.ts b/feature/thirdselect/src/main/ets/default/common/SmartPickerRecommendTabInfo.ts index 557f93ee..7baaabbe 100644 --- a/feature/thirdselect/src/main/ets/default/common/SmartPickerRecommendTabInfo.ts +++ b/feature/thirdselect/src/main/ets/default/common/SmartPickerRecommendTabInfo.ts @@ -17,9 +17,9 @@ import SmartPickerConstants from './SmartPickerConstants'; export default class SmartPickerRecommendTabInfo { private recommendType: number = SmartPickerConstants.INVALID; - private labelId: string = '' - private recommendContent: string = '' - private albumUri: string = '' + private labelId: string = ''; + private recommendContent: string = ''; + private albumUri: string = ''; private cameraAble: boolean = false; private totalCount: number = SmartPickerConstants.INVALID; diff --git a/feature/thirdselect/src/main/ets/default/dataimpl/SmartPickerPhotosDataImpl.ts b/feature/thirdselect/src/main/ets/default/dataimpl/SmartPickerPhotosDataImpl.ts index fd2b4467..ace861e5 100644 --- a/feature/thirdselect/src/main/ets/default/dataimpl/SmartPickerPhotosDataImpl.ts +++ b/feature/thirdselect/src/main/ets/default/dataimpl/SmartPickerPhotosDataImpl.ts @@ -14,19 +14,19 @@ */ import { SmartPickerDataInterface } from '../interface/SmartPickerDataInterface'; -import common from '@ohos.app.ability.common'; +import type common from '@ohos.app.ability.common'; import SmartPickerRecommendInfo from '../common/SmartPickerRecommendInfo'; import SmartPickerConstants from '../common/SmartPickerConstants'; import { Log } from '@ohos/common/src/main/ets/default/utils/Log'; import dataSharePredicates from '@ohos.data.dataSharePredicates'; -import { AsyncCallback } from '@ohos/common/src/main/ets/default/model/common/AsyncCallback'; +import type { AsyncCallback } from '@ohos/common/src/main/ets/default/model/common/AsyncCallback'; import { MediaItem } from '@ohos/common/src/main/ets/default/model/browser/photo/MediaItem'; -import { QueryParam } from '@ohos/common/src/main/ets/default/model/browser/BrowserDataImpl'; +import type { QueryParam } from '@ohos/common/src/main/ets/default/model/browser/BrowserDataImpl'; import { SmartPickerUtils } from '../utils/SmartPickerUtils'; import { Constants } from '@ohos/common/src/main/ets/default/model/common/Constants'; import photoAccessHelper from '@ohos.file.photoAccessHelper'; -import SmartPickerDataAdapter from '../common/SmartPickerDataAdapter'; -import { RecommendationOptions } from '../common/SmartPickerManager'; +import type SmartPickerDataAdapter from '../common/SmartPickerDataAdapter'; +import type { RecommendationOptions } from '../common/SmartPickerManager'; import { StringUtil } from '@ohos/common/src/main/ets/default/utils/StringUtil'; const TAG: string = 'SmartPickerPhotosDataImpl'; @@ -62,7 +62,7 @@ export class SmartPickerPhotosDataImpl implements SmartPickerDataInterface { private addLabelIdNameInfo(recommendationType?: number): void { try { - if (recommendationType != undefined) { + if (recommendationType !== undefined) { switch (recommendationType) { case SmartPickerConstants.QR_OR_BAR_CODE: this.labelIdNameMap.set(SmartPickerConstants.LABEL_QR_CODE, SmartPickerConstants.NAME_QR_CODE); @@ -114,7 +114,7 @@ export class SmartPickerPhotosDataImpl implements SmartPickerDataInterface { let albumList = await albumsFetchResult.getAllObjects(); albumsFetchResult.close(); let pickerRecommendInfoList: SmartPickerRecommendInfo[] = []; - for (let i = 0;i < albumList.length; i++) { + for (let i = 0; i < albumList.length; i++) { let album: photoAccessHelper.Album = albumList[i]; if (album.count > 0) { let tabInfo = this.buildTabInfoByAlbum(album); @@ -148,7 +148,7 @@ export class SmartPickerPhotosDataImpl implements SmartPickerDataInterface { this.getLabelPhotoData(callback, albumUri, start, count, filterMediaType); } - private getLabelPhotoData(callback: AsyncCallback, albumUri: string, startIndex?: number, count?: number, filterMediaType?: string) { + private getLabelPhotoData(callback: AsyncCallback, albumUri: string, startIndex?: number, count?: number, filterMediaType?: string): void { if (StringUtil.isEmpty(albumUri)) { callback.callback([], albumUri); return; @@ -164,7 +164,7 @@ export class SmartPickerPhotosDataImpl implements SmartPickerDataInterface { } else { callback.callback([], albumUri); } - }) + }); } catch (err) { Log.error(TAG, 'getLabelPhotoData err:' + err); callback.callback([], albumUri); diff --git a/feature/thirdselect/src/main/ets/default/interface/SmartPickerDataFactory.ts b/feature/thirdselect/src/main/ets/default/interface/SmartPickerDataFactory.ts index fc56bf29..d3fba875 100644 --- a/feature/thirdselect/src/main/ets/default/interface/SmartPickerDataFactory.ts +++ b/feature/thirdselect/src/main/ets/default/interface/SmartPickerDataFactory.ts @@ -13,16 +13,16 @@ * limitations under the License. */ -import common from '@ohos.app.ability.common'; -import SmartPickerDataAdapter from '../common/SmartPickerDataAdapter'; +import type common from '@ohos.app.ability.common'; +import type SmartPickerDataAdapter from '../common/SmartPickerDataAdapter'; import { SmartPickerPhotosDataImpl } from '../dataimpl/SmartPickerPhotosDataImpl'; -import { SmartPickerDataInterface } from './SmartPickerDataInterface'; +import type { SmartPickerDataInterface } from './SmartPickerDataInterface'; export class SmartPickerDataFactory { static readonly TYPE_LABEL = 'label'; static getFeature(type: string, dataAdapter: SmartPickerDataAdapter): SmartPickerDataInterface { - if (type == SmartPickerDataFactory.TYPE_LABEL) { + if (type === SmartPickerDataFactory.TYPE_LABEL) { let context: common.Context = undefined; if (AppStorage.has('photosAbilityContext')) { context = AppStorage.get('photosAbilityContext'); diff --git a/feature/thirdselect/src/main/ets/default/interface/SmartPickerDataInterface.ts b/feature/thirdselect/src/main/ets/default/interface/SmartPickerDataInterface.ts index 5ac2a2d9..46868319 100644 --- a/feature/thirdselect/src/main/ets/default/interface/SmartPickerDataInterface.ts +++ b/feature/thirdselect/src/main/ets/default/interface/SmartPickerDataInterface.ts @@ -13,13 +13,16 @@ * limitations under the License. */ -import { RecommendationOptions } from '../common/SmartPickerManager'; -import SmartPickerRecommendInfo from '../common/SmartPickerRecommendInfo'; +import type { MediaItem } from '@ohos/common'; +import type { QueryParam } from '@ohos/common/src/main/ets/default/model/browser/BrowserDataImpl'; +import type { AsyncCallback } from '@ohos/common/src/main/ets/default/model/common/AsyncCallback'; +import type { RecommendationOptions } from '../common/SmartPickerManager'; +import type SmartPickerRecommendInfo from '../common/SmartPickerRecommendInfo'; export interface SmartPickerDataInterface { - getTabInfoList(recommendationOptions: RecommendationOptions, param?: any): Promise>; + getTabInfoList(recommendationOptions: RecommendationOptions, param?: string): Promise>; - getData(callback: any, param: any): void; + getData(callback: AsyncCallback, param: QueryParam): void; - getDataCount(callback: any, param: any): Promise; + getDataCount(albumUri: string, filterMediaType?: string): Promise; } \ No newline at end of file diff --git a/feature/thirdselect/src/main/ets/default/utils/SmartPickerUtils.ts b/feature/thirdselect/src/main/ets/default/utils/SmartPickerUtils.ts index 926badea..e978903e 100644 --- a/feature/thirdselect/src/main/ets/default/utils/SmartPickerUtils.ts +++ b/feature/thirdselect/src/main/ets/default/utils/SmartPickerUtils.ts @@ -15,7 +15,8 @@ import { AlbumDefine, Constants } from '@ohos/common'; import Want from '@ohos.app.ability.Want'; -import { SmartPickerManager, RecommendationOptions } from '../common/SmartPickerManager'; +import type { RecommendationOptions } from '../common/SmartPickerManager'; +import { SmartPickerManager } from '../common/SmartPickerManager'; import SmartPickerConstants from '../common/SmartPickerConstants'; import { Log } from '@ohos/common/src/main/ets/default/utils/Log'; @@ -59,7 +60,7 @@ export class SmartPickerUtils { static getThumbnailSafe(sourceUri: string, path: string, size?): string { try { if (size) { - if (size.width != 0 && size.height != 0) { + if (size.width !== 0 && size.height !== 0) { return `${sourceUri}?oper=thumbnail&width=${size.width}&height=${size.height}&path=${path}`; } else { Log.warn(TAG, 'getThumbnailSafe with width==0 and height==0, so do not use thumbnail' + JSON.stringify(size)); diff --git a/feature/thirdselect/src/main/ets/default/view/ThirdSelectPhotoGridBase.ets b/feature/thirdselect/src/main/ets/default/view/ThirdSelectPhotoGridBase.ets index 512f5fab..05afe983 100644 --- a/feature/thirdselect/src/main/ets/default/view/ThirdSelectPhotoGridBase.ets +++ b/feature/thirdselect/src/main/ets/default/view/ThirdSelectPhotoGridBase.ets @@ -136,7 +136,7 @@ export struct ThirdSelectPhotoGridBase { if (this.isShowSmartRecommendTabBar) { this.selectParams.cameraAble = this.smartRecommendTabItems[this.currentSmartRecommendTabIndex].isCameraAble(); } - this.dataSource.changeDataImpl(this.currentSmartRecommendTabIndex == 0 ? this.photoDataImpl : this.smartPickerDataImpl); + this.dataSource.changeDataImpl(this.currentSmartRecommendTabIndex === 0 ? this.photoDataImpl : this.smartPickerDataImpl); this.smartRecommendTabItems[this.currentSmartRecommendTabIndex].setUserClickTab(true); this.dataSource.setAlbumUri(this.smartRecommendTabItems[this.currentSmartRecommendTabIndex].getAlbumUri()); this.dataSource.resetActiveWindow(); @@ -281,10 +281,10 @@ export struct ThirdSelectPhotoGridBase { onSmartPickerRecommendInfoListReady(pickerRecommendInfoList: SmartPickerRecommendInfo[], dataAdapter: SmartPickerDataAdapter): void { let param: SelectParams = router.getParams() as SelectParams; - if (pickerRecommendInfoList == undefined || pickerRecommendInfoList == null || pickerRecommendInfoList.length == 0) { + if (pickerRecommendInfoList === undefined || pickerRecommendInfoList === null || pickerRecommendInfoList.length === 0) { return; } - if (this.smartPickerDataImpl == undefined || this.smartPickerDataImpl == null) { + if (this.smartPickerDataImpl === undefined || this.smartPickerDataImpl === null) { this.smartPickerDataImpl = new SmartPickerDataImpl(); this.smartPickerDataImpl.setDataAdapter(dataAdapter); } diff --git a/feature/thirdselect/src/main/ets/default/view/ThirdSelectSmartRecommendTabBar.ets b/feature/thirdselect/src/main/ets/default/view/ThirdSelectSmartRecommendTabBar.ets index ef074c99..9dd8331c 100644 --- a/feature/thirdselect/src/main/ets/default/view/ThirdSelectSmartRecommendTabBar.ets +++ b/feature/thirdselect/src/main/ets/default/view/ThirdSelectSmartRecommendTabBar.ets @@ -39,16 +39,16 @@ export struct ThirdSelectSmartRecommendTabBar { ForEach(this.smartRecommendTabItems, (item: SmartPickerRecommendTabInfo, index: number) => { Row() { Text(this.getTabTitle(item)) - .fontColor(this.currentTabIndex == index ? $r('sys.color.ohos_id_color_text_primary_dark') : $r('sys.color.ohos_id_color_text_secondary')) + .fontColor(this.currentTabIndex === index ? $r('sys.color.ohos_id_color_text_primary_dark') : $r('sys.color.ohos_id_color_text_secondary')) .fontSize($r('sys.float.ohos_id_text_size_button3')) .fontWeight(FontWeight.Regular) .draggable(false) .margin({ left: $r('app.float.picker_smart_recommend_tab_text_margin_left') }) .lineHeight($r('app.float.picker_smart_recommend_tab_text_height')) } - .backgroundColor(this.currentTabIndex == index ? $r('sys.color.ohos_id_color_secondary') : $r('sys.color.ohos_id_color_button_normal')) + .backgroundColor(this.currentTabIndex === index ? $r('sys.color.ohos_id_color_secondary') : $r('sys.color.ohos_id_color_button_normal')) .height($r('app.float.picker_smart_recommend_tab_height')) - .margin({ left: index == 0 ? 0 : $r('app.float.picker_smart_recommend_tab_margin_left') }) + .margin({ left: index === 0 ? 0 : $r('app.float.picker_smart_recommend_tab_margin_left') }) .padding({ left: $r('app.float.picker_smart_recommend_tab_left_padding'), right: $r('app.float.picker_smart_recommend_tab_right_padding') }) .borderRadius(SmartPickerConstants.RECOMMEND_TAB_BORDER_RADIUS) .key('pickerRecommendTab_' + index)