1 添加picker照片推荐能力

2 代码规范问题处理,代码优化

Signed-off-by: wangqixu <wangqixu2@huawei.com>
This commit is contained in:
wangqixu 2023-12-16 10:41:56 +08:00
parent 83cce3dd4e
commit 4d731b27d9
20 changed files with 96 additions and 102 deletions

View File

@ -33,10 +33,10 @@ export class GetItemsCallback implements AsyncCallback<MediaItem[]> {
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}`);

View File

@ -33,10 +33,10 @@ export class GetMediaCountCallback implements AsyncCallback<number> {
}
// 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);

View File

@ -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) {

View File

@ -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<FileAsset> {

View File

@ -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 {

View File

@ -49,12 +49,11 @@ 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<string> = [
photoAccessHelper.PhotoKeys.URI.toString(),
photoAccessHelper.PhotoKeys.PHOTO_TYPE.toString(),
@ -72,6 +71,6 @@ export default class SmartPickerConstants {
photoAccessHelper.PhotoKeys.DATE_TRASHED.toString(),
photoAccessHelper.PhotoKeys.HIDDEN.toString(),
photoAccessHelper.PhotoKeys.SIZE.toString()
]
];
}

View File

@ -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<SmartPickerRecommendInfo[]>, recommendationOptions: RecommendationOptions, param?: string) {
getTabInfoList(callback: AsyncCallback<SmartPickerRecommendInfo[]>, 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<MediaItem[]>, param: QueryParam) {
getData(callback: AsyncCallback<MediaItem[]>, 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);
})
});
}
}
}

View File

@ -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<MediaItem[]>, 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);
})
});
}
}

View File

@ -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;

View File

@ -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() {

View File

@ -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<SmartPickerRecommendInfo[]> {
private manager: SmartPickerManager;

View File

@ -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<SmartPickerRecommendInfo>, dataAdapter: SmartPickerDataAdapter): void;

View File

@ -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 {
}
}

View File

@ -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;

View File

@ -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);
@ -148,7 +148,7 @@ export class SmartPickerPhotosDataImpl implements SmartPickerDataInterface {
this.getLabelPhotoData(callback, albumUri, start, count, filterMediaType);
}
private getLabelPhotoData(callback: AsyncCallback<MediaItem[]>, albumUri: string, startIndex?: number, count?: number, filterMediaType?: string) {
private getLabelPhotoData(callback: AsyncCallback<MediaItem[]>, 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);

View File

@ -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<common.UIAbilityContext>('photosAbilityContext');

View File

@ -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<Array<SmartPickerRecommendInfo>>;
getTabInfoList(recommendationOptions: RecommendationOptions, param?: string): Promise<Array<SmartPickerRecommendInfo>>;
getData(callback: any, param: any): void;
getData(callback: AsyncCallback<MediaItem[]>, param: QueryParam): void;
getDataCount(callback: any, param: any): Promise<number>;
getDataCount(albumUri: string, filterMediaType?: string): Promise<number>;
}

View File

@ -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));

View File

@ -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);
}

View File

@ -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)