!358 Partial fix 140: folder entry

Merge pull request !358 from Ivan Tyulyandin/140_part_2
This commit is contained in:
openharmony_ci 2023-06-09 01:03:06 +00:00 committed by Gitee
commit 83720c3e8e
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
21 changed files with 382 additions and 107 deletions

View File

@ -59,7 +59,7 @@ export class BatchDeleteMenuOperation extends ProcessMenuOperation {
}
getResourceFromGrid(dataSource: ItemDataSource): Resource {
if (dataSource && dataSource.isSelect()) {
if (dataSource != null && dataSource.isSelect()) {
return this.menuContext.albumId == MediaConstants.ALBUM_ID_RECYCLE ? $r('app.string.recycle_all_files_tips') : $r('app.string.delete_all_files_tips');
} else if (this.count == 1) {
return this.menuContext.albumId == MediaConstants.ALBUM_ID_RECYCLE ? $r('app.string.recycle_single_file_tips') : $r('app.string.delete_single_file_tips');
@ -91,7 +91,9 @@ export class BatchDeleteMenuOperation extends ProcessMenuOperation {
// 2. onDeleteStart exit selection mode
let onOperationStart: Function = this.menuContext.onOperationStart;
onOperationStart && onOperationStart();
if (onOperationStart != null) {
onOperationStart()
}
this.menuContext.broadCast.emit(BroadcastConstants.DELETE_PROGRESS_DIALOG,
[$r('app.string.action_delete'), this.count]);

View File

@ -120,7 +120,7 @@ export class MainAbility extends Ability {
}
})
finishTrace('onCreate');
appBroadcast.on(BroadcastConstants.THIRD_ROUTE_PAGE, this.thirdRouterPage.bind(this));
appBroadcast.on(BroadcastConstants.THIRD_ROUTE_PAGE, (): Promise<void> => this.thirdRouterPageBindImpl());
Log.info(this.TAG, 'Application onCreate end');
}
@ -201,7 +201,11 @@ export class MainAbility extends Ability {
}
async thirdRouterPage(): Promise<void> {
let entryFrom: number = AppStorage.Get<number>(Constants.ENTRY_FROM_HAP);
return await this.thirdRouterPageBindImpl()
}
private async thirdRouterPageBindImpl(): Promise<void> {
let entryFrom = AppStorage.Get<number>(Constants.ENTRY_FROM_HAP);
Log.info(this.TAG, "thirdRouterPage entryFromHap: " + entryFrom);
if (entryFrom == Constants.ENTRY_FROM_NONE) {
return;

View File

@ -26,7 +26,7 @@ export struct NoPhotoIndexComponent {
// set an initial value temporarily, later change to 0.
@State imageSize: number = 0;
private reSizeFunc = this.reSizeLayout.bind(this);
private reSizeFunc = (): void => this.reSizeLayoutBindImpl();
aboutToAppear(): void {
Log.info(this.TAG, 'aboutToAppear');
@ -35,6 +35,10 @@ export struct NoPhotoIndexComponent {
}
reSizeLayout(): void {
this.reSizeLayoutBindImpl()
}
private reSizeLayoutBindImpl(): void {
this.updateImageSize();
}

View File

@ -66,7 +66,7 @@ struct MediaOperationPage {
this.albumsDataSource.setBlackList(blackList)
this.onActive();
this.loadAlbums()
this.onMenuClicked = this.onMenuClicked.bind(this);
this.onMenuClicked = (action: Action): void => this.onMenuClickedBindImpl(action);
this.broadCast.on(BroadcastConstants.MEDIA_OPERATION, (albumInfo: SimpleAlbumDataItem, completedFunc?: Function): void => {
router.back({
@ -89,6 +89,10 @@ struct MediaOperationPage {
}
onMenuClicked(action: Action): void {
this.onMenuClickedBindImpl(action)
}
private onMenuClickedBindImpl(action: Action): void {
Log.info(TAG, "onMenuClicked, actionID: " + action.actionID);
if (action === Action.CANCEL) {
@ -104,8 +108,8 @@ struct MediaOperationPage {
createNewAlbum(): void {
Log.info(TAG, 'createNewAlbum');
let menuContext = new MenuContext();
this.onOperationStart = this.onOperationStart.bind(this);
this.onOperationEnd = this.onOperationEnd.bind(this);
this.onOperationStart = (): void => this.onOperationStartBindImpl();
this.onOperationEnd = (): void => this.onOperationEndBindImpl();
menuContext
.withOperationStartCallback(this.onOperationStart)
.withOperationEndCallback(this.onOperationEnd)
@ -118,9 +122,17 @@ struct MediaOperationPage {
}
onOperationStart(): void {
this.onOperationStartBindImpl()
}
private onOperationStartBindImpl(): void {
}
onOperationEnd(): void {
this.onOperationEndBindImpl()
}
private onOperationEndBindImpl(): void {
}
updateListCardWidth(): void {

View File

@ -27,11 +27,15 @@ export struct SaveImageDialog {
controller: CustomDialogController;
controllerClose(): void {
this.controllerCloseBindImpl()
}
private controllerCloseBindImpl(): void {
this.controller.close()
}
aboutToAppear(): void {
this.broadCast.on(BroadcastConstants.EXIT_SAVE_PROGRESS_CLOSE, this.controllerClose.bind(this));
this.broadCast.on(BroadcastConstants.EXIT_SAVE_PROGRESS_CLOSE, (): void => this.controllerCloseBindImpl());
}
build() {

View File

@ -113,14 +113,18 @@ export struct AlbumSetPage {
}
onMenuClicked(action: Action, arg: Object[]): void {
this.onMenuClickedBindImpl(action, arg)
}
private onMenuClickedBindImpl(action: Action, arg: Object[]): void {
Log.info(TAG, 'onMenuClicked, action: ' + action.actionID);
let menuContext: MenuContext;
let menuOperation: MenuOperation;
if (action === Action.NEW) {
menuContext = new MenuContext();
menuContext
.withOperationStartCallback(this.onOperationStart.bind(this))
.withOperationEndCallback(this.onNewEnd.bind(this))
.withOperationStartCallback((): void => this.onOperationStartBindImpl())
.withOperationEndCallback((): void => this.onNewEndBindImpl())
.withDataSource(this.albumsDataSource)
.withBroadCast(this.broadCast);
menuOperation = new AlbumSetNewMenuOperation(menuContext);
@ -131,8 +135,8 @@ export struct AlbumSetPage {
menuContext = new MenuContext();
menuContext
.withDataSource(this.albumsDataSource)
.withOperationStartCallback(this.onOperationStart.bind(this))
.withOperationEndCallback(this.onRenameEnd.bind(this))
.withOperationStartCallback((): void => this.onOperationStartBindImpl())
.withOperationEndCallback((): void => this.onRenameEndBindImpl())
.withBroadCast(this.broadCast);
menuOperation = new AlbumSetRenameMenuOperation(menuContext);
menuOperation.doAction();
@ -140,8 +144,8 @@ export struct AlbumSetPage {
menuContext = new MenuContext();
menuContext
.withDataSource(this.albumsDataSource)
.withOperationStartCallback(this.onOperationStart.bind(this))
.withOperationEndCallback(this.onDeleteEnd.bind(this))
.withOperationStartCallback((): void => this.onOperationStartBindImpl())
.withOperationEndCallback((): void => this.onDeleteEndBindImpl())
.withBroadCast(this.broadCast);
menuOperation = new AlbumSetDeleteMenuOperation(menuContext);
menuOperation.doAction();
@ -149,23 +153,39 @@ export struct AlbumSetPage {
}
onOperationStart(): void {
this.onOperationStartBindImpl()
}
private onOperationStartBindImpl(): void {
Log.debug(TAG, 'onOperationStart');
mediaObserver.unregisterObserver(this.dataObserver);
}
private onDeleteEnd(): void {
this.onDeleteEndBindImpl()
}
private onDeleteEndBindImpl(): void {
this.isAlbumSetSelectedMode = false;
this.albumsDataSource.dataRemove();
mediaObserver.registerObserver(this.dataObserver);
}
onNewEnd(): void {
this.onNewEndBindImpl()
}
private onNewEndBindImpl(): void {
Log.debug(TAG, 'onNewEnd');
this.isAlbumSetSelectedMode = false;
mediaObserver.registerObserver(this.dataObserver);
}
onRenameEnd(): void {
this.onRenameEndBindImpl()
}
private onRenameEndBindImpl(): void {
Log.debug(TAG, 'onRenameEnd');
this.isAlbumSetSelectedMode = false;
this.albumsDataSource.notifyDataReload();
@ -173,6 +193,10 @@ export struct AlbumSetPage {
}
onOperationEnd(): void {
this.onOperationEndBindImpl()
}
private onOperationEndBindImpl(): void {
Log.debug(TAG, 'onOperationEnd');
this.isAlbumSetSelectedMode = false;
this.isMediaLibDataChanged = true;
@ -185,10 +209,10 @@ export struct AlbumSetPage {
aboutToAppear(): void {
startTrace('AlbumSetPageAboutToAppear');
Log.info(TAG, 'AlbumSetPageAboutToAppear');
this.appBroadcast.on(BroadcastConstants.BACK_PRESS_EVENT, this.onIndexBackPress.bind(this));
this.appBroadcast.on(BroadcastConstants.ON_TAB_CHANGED, this.onTabChanged.bind(this));
this.appBroadcast.on(BroadcastConstants.BACK_PRESS_EVENT, (clbk: Function): void => this.onIndexBackPressBindImpl(clbk));
this.appBroadcast.on(BroadcastConstants.ON_TAB_CHANGED, (index: number): void => this.onTabChangedBindImpl(index));
this.appBroadcast.on(BroadcastConstants.RESET_ZERO, this.onResetZero.bind(this));
this.appBroadcast.on(BroadcastConstants.RESET_ZERO, (pageNumber: number): void => this.onResetZeroBindImpl(pageNumber));
this.isInCurrentTab = true;
@ -197,7 +221,7 @@ export struct AlbumSetPage {
this.initGridRowCount();
let self = this;
this.onMenuClicked = this.onMenuClicked.bind(this);
this.onMenuClicked = (action: Action, args: Object[]): void => this.onMenuClickedBindImpl(action, args);
this.broadCast.on(BroadcastConstants.SELECT, (index: number): void => this.onSelect(index));
screenManager.on(screenManager.ON_WIN_SIZE_CHANGED, (): void => {
@ -222,10 +246,10 @@ export struct AlbumSetPage {
aboutToDisappear(): void {
Log.info(TAG, 'aboutToDisappear');
this.broadCast.off(null, null);
this.appBroadcast.off(BroadcastConstants.BACK_PRESS_EVENT, this.onIndexBackPress.bind(this));
this.appBroadcast.off(BroadcastConstants.ON_TAB_CHANGED, this.onTabChanged.bind(this));
this.appBroadcast.off(BroadcastConstants.RESET_STATE_EVENT, this.onStateReset.bind(this));
this.appBroadcast.off(BroadcastConstants.RESET_ZERO, this.onResetZero.bind(this));
this.appBroadcast.off(BroadcastConstants.BACK_PRESS_EVENT, (clbk: Function): void => this.onIndexBackPressBindImpl(clbk));
this.appBroadcast.off(BroadcastConstants.ON_TAB_CHANGED, (index: number): void => this.onTabChangedBindImpl(index));
this.appBroadcast.off(BroadcastConstants.RESET_STATE_EVENT, (index: number): void => this.onStateResetBindImpl(index));
this.appBroadcast.off(BroadcastConstants.RESET_ZERO, (pageNumber: number): void => this.onResetZeroBindImpl(pageNumber));
mediaObserver.unregisterObserver(this.dataObserver);
this.dataObserver = undefined;
this.scroller = undefined;
@ -251,11 +275,15 @@ export struct AlbumSetPage {
if (newAlbum != null) {
AppStorage.Delete(Constants.APP_KEY_NEW_ALBUM);
this.broadCast.emit(BroadcastConstants.SHOW_COPY_OR_MOVE_DIALOG,
[this.moveOperation.bind(this), this.copyOperation.bind(this)]);
[(): void => this.moveOperationBindImpl(), (): void => this.copyOperationBindImpl()]);
}
}
private copyOperation(): void {
this.copyOperationBindImpl()
}
private copyOperationBindImpl(): void {
let mediaItems = AppStorage.Get<MediaDataItem[]>(Constants.APP_KEY_NEW_ALBUM_SELECTED);
let targetAlbum = AppStorage.Get<SimpleAlbumDataItem>(Constants.APP_KEY_NEW_ALBUM_TARGET);
if (mediaItems == undefined || targetAlbum == undefined) {
@ -264,8 +292,8 @@ export struct AlbumSetPage {
}
let menuContext = new MenuContext();
menuContext.withItems(mediaItems)
.withOperationStartCallback(this.onOperationStart.bind(this))
.withOperationEndCallback(this.onOperationEnd.bind(this))
.withOperationStartCallback((): void => this.onOperationStartBindImpl())
.withOperationEndCallback((): void => this.onOperationEndBindImpl())
.withBroadCast(this.broadCast)
.withAlbumInfo(targetAlbum);
let menuOperation = new CopyMenuOperation(menuContext);
@ -273,6 +301,10 @@ export struct AlbumSetPage {
}
private moveOperation(): void {
this.moveOperationBindImpl()
}
private moveOperationBindImpl(): void {
let mediaItems = AppStorage.Get<MediaDataItem[]>(Constants.APP_KEY_NEW_ALBUM_SELECTED);
let targetAlbum = AppStorage.Get<SimpleAlbumDataItem>(Constants.APP_KEY_NEW_ALBUM_TARGET);
if (mediaItems == undefined || undefined == targetAlbum) {
@ -280,8 +312,8 @@ export struct AlbumSetPage {
}
let menuContext = new MenuContext();
menuContext.withItems(mediaItems)
.withOperationStartCallback(this.onOperationStart.bind(this))
.withOperationEndCallback(this.onOperationEnd.bind(this))
.withOperationStartCallback((): void => this.onOperationStartBindImpl())
.withOperationEndCallback((): void => this.onOperationEndBindImpl())
.withBroadCast(this.broadCast)
.withAlbumInfo(targetAlbum);
let menuOperation = new MoveMenuOperation(menuContext);
@ -298,6 +330,10 @@ export struct AlbumSetPage {
}
onIndexBackPress(callback: Function): void {
this.onIndexBackPressBindImpl(callback)
}
private onIndexBackPressBindImpl(callback: Function): void {
if (this.isInCurrentTab) {
if (this.isAlbumSetSelectedMode) {
callback(true);
@ -309,12 +345,20 @@ export struct AlbumSetPage {
}
onStateReset(index: number): void {
this.onStateResetBindImpl(index)
}
private onStateResetBindImpl(index: number): void {
if (index == Constants.ALBUM_PAGE_INDEX) {
this.isAlbumSetSelectedMode = false;
}
}
onTabChanged(index: number): void {
this.onTabChangedBindImpl(index)
}
private onTabChangedBindImpl(index: number): void {
if (index == Constants.ALBUM_PAGE_INDEX) {
this.isInCurrentTab = true;
this.onActive();
@ -361,6 +405,10 @@ export struct AlbumSetPage {
}
onResetZero(pageNumber: number): void {
this.onResetZeroBindImpl(pageNumber)
}
private onResetZeroBindImpl(pageNumber: number): void {
if (pageNumber == Constants.ALBUM_PAGE_INDEX) {
this.scroller.scrollEdge(Edge.Top);
}

View File

@ -97,7 +97,7 @@ struct AlbumSelect {
}
this.loadAlbums();
this.onMenuClicked = this.onMenuClicked.bind(this);
this.onMenuClicked = (action: Action): void => this.onMenuClickedBindImpl(action);
this.updateActionBar();
finishTrace('AlbumSetPageAboutToAppear');
}
@ -157,6 +157,10 @@ struct AlbumSelect {
}
private onMenuClicked(action: Action): void {
this.onMenuClickedBindImpl(action)
}
private onMenuClickedBindImpl(action: Action): void {
Log.debug(TAG, 'onMenuClicked, action: ' + action.actionID);
if (action === Action.CANCEL) {
Log.info(TAG, 'clear SelectManager data');

View File

@ -118,6 +118,10 @@ struct PhotoBrowser {
private globalThis = GlobalContext.getContext();
onMenuClicked(action: Action): void {
this.onMenuClickedBindImpl(action)
}
private onMenuClickedBindImpl(action: Action): void {
Log.info(TAG, "onMenuClicked, action: " + action.actionID + ", isPullingDown: " + this.isPullingDown);
if (this.isPullingDown) {
return;
@ -166,7 +170,7 @@ struct PhotoBrowser {
.withDeletePageFromType(BroadcastConstants.DELETE_FROM_BROWSER)
.withAlbumId( Boolean<string>(this.albumInfo.id).valueOf() ? this.albumInfo.id : (Boolean<SimpleAlbumDataItem>(this.albumInfo).valueOf() ? this.albumInfo.toString() : "") )
.withBroadCast(this.broadCast)
.withOperationEndCallback(this.onDeleteEnd.bind(this))
.withOperationEndCallback((): void => this.onDeleteEndBindImpl())
menuOperation = new BatchDeleteMenuOperation(menuContext);
} else if (action === Action.CLEAR_RECYCLE) {
if (currentPhoto == undefined) {
@ -174,14 +178,14 @@ struct PhotoBrowser {
}
menuContext.withItems([currentPhoto])
.withBroadCast(this.broadCast)
.withOperationEndCallback(this.onDeleteEnd.bind(this))
.withOperationEndCallback((): void => this.onDeleteEndBindImpl())
menuOperation = new ClearRecycleMenuOperation(menuContext);
} else if (action === Action.RECOVER) {
if (currentPhoto == undefined) {
return;
}
menuContext = new MenuContext();
this.onDeleteEnd = this.onDeleteEnd.bind(this);
this.onDeleteEnd = (): void => this.onDeleteEndBindImpl();
menuContext.withItems([currentPhoto])
.withOperationEndCallback(this.onDeleteEnd)
.withBroadCast(this.broadCast)
@ -261,6 +265,10 @@ struct PhotoBrowser {
}
private onDeleteEnd(): void {
this.onDeleteEndBindImpl()
}
private onDeleteEndBindImpl(): void {
Log.debug(TAG, "onDeleteEnd start");
AppStorage.SetOrCreate<number>("isDelete", 0);
this.operateEnd();
@ -312,6 +320,10 @@ struct PhotoBrowser {
}
onPhotoChanged(index: number): void {
this.onPhotoChangedBindImpl(index)
}
private onPhotoChangedBindImpl(index: number): void {
index = Math.min(index, this.browserDataSource.totalCount() - 1);
Log.info(TAG, "onPhotoChanged start " + index);
this.currentIndex = this.isToEdit ? 0 : index;
@ -411,7 +423,11 @@ struct PhotoBrowser {
return this.browserDataSource.getDataByIndex(index);
}
async onMoveEnd(err, count, total): Promise<void> {
async onMoveEnd(err: object, count: number, total: number): Promise<void> {
return await this.onMoveEndBindImpl(err, count, total)
}
async onMoveEndBindImpl(err: object, count: number, total: number): Promise<void> {
Log.debug(TAG, "onMoveEnd count: " + count + ", total: " + total);
if (err != null) {
getResourceString($r('app.string.move_failed_single')).then<void, void>((message: string): void => {
@ -427,7 +443,11 @@ struct PhotoBrowser {
this.appBroadcast.emit(BroadcastConstants.UPDATE_DATA_SOURCE, [currentPhoto]);
}
onCopyEnd(err, count, total): void {
onCopyEnd(err: object, count: number, total: number): void {
this.onCopyEndBindImpl(err, count, total)
}
private onCopyEndBindImpl(err: object, count: number, total: number): void {
Log.debug(TAG, "onCopyEnd count: " + count + ", total: " + total);
this.dataSourceLoadFinish()
if (err != null) {
@ -437,7 +457,11 @@ struct PhotoBrowser {
}
}
async onDownloadEnd(err, count, total): Promise<void> {
async onDownloadEnd(err: object, count: number, total: number): Promise<void> {
return await this.onDownloadEndBindImpl(err, count, total)
}
async onDownloadEndBindImpl(err: object, count: number, total: number): Promise<void> {
Log.debug(TAG, "onDownloadEnd count: " + count + ", total: " + total);
if (err != null) {
getResourceString($r('app.string.download_failed_single')).then<void, void>((message: string): void => {
@ -452,11 +476,15 @@ struct PhotoBrowser {
onBackPress(): boolean {
Log.info(TAG, 'onBackPress');
this.controller.finishAnimation(this.onBackPressInner.bind(this));
this.controller.finishAnimation((): void => this.onBackPressInnerBindImpl());
return true;
}
onBackPressInner(): void {
this.onBackPressInnerBindImpl()
}
private onBackPressInnerBindImpl(): void {
Log.info(TAG, "onBackPressInner " + this.checkedTransition);
if (this.checkedTransition === Constants.PHOTO_TRANSITION_TIMELINE) {
Log.info(TAG, 'onBackPress TimelinePage');
@ -602,7 +630,7 @@ struct PhotoBrowser {
mediaObserver.registerObserver(this.dataObserver);
this.checkedTransition = this.photoBrowserTransition;
this.onMenuClicked = this.onMenuClicked.bind(this);
this.onMenuClicked = (action: Action): void => this.onMenuClickedBindImpl(action);
// register event handling
this.broadCast.on(PhotoConstants.TOGGLE_BAR, (): void => {
@ -696,14 +724,14 @@ struct PhotoBrowser {
albumInfo = params.albumInfo.toString();
}
if (params.pageType === MediaOperationType.Move) {
this.onMoveEnd = this.onMoveEnd.bind(this);
this.onMoveEnd = (err: object, count: number, total: number): Promise<void> => this.onMoveEndBindImpl(err, count, total);
menuContext.withItems([currentPhoto])
.withBroadCast(this.broadCast)
.withAlbumInfo(JSON.parse(albumInfo) as SimpleAlbumDataItem)
.withOperationEndCallback(this.onMoveEnd);
menuOperation = new MoveMenuOperation(menuContext);
} else if (params.pageType === MediaOperationType.Copy) {
this.onCopyEnd = this.onCopyEnd.bind(this);
this.onCopyEnd = (err: object, count: number, total: number): void => this.onCopyEndBindImpl(err, count, total);
menuContext.withItems([currentPhoto])
.withBroadCast(this.broadCast)
.withAlbumInfo(JSON.parse(albumInfo) as SimpleAlbumDataItem)
@ -721,7 +749,7 @@ struct PhotoBrowser {
let menuContext = new MenuContext();
let menuOperation: MenuOperation;
let currentPhoto = this.getCurrentPhoto();
this.onDownloadEnd = this.onDownloadEnd.bind(this);
this.onDownloadEnd = (err: object, count: number, total: number): Promise<void> => this.onDownloadEndBindImpl(err, count, total);
if (currentPhoto == undefined) {
Log.warn(TAG, 'MediaOperation currentPhoto is undefined');
return;
@ -766,7 +794,7 @@ struct PhotoBrowser {
dataSource: this.browserDataSource,
photoSwiperTransition: this.photoBrowserTransition,
swiperController: this.controller,
onPhotoChanged: this.onPhotoChanged.bind(this)
onPhotoChanged: (index: number): void => this.onPhotoChangedBindImpl(index)
})
}
if (!this.isFromViewData) {

View File

@ -113,7 +113,7 @@ struct SelectPhotoBrowser {
} else {
this.selectPhotoTransition = '';
}
this.onMenuClicked = this.onMenuClicked.bind(this);
this.onMenuClicked = (action: Action): void => this.onMenuClickedBindImpl(action);
// register event handling
this.broadCast.on(PhotoConstants.TOGGLE_BAR, (event: Object): void => {
@ -158,6 +158,10 @@ struct SelectPhotoBrowser {
}
onPhotoChanged(index: number): void {
this.onPhotoChangedBindImpl(index)
}
private onPhotoChangedBindImpl(index: number): void {
this.currentIndex = index;
this.isSelected = this.getCurrentPhoto().isSelect;
this.browserDataSource.notifyDataChange(index);
@ -186,6 +190,10 @@ struct SelectPhotoBrowser {
}
onMenuClicked(action: Action): void {
this.onMenuClickedBindImpl(action)
}
private onMenuClickedBindImpl(action: Action): void {
Log.debug(TAG, "onMenuClicked, action: " + action.actionID);
if (action === Action.BACK) {
this.onBackPress();
@ -214,7 +222,7 @@ struct SelectPhotoBrowser {
PhotoSwiper({
dataSource: this.browserDataSource,
photoSwiperTransition: this.selectPhotoTransition,
onPhotoChanged: this.onPhotoChanged.bind(this),
onPhotoChanged: (index: number): void => this.onPhotoChanged(index),
swiperController: this.controller
})
ThirdSelectPhotoBrowserActionBar({

View File

@ -46,6 +46,10 @@ struct VideoBrowser {
}
private onMenuClicked(action: Action): void {
this.onMenuClickedBindImpl(action)
}
private onMenuClickedBindImpl(action: Action): void {
Log.info(this.TAG, "onMenuClicked, action: " + action.actionID);
let menuOperation: MenuOperation;
if (action === Action.BACK) {
@ -70,7 +74,7 @@ struct VideoBrowser {
Log.info(this.TAG, "uri is " + this.uri);
this.photoDate = DateUtil.getLocalizedDate(this.dateAdded);
this.timeAndLocation = DateUtil.getLocalizedTime(this.dateAdded);
this.onMenuClicked = this.onMenuClicked.bind(this);
this.onMenuClicked = (action: Action): void => this.onMenuClickedBindImpl(action);
screenManager.setSystemUi(false);
finishTrace('VideoBrowserAboutToAppear');
}

View File

@ -64,6 +64,10 @@ struct DistributedAlbumSetPage {
}
onMenuClicked(action: Action, arg: Object[]): void {
this.onMenuClickedBindImpl(action, arg)
}
private onMenuClickedBindImpl(action: Action, arg: Object[]): void {
Log.info(TAG, 'onMenuClicked, action: ' + action.actionID);
if (action === Action.BACK) {
router.back();
@ -82,14 +86,14 @@ struct DistributedAlbumSetPage {
Log.warn(TAG, 'param is error');
}
this.onMenuClicked = this.onMenuClicked.bind(this);
this.onMenuClicked = (action: Action, args: Object[]): void => this.onMenuClickedBindImpl(action, args);
this.broadCast.on(Constants.ON_LOADING_FINISHED, (size: number): void => {
Log.info(TAG, 'ON_LOADING_FINISHED size: ' + size);
this.isEmpty = size == 0;
});
broadcastManager.getBroadcast().on(BroadcastConstants.ON_REMOTE_CHANGED,
this.onUpdateRemoteDevice.bind(this));
(res: string, deviceId: number): void => this.onUpdateRemoteDeviceBindImpl(res, deviceId));
mediaObserver.registerObserver(this.dataObserver);
@ -104,7 +108,7 @@ struct DistributedAlbumSetPage {
aboutToDisappear(): void {
broadcastManager.getBroadcast().off(BroadcastConstants.ON_REMOTE_CHANGED,
this.onUpdateRemoteDevice.bind(this));
(res: string, deviceId: number): void => this.onUpdateRemoteDeviceBindImpl(res, deviceId));
mediaObserver.unregisterObserver(this.dataObserver);
}
@ -135,6 +139,10 @@ struct DistributedAlbumSetPage {
}
private onUpdateRemoteDevice(res, deviceId): void {
this.onUpdateRemoteDeviceBindImpl(res, deviceId)
}
private onUpdateRemoteDeviceBindImpl(res, deviceId): void {
Log.debug(TAG, 'onUpdateRemoteDevice');
if (!this.isActive) {

View File

@ -40,6 +40,10 @@ export struct CropImageShow {
private prePinch: number = 0;
onCropResetClicked(): void {
this.onCropResetClickedBindImpl()
}
private onCropResetClickedBindImpl(): void {
Log.debug(this.TAG, 'crop reset is clicked');
this.cropEdit.reset();
this.isCropReset = this.cropEdit.couldReset();
@ -102,7 +106,7 @@ export struct CropImageShow {
aboutToAppear(): void {
Log.debug(this.TAG, 'Photo CropImageShow called');
this.broadCast.on(Constants.CROP_RESET_CLICKED, this.onCropResetClicked.bind(this));
this.broadCast.on(Constants.CROP_RESET_CLICKED, (): void => this.onCropResetClickedBindImpl());
this.flexHeight = this.isVerticalScreen
? this.screenHeight - Constants.TOP_BAR_SIZE - Constants.BOTTOM_TOOL_BAR_SIZE
: this.screenWidth - Constants.TOP_BAR_SIZE;

View File

@ -66,7 +66,7 @@ struct Edit {
onBackPress(): boolean {
if (this.isCropReset) {
this.broadCast.emit(BroadcastConstants.SHOW_EDIT_EXIT_PHOTO_DIALOG, [this.discardCallback.bind(this)]);
this.broadCast.emit(BroadcastConstants.SHOW_EDIT_EXIT_PHOTO_DIALOG, [(): void => this.discardCallbackBindImpl()]);
} else {
router.back();
}
@ -74,10 +74,18 @@ struct Edit {
}
discardCallback(): void {
this.discardCallbackBindImpl()
}
private discardCallbackBindImpl(): void {
Log.debug(this.TAG, 'discardCallback called');
}
loadFailedCallback(): void {
this.loadFailedCallbackBindImpl()
}
private loadFailedCallbackBindImpl(): void {
this.isLoadFailed = true;
}
@ -86,7 +94,7 @@ struct Edit {
if (this.mediaItem != null) {
this.isLoadFailed = false;
this.editorManager.initialize(
this.mediaItem, PhotoEditMode.EDIT_MODE_CROP, this.loadFailedCallback.bind(this));
this.mediaItem, PhotoEditMode.EDIT_MODE_CROP, (): void => this.loadFailedCallbackBindImpl());
}
this.cropEdit = this.editorManager.getPhotoEditBaseInstance(PhotoEditMode.EDIT_MODE_CROP) as PhotoEditCrop;
if (this.isVerticalScreen) {

View File

@ -49,8 +49,9 @@ struct FormEditorPage {
albumId: string = '';
@State time: number = 30;
@State intervalTime: Resource = $r('app.string.fa_play_interval_time_30');
private saveDataFunc = this.saveData.bind(this);
private onChangeFunc = this.onChange.bind(this);
private saveDataFunc = (albumName: string, albumId: string, displayName: object, index: number, isShow: boolean): Promise<void> =>
this.saveDataBindImpl(albumName, albumId, displayName, index, isShow);
private onChangeFunc = (value: number): void => this.onTabChangedBindImpl(value);
settingController: CustomDialogController = new CustomDialogController({
builder: SettingDialog(),
autoCancel: false,
@ -136,6 +137,10 @@ struct FormEditorPage {
}
async saveData(albumName: string, albumId: string, displayName: object, index: number, isShow: boolean): Promise<void> {
return await this.saveDataBindImpl(albumName, albumId, displayName, index, isShow)
}
async saveDataBindImpl(albumName: string, albumId: string, displayName: object, index: number, isShow: boolean): Promise<void> {
Log.debug(TAG, "saveData start! " + albumName + " " + displayName + " " + index);
let msgDisplayName = '';
if (displayName instanceof String) {
@ -235,7 +240,11 @@ struct FormEditorPage {
this.appBroadcast.off(Constants.FROM_PLAYBACK_INTERVAL, this.onChangeFunc);
}
onChange(value): void {
onChange(value: number): void {
this.onTabChangedBindImpl(value)
}
private onTabChangedBindImpl(value: number): void {
this.time = value;
this.setIntervalTime();
AppStorage.SetOrCreate(Constants.FROM_PLAYBACK_INTERVAL, this.time);

View File

@ -79,6 +79,10 @@ struct NewAlbumPage {
}
onMenuClicked(action: Action): void {
this.onMenuClickedBindImpl(action)
}
private onMenuClickedBindImpl(action: Action): void {
Log.info(TAG, "onMenuClicked, action: " + action.actionID);
if (action === Action.CANCEL) {
this.groupDataSource.setSelect(false)
@ -138,6 +142,10 @@ struct NewAlbumPage {
}
onUpdateFavorAndSelectState(item: MediaDataItem): void {
this.onUpdateFavorAndSelectStateBindImpl(item)
}
private onUpdateFavorAndSelectStateBindImpl(item: MediaDataItem): void {
this.onUpdateFavorState(item);
this.onSelect(this.groupDataSource.getIndexByItem(item));
}
@ -156,9 +164,17 @@ struct NewAlbumPage {
}
onOperationStart(): void {
this.onOperationStartBindImpl()
}
private onOperationStartBindImpl(): void {
}
onOperationEnd(): void {
this.onOperationEndBindImpl()
}
private onOperationEndBindImpl(): void {
if (this.isNewAlbum) {
AppStorage.Delete(Constants.APP_KEY_NEW_ALBUM);
AppStorage.Delete(Constants.APP_KEY_NEW_ALBUM_TARGET);
@ -179,8 +195,8 @@ struct NewAlbumPage {
private copyOperation(): void {
let menuContext = new MenuContext();
this.onOperationStart = this.onOperationStart.bind(this);
this.onOperationEnd = this.onOperationEnd.bind(this);
this.onOperationStart = (): void => this.onOperationStartBindImpl();
this.onOperationEnd = (): void => this.onOperationEndBindImpl();
menuContext
.withDataSource(this.groupDataSource)
.withOperationStartCallback(this.onOperationStart)
@ -204,7 +220,7 @@ struct NewAlbumPage {
this.groupDataSource.notifyDataReload()
this.isHideScrollBar = (this.groupDataSource.totalCount() <= Constants.GRID_SCROLL_BAR_VISIBLE_THRESHOLD)
})
this.onMenuClicked = this.onMenuClicked.bind(this);
this.onMenuClicked = (action: Action): void => this.onMenuClickedBindImpl(action);
this.broadCast.on(BroadcastConstants.SELECT, (index: number): void => this.onSelect(index));
this.broadCast.on(BroadcastConstants.JUMP_PHOTO_BROWSER, (name: string, item: MediaDataItem): void => {
@ -215,7 +231,7 @@ struct NewAlbumPage {
this.jumpToThirdPhotoBrowser(name, item)
})
this.appBroadcast.on(BroadcastConstants.UPDATE_DATA_SOURCE, this.onUpdateFavorAndSelectState.bind(this));
this.appBroadcast.on(BroadcastConstants.UPDATE_DATA_SOURCE, (item: MediaDataItem): void => this.onUpdateFavorAndSelectStateBindImpl(item));
this.initGridRowCount();
this.moreMenuList = [];
@ -278,7 +294,7 @@ struct NewAlbumPage {
aboutToDisappear(): void {
this.broadCast.off(null, null);
this.appBroadcast.off(BroadcastConstants.UPDATE_DATA_SOURCE, this.onUpdateFavorAndSelectState.bind(this));
this.appBroadcast.off(BroadcastConstants.UPDATE_DATA_SOURCE, (item: MediaDataItem): void => this.onUpdateFavorAndSelectStateBindImpl(item));
}
build() {

View File

@ -104,6 +104,10 @@ struct PhotoGridPage {
}
onMenuClicked(action: Action): void {
this.onMenuClickedBindImpl(action)
}
private onMenuClickedBindImpl(action: Action): void {
Log.info(TAG, "onMenuClicked, action: " + action.actionID);
let menuContext: MenuContext;
let menuOperation: MenuOperation;
@ -121,8 +125,8 @@ struct PhotoGridPage {
this.onSelect()
} else if (action === Action.DELETE) {
menuContext = new MenuContext();
this.onDeleteStart = this.onDeleteStart.bind(this);
this.onDeleteEnd = this.onDeleteEnd.bind(this);
this.onDeleteStart = (): void => this.onDeleteStartBindImpl();
this.onDeleteEnd = (err: object): void => this.onDeleteEndBindImpl(err);
menuContext
.withDeletePageFromType(BroadcastConstants.DELETE_FROM_GRID)
.withAlbumId(this.albumInfo.id)
@ -141,8 +145,8 @@ struct PhotoGridPage {
this.openDetailsDialog();
} else if (action === Action.CLEAR_RECYCLE) {
menuContext = new MenuContext();
this.onDeleteStart = this.onDeleteStart.bind(this);
this.onDeleteEnd = this.onDeleteEnd.bind(this);
this.onDeleteStart = (): void => this.onDeleteStartBindImpl();
this.onDeleteEnd = (err: object): void => this.onDeleteEndBindImpl(err);
menuContext
.withDataSource(this.groupDataSource)
.withOperationStartCallback(this.onDeleteStart)
@ -152,8 +156,8 @@ struct PhotoGridPage {
menuOperation.doAction();
} else if (action === Action.RECOVER) {
menuContext = new MenuContext();
this.onDeleteStart = this.onDeleteStart.bind(this);
this.onDeleteEnd = this.onDeleteEnd.bind(this);
this.onDeleteStart = (): void => this.onDeleteStartBindImpl();
this.onDeleteEnd = (err: object): void => this.onDeleteEndBindImpl(err);
menuContext
.withDataSource(this.groupDataSource)
.withOperationStartCallback(this.onDeleteStart)
@ -168,8 +172,8 @@ struct PhotoGridPage {
} else if (action === Action.NEW) {
this.routeToAddMediaPage();
} else if (action === Action.DOWNLOAD) {
this.onDownloadStart = this.onDownloadStart.bind(this);
this.onDownloadEnd = this.onDownloadEnd.bind(this);
this.onDownloadStart = (): void => this.onDownloadStartBindImpl();
this.onDownloadEnd = (err: object, count: number, total: number): Promise<void> => this.onDownloadEndBindImpl(err, count, total);
menuContext = new MenuContext();
menuContext
.withDataSource(this.groupDataSource)
@ -230,11 +234,19 @@ struct PhotoGridPage {
}
onCopyStart(): void {
this.onCopyStartBindImpl()
}
private onCopyStartBindImpl(): void {
Log.info(TAG, "onCopyStart");
mediaObserver.unregisterObserver(this.dataObserver);
}
onCopyEnd(err, count, total): void {
onCopyEnd(err: object, count: number, total: number): void {
this.onCopyEndBindImpl(err, count, total)
}
onCopyEndBindImpl(err, count, total): void {
Log.info(TAG, "onCopyEnd count: " + count + ", total: " + total);
this.onModeChange();
mediaObserver.registerObserver(this.dataObserver);
@ -249,11 +261,19 @@ struct PhotoGridPage {
}
onDownloadStart(): void {
this.onDownloadStartBindImpl()
}
private onDownloadStartBindImpl(): void {
Log.info(TAG, "onDownloadStart");
mediaObserver.unregisterObserver(this.dataObserver);
}
async onDownloadEnd(err, count, total): Promise<void> {
async onDownloadEnd(err: object, count: number, total: number): Promise<void> {
return await this.onDownloadEndBindImpl(err, count, total)
}
async onDownloadEndBindImpl(err: object, count: number, total: number): Promise<void> {
Log.info(TAG, "onDownloadEnd count: " + count + ", total: " + total);
this.onModeChange();
mediaObserver.registerObserver(this.dataObserver);
@ -277,11 +297,19 @@ struct PhotoGridPage {
}
onMoveStart(): void {
this.onMoveStartBindImpl()
}
private onMoveStartBindImpl(): void {
Log.info(TAG, "onMoveStart");
mediaObserver.unregisterObserver(this.dataObserver);
}
onMoveEnd(err, count, total): void {
onMoveEnd(err: object, count: number, total: number): void {
this.onMoveEndBindImpl(err, count, total)
}
private onMoveEndBindImpl(err: object, count: number, total: number): void {
Log.info(TAG, "onMoveEnd count: " + count + ", total: " + total);
this.onModeChange();
mediaObserver.registerObserver(this.dataObserver);
@ -295,11 +323,19 @@ struct PhotoGridPage {
}
onDeleteStart(): void {
this.onDeleteStartBindImpl()
}
private onDeleteStartBindImpl(): void {
Log.info(TAG, "onDeleteStart");
mediaObserver.unregisterObserver(this.dataObserver);
}
onDeleteEnd(err): void {
onDeleteEnd(err: object): void {
this.onDeleteEndBindImpl(err)
}
private onDeleteEndBindImpl(err: object): void {
Log.info(TAG, "onDeleteEnd");
this.onModeChange();
mediaObserver.registerObserver(this.dataObserver);
@ -363,6 +399,10 @@ struct PhotoGridPage {
}
private onUpdateFavorAndSelectState(item: MediaDataItem): void {
this.onUpdateFavorAndSelectStateBindImpl(item)
}
private onUpdateFavorAndSelectStateBindImpl(item: MediaDataItem): void {
this.onUpdateFavorState(item);
this.onSelect();
}
@ -389,8 +429,8 @@ struct PhotoGridPage {
private moveOperation(albumInfo: SimpleAlbumDataItem): void {
let menuContext = new MenuContext();
this.onMoveStart = this.onMoveStart.bind(this);
this.onMoveEnd = this.onMoveEnd.bind(this);
this.onMoveStart = (): void => this.onMoveStartBindImpl();
this.onMoveEnd = (err: object, count: number, total: number): void => this.onMoveEndBindImpl(err, count, total);
menuContext.withDataSource(this.groupDataSource)
.withOperationStartCallback(this.onMoveStart)
.withOperationEndCallback(this.onMoveEnd)
@ -403,8 +443,8 @@ struct PhotoGridPage {
private copyOperation(albumInfo: SimpleAlbumDataItem): void {
let menuContext = new MenuContext();
menuContext.withDataSource(this.groupDataSource)
.withOperationStartCallback(this.onCopyStart.bind(this))
.withOperationEndCallback(this.onCopyEnd.bind(this))
.withOperationStartCallback((): void => this.onCopyStartBindImpl())
.withOperationEndCallback((err: object, count: number, total: number): void => this.onCopyEndBindImpl(err, count, total))
.withBroadCast(this.broadCast)
.withAlbumInfo(albumInfo);
let menuOperation = new CopyMenuOperation(menuContext);
@ -431,7 +471,7 @@ struct PhotoGridPage {
}
Log.info(TAG, "reloadGroupItemData");
this.onMenuClicked = this.onMenuClicked.bind(this);
this.onMenuClicked = (action: Action) => this.onMenuClickedBindImpl(action);
mediaObserver.registerObserver(this.dataObserver);
this.broadCast.on(BroadcastConstants.SELECT, (index: number): void => { this.onSelect() });
@ -445,11 +485,11 @@ struct PhotoGridPage {
this.broadCast.on(Constants.ON_LOADING_FINISHED, (size: number): void => {
Log.info(TAG, "ON_LOADING_FINISHED size: " + size);
});
this.appBroadcast.on(BroadcastConstants.UPDATE_DATA_SOURCE, this.onUpdateFavorAndSelectState.bind(this));
this.appBroadcast.on(BroadcastConstants.UPDATE_DATA_SOURCE, (item: MediaDataItem): void => this.onUpdateFavorAndSelectStateBindImpl(item));
if (this.albumInfo.deviceId != null) {
Log.info(TAG, "deviceId size: " + this.albumInfo.deviceId);
this.appBroadcast.on(BroadcastConstants.ON_REMOTE_CHANGED, this.onUpdateRemoteDevice.bind(this));
this.appBroadcast.on(BroadcastConstants.ON_REMOTE_CHANGED, (res: string, deviceId: number): void => this.onUpdateRemoteDeviceBindImpl(res, deviceId));
}
screenManager.on(screenManager.ON_WIN_SIZE_CHANGED, (): void => {
@ -472,7 +512,11 @@ struct PhotoGridPage {
Log.info(TAG, "initGridRowCount contentWidth: " + contentWidth);
}
private onUpdateRemoteDevice(res, deviceId): void {
private onUpdateRemoteDevice(res: string, deviceId: number): void {
this.onUpdateRemoteDeviceBindImpl(res, deviceId)
}
private onUpdateRemoteDeviceBindImpl(res: string, deviceId: number|string): void {
Log.info(TAG, "onUpdateRemoteDevice");
if (deviceId != this.albumInfo.deviceId || this.isActive == false) {
Log.debug(TAG, "other device");
@ -580,8 +624,8 @@ struct PhotoGridPage {
aboutToDisappear(): void {
Log.info(TAG, "aboutToDisappear");
this.broadCast.off(null, null);
this.appBroadcast.off(BroadcastConstants.UPDATE_DATA_SOURCE, this.onUpdateFavorAndSelectState.bind(this));
this.appBroadcast.off(BroadcastConstants.ON_REMOTE_CHANGED, this.onUpdateRemoteDevice.bind(this));
this.appBroadcast.off(BroadcastConstants.UPDATE_DATA_SOURCE, (item: MediaDataItem): void => this.onUpdateFavorAndSelectStateBindImpl(item));
this.appBroadcast.off(BroadcastConstants.ON_REMOTE_CHANGED, (res: string, deviceId: number): void => this.onUpdateRemoteDeviceBindImpl(res, deviceId));
mediaObserver.unregisterObserver(this.dataObserver);
this.dataObserver = undefined;
this.scroller = undefined;

View File

@ -123,7 +123,7 @@ struct ThirdSelectAlbumSetPage {
this.loadAlbums()
this.leftAction = this.isFromFa ? Action.BACK : Action.CANCEL
this.title = (this.isFromFa && !this.isFromFaPhoto) ? ActionBarProp.SINGLE_SELECT_ALBUM_TITLE : ActionBarProp.SINGLE_UNSELECT_TITLE
this.onMenuClicked = this.onMenuClicked.bind(this);
this.onMenuClicked = (action: Action): void => this.onMenuClickedBindImpl(action);
Log.info(TAG, "isMultiPick: " + this.isMultiPick);
Log.info(TAG, "type: " + this.type);
Log.info(TAG, "ThirdSelectAlbumSetPage isFromWallpaper: " + this.isFromWallpaper);
@ -209,6 +209,10 @@ struct ThirdSelectAlbumSetPage {
}
onMenuClicked(action: Action): void {
this.onMenuClickedBindImpl(action)
}
private onMenuClickedBindImpl(action: Action): void {
Log.info(TAG, "onMenuClicked, action: " + action.actionID);
if (action === Action.CANCEL) {
Log.info(TAG, 'click cancel');

View File

@ -100,7 +100,7 @@ struct ThirdSelectPhotoBrowser {
this.totalSelectedCount = this.browserDataSource.getSelectedCount();
}
this.onMenuClicked = this.onMenuClicked.bind(this);
this.onMenuClicked = (action: Action): void => this.onMenuClickedBindImpl(action);
this.broadCast.on(PhotoConstants.TOGGLE_BAR, (): void => {
this.onToggleBars();
@ -138,6 +138,10 @@ struct ThirdSelectPhotoBrowser {
}
onPhotoChanged(index: number): void {
this.onPhotoChangedBindImpl(index)
}
private onPhotoChangedBindImpl(index: number): void {
this.currentIndex = index;
let currentPhoto = this.getCurrentPhoto();
if (currentPhoto == undefined) {
@ -174,6 +178,10 @@ struct ThirdSelectPhotoBrowser {
}
onMenuClicked(action: Action): void {
this.onMenuClickedBindImpl(action)
}
private onMenuClickedBindImpl(action: Action): void {
Log.info(TAG, "onMenuClicked, action: " + action.actionID);
if (action == Action.BACK) {
this.onBackPress();
@ -207,7 +215,7 @@ struct ThirdSelectPhotoBrowser {
PhotoSwiper({
dataSource: this.browserDataSource,
photoSwiperTransition: this.thirdSelectTransition,
onPhotoChanged: this.onPhotoChanged.bind(this),
onPhotoChanged: (index: number): void => this.onPhotoChangedBindImpl(index),
swiperController: this.controller
})
ThirdSelectPhotoBrowserActionBar({

View File

@ -82,6 +82,10 @@ struct ThirdSelectPhotoGridPage {
}
onMenuClicked(action: Action): void {
this.onMenuClickedBindImpl(action)
}
private onMenuClickedBindImpl(action: Action): void {
Log.info(TAG, "onMenuClicked, action: " + action.actionID);
if (action == Action.BACK) {
router.back();
@ -159,7 +163,7 @@ struct ThirdSelectPhotoGridPage {
})
this.initGridRowCount();
this.onMenuClicked = this.onMenuClicked.bind(this);
this.onMenuClicked = (action: Action): void => this.onMenuClickedBindImpl(action);
this.broadCast.on(BroadcastConstants.SELECT, (index: number): Promise<void> => { return this.onSelect(index) });
this.broadCast.on(BroadcastConstants.JUMP_THIRD_PHOTO_BROWSER, (name: string, item: MediaDataItem): void => {
this.jumpToThirdPhotoBrowser(name, item);

View File

@ -101,10 +101,10 @@ export struct TimelinePage {
mediaObserver.registerObserver(this.dataObserver);
screenManager.on(screenManager.ON_WIN_SIZE_CHANGED, (): void => this.initGridRowCount());
this.appBroadcast.on(BroadcastConstants.BACK_PRESS_EVENT, this.onIndexBackPress.bind(this));
this.appBroadcast.on(BroadcastConstants.ON_TAB_CHANGED, this.onTabChanged.bind(this));
this.appBroadcast.on(BroadcastConstants.RESET_STATE_EVENT, this.onStateReset.bind(this));
this.appBroadcast.on(BroadcastConstants.UPDATE_DATA_SOURCE, this.onUpdateFavorAndSelectState.bind(this));
this.appBroadcast.on(BroadcastConstants.BACK_PRESS_EVENT, (clbk: Function): void => this.onIndexBackPressBindImpl(clbk));
this.appBroadcast.on(BroadcastConstants.ON_TAB_CHANGED, (index: number): void => this.onTabChangedBindImpl(index));
this.appBroadcast.on(BroadcastConstants.RESET_STATE_EVENT, (index: number): void => this.onStateResetBindImpl(index));
this.appBroadcast.on(BroadcastConstants.UPDATE_DATA_SOURCE, (item: MediaDataItem): void => this.onUpdateFavorAndSelectStateBindImpl(item));
this.appBroadcast.on(BroadcastConstants.RESET_ZERO, (pageNumber: number): void => {
if (pageNumber == Constants.TIMELINE_PAGE_INDEX) {
this.scroller.scrollEdge(Edge.Top);
@ -182,10 +182,10 @@ export struct TimelinePage {
aboutToDisappear(): void {
Log.info(TAG, 'TimelinePageAboutToDisappear');
this.appBroadcast.off(BroadcastConstants.BACK_PRESS_EVENT, this.onIndexBackPress.bind(this));
this.appBroadcast.off(BroadcastConstants.ON_TAB_CHANGED, this.onTabChanged.bind(this));
this.appBroadcast.off(BroadcastConstants.RESET_STATE_EVENT, this.onStateReset.bind(this));
this.appBroadcast.off(BroadcastConstants.UPDATE_DATA_SOURCE, this.onUpdateFavorAndSelectState.bind(this));
this.appBroadcast.off(BroadcastConstants.BACK_PRESS_EVENT, (clbk: Function): void => this.onIndexBackPressBindImpl(clbk));
this.appBroadcast.off(BroadcastConstants.ON_TAB_CHANGED, (index: number): void => this.onTabChangedBindImpl(index));
this.appBroadcast.off(BroadcastConstants.RESET_STATE_EVENT, (index: number): void => this.onStateResetBindImpl(index));
this.appBroadcast.off(BroadcastConstants.UPDATE_DATA_SOURCE, (item: MediaDataItem): void => this.onUpdateFavorAndSelectStateBindImpl(item));
mediaObserver.unregisterObserver(this.dataObserver);
this.broadCast.off(null, null);
}
@ -210,8 +210,8 @@ export struct TimelinePage {
private moveOperation(albumInfo: SimpleAlbumDataItem): void {
let menuContext = new MenuContext();
this.onMoveStart = this.onMoveStart.bind(this);
this.onMoveEnd = this.onMoveEnd.bind(this);
this.onMoveStart = (): void => this.onMoveStartBindImpl();
this.onMoveEnd = (err: object, count: number, total: number): void => this.onMoveEndBindImpl(err, count, total);
menuContext.withDataSource(this.timelineDataSource)
.withOperationStartCallback(this.onMoveStart)
.withOperationEndCallback(this.onMoveEnd)
@ -223,8 +223,8 @@ export struct TimelinePage {
private copyOperation(albumInfo: SimpleAlbumDataItem): void {
let menuContext = new MenuContext();
this.onCopyStart = this.onCopyStart.bind(this);
this.onCopyEnd = this.onCopyEnd.bind(this);
this.onCopyStart = (): void => this.onCopyStartBindImpl();
this.onCopyEnd = (err: object, count: number, total: number): void => this.onCopyEndBindImpl(err, count, total);
menuContext.withDataSource(this.timelineDataSource)
.withOperationStartCallback(this.onCopyStart)
.withOperationEndCallback(this.onCopyEnd)
@ -244,12 +244,20 @@ export struct TimelinePage {
}
onIndexBackPress(callback: Function): void {
this.onIndexBackPressBindImpl(callback)
}
private onIndexBackPressBindImpl(callback: Function): void {
if (this.isInCurrentTab) {
callback(this.onModeChange());
}
}
private onUpdateFavorAndSelectState(item: MediaDataItem): void {
this.onUpdateFavorAndSelectStateBindImpl(item)
}
private onUpdateFavorAndSelectStateBindImpl(item: MediaDataItem): void {
this.onUpdateFavorState(item);
this.onSelect();
}
@ -263,6 +271,10 @@ export struct TimelinePage {
}
onTabChanged(index: number): void {
this.onTabChangedBindImpl(index)
}
private onTabChangedBindImpl(index: number): void {
if (index == Constants.TIMELINE_PAGE_INDEX) {
this.isInCurrentTab = true;
this.onActive();
@ -273,12 +285,20 @@ export struct TimelinePage {
}
onStateReset(index: number): void {
this.onStateResetBindImpl(index)
}
private onStateResetBindImpl(index: number): void {
if (index == Constants.TIMELINE_PAGE_INDEX) {
this.onModeChange();
}
}
onMenuClicked(action: Action): void {
this.onMenuClickedBindImpl(action)
}
private onMenuClickedBindImpl(action: Action): void {
Log.info(TAG, "onMenuClicked, actionID: " + action.actionID);
let menuContext: MenuContext;
let menuOperation: MenuOperation;
@ -290,8 +310,8 @@ export struct TimelinePage {
this.onSelect()
} else if (action === Action.DELETE) {
menuContext = new MenuContext();
this.onDeleteStart = this.onDeleteStart.bind(this);
this.onDeleteEnd = this.onDeleteEnd.bind(this);
this.onDeleteStart = (): void => this.onDeleteStartBindImpl();
this.onDeleteEnd = (err: object): void => this.onDeleteEndBindImpl(err);
menuContext
.withDataSource(this.timelineDataSource)
.withOperationStartCallback(this.onDeleteStart)
@ -367,11 +387,19 @@ export struct TimelinePage {
}
onDeleteStart(): void {
this.onDeleteStartBindImpl()
}
private onDeleteStartBindImpl(): void {
Log.info(TAG, "onDeleteStart");
mediaObserver.unregisterObserver(this.dataObserver);
}
onDeleteEnd(err): void {
onDeleteEnd(err: object): void {
this.onDeleteEndBindImpl(err)
}
private onDeleteEndBindImpl(err: object): void {
Log.info(TAG, "onDeleteEnd");
startTrace('onModeChange');
this.onModeChange();
@ -386,12 +414,20 @@ export struct TimelinePage {
}
onCopyStart(): void {
this.onCopyStartBindImpl()
}
private onCopyStartBindImpl(): void {
Log.info(TAG, "onCopyStart");
mediaObserver.unregisterObserver(this.dataObserver);
}
onCopyEnd(err, count, total): void {
onCopyEnd(err: object, count: number, total: number): void {
this.onCopyEndBindImpl(err, count, total)
}
private onCopyEndBindImpl(err: object, count: number, total: number): void {
Log.info(TAG, "onCopyEnd count: " + count + ", total: " + total);
startTrace('onModeChange');
this.onModeChange();
@ -408,11 +444,19 @@ export struct TimelinePage {
}
onMoveStart(): void {
this.onMoveStartBindImpl()
}
private onMoveStartBindImpl(): void {
Log.info(TAG, "onMoveStart");
mediaObserver.unregisterObserver(this.dataObserver);
}
onMoveEnd(err, count, total): void {
onMoveEnd(err: object, count: number, total: number): void {
this.onMoveEndBindImpl(err, count, total)
}
private onMoveEndBindImpl(err: object, count: number, total: number): void {
Log.info(TAG, "onMoveEnd count: " + count + ", total: " + total);
startTrace('onModeChange');
this.onModeChange();
@ -484,7 +528,7 @@ export struct TimelinePage {
if (this.initLoadFinish && !this.isEmpty) {
ActionBar({
actionBarProp: $actionBarProp,
onMenuClicked: this.onMenuClicked.bind(this)
onMenuClicked: (action: Action): void => this.onMenuClickedBindImpl(action)
})
Stack() {
@ -558,7 +602,7 @@ export struct TimelinePage {
if (this.isSelectedMode) {
ToolBar({
toolMenuList: $toolBarMenuList,
onMenuClicked: this.onMenuClicked.bind(this)
onMenuClicked: (action: Action): void => this.onMenuClickedBindImpl(action)
})
}
CustomDialogView()

View File

@ -44,8 +44,8 @@ struct ResourceDeletePage {
Log.info(TAG, 'onPageShow');
let menuOperation: MenuOperation;
let menuContext: MenuContext = new MenuContext();
this.onOperationEnd = this.onOperationEnd.bind(this);
this.onOperationCancel = this.onOperationCancel.bind(this);
this.onOperationEnd = (): void => this.onOperationEndBindImpl();
this.onOperationCancel = (): void => this.onOperationCancelBindImpl();
menuContext
.withItems(this.mediaDataItems)
.withOperationEndCallback(this.onOperationEnd)
@ -91,11 +91,19 @@ struct ResourceDeletePage {
.height('100%');
}
onOperationEnd (): void {
onOperationEnd(): void {
this.onOperationEndBindImpl()
}
private onOperationEndBindImpl(): void {
this.setDeleteResult(dialogRequest.ResultCode.RESULT_OK);
}
onOperationCancel (): void {
onOperationCancel(): void {
this.onOperationCancelBindImpl()
}
private onOperationCancelBindImpl(): void {
this.setDeleteResult(dialogRequest.ResultCode.RESULT_CANCEL);
}