mirror of
https://gitee.com/openharmony/applications_photos
synced 2024-11-23 15:10:25 +00:00
Partial fix 140: folder common
Signed-off-by: Ivan Tyulyandin <ivan.tyulyandin@huawei.com>
This commit is contained in:
parent
9ff1b5d24a
commit
a1f86fb492
@ -50,8 +50,8 @@ export class AlbumSetNewMenuOperation implements MenuOperation, MenuOperationCal
|
||||
this.getNewAlbumDisplayName(name).then((newAlbumDisplayName: string): void => {
|
||||
Log.info(TAG, "The display name of new album is " + newAlbumDisplayName);
|
||||
|
||||
this.confirmCallback = this.confirmCallback.bind(this);
|
||||
this.cancelCallback = this.cancelCallback.bind(this);
|
||||
this.confirmCallback = (displayName: string): Promise<void> => this.confirmCallbackBindImpl(displayName);
|
||||
this.cancelCallback = (): void => this.cancelCallbackBindImpl();
|
||||
|
||||
this.menuContext.broadCast.emit(BroadcastConstants.SHOW_NEW_ALBUM_PHOTO_DIALOG,
|
||||
[newAlbumDisplayName, this.confirmCallback, this.cancelCallback]);
|
||||
@ -65,6 +65,10 @@ export class AlbumSetNewMenuOperation implements MenuOperation, MenuOperationCal
|
||||
}
|
||||
|
||||
private async confirmCallback(displayName: string): Promise<void> {
|
||||
return await this.confirmCallbackBindImpl(displayName)
|
||||
}
|
||||
|
||||
private async confirmCallbackBindImpl(displayName: string): Promise<void> {
|
||||
Log.info(TAG, "AlbumSet new album confirm and the new name is: " + displayName);
|
||||
let relativePath = await mediaModel.getPublicDirectory(MediaLib.DirectoryType.DIR_CAMERA) + displayName + "/";
|
||||
let simpleAlbumDataItem: SimpleAlbumDataItem = new SimpleAlbumDataItem("", displayName, relativePath, "", "");
|
||||
@ -83,7 +87,7 @@ export class AlbumSetNewMenuOperation implements MenuOperation, MenuOperationCal
|
||||
|
||||
if (this.menuContext.jumpSourceToMain == JumpSourceToMain.ALBUM) {
|
||||
Log.info(TAG, 'go back to photo grid');
|
||||
this.menuContext.broadCast.emit(BroadcastConstants.MEDIA_OPERATION, [simpleAlbumDataItem, this.onCompleted.bind(this)]);
|
||||
this.menuContext.broadCast.emit(BroadcastConstants.MEDIA_OPERATION, [simpleAlbumDataItem, (): void => this.onCompletedBindImpl()]);
|
||||
} else {
|
||||
router.push({
|
||||
uri: 'feature/albumSelect/view/AlbumSelect',
|
||||
@ -102,10 +106,18 @@ export class AlbumSetNewMenuOperation implements MenuOperation, MenuOperationCal
|
||||
}
|
||||
|
||||
private cancelCallback(): void {
|
||||
this.cancelCallbackBindImpl()
|
||||
}
|
||||
|
||||
private cancelCallbackBindImpl(): void {
|
||||
Log.info(TAG, 'AlbumSet new album cancel');
|
||||
}
|
||||
|
||||
onCompleted(): void {
|
||||
this.onCompletedBindImpl()
|
||||
}
|
||||
|
||||
private onCompletedBindImpl(): void {
|
||||
Log.info(TAG, 'new album data succeed!');
|
||||
if(this.onOperationEnd != null) this.onOperationEnd();
|
||||
}
|
||||
|
@ -46,8 +46,8 @@ export class BatchDeleteMenuOperation extends ProcessMenuOperation {
|
||||
return;
|
||||
}
|
||||
|
||||
this.confirmCallback = this.confirmCallback.bind(this);
|
||||
this.cancelCallback = this.cancelCallback.bind(this);
|
||||
this.confirmCallback = (): void => this.confirmCallbackBindImpl();
|
||||
this.cancelCallback = (): void => this.cancelCallbackBindImpl();
|
||||
|
||||
let resource: Resource = this.getDeleteMessageResource(dataSource);
|
||||
let deleteResource: Resource = this.menuContext.albumId == MediaConstants.ALBUM_ID_RECYCLE ? $r('app.string.dialog_recycle') : $r('app.string.dialog_delete');
|
||||
@ -59,7 +59,7 @@ export class BatchDeleteMenuOperation extends ProcessMenuOperation {
|
||||
}
|
||||
|
||||
getResourceFromGrid(dataSource: ItemDataSource): Resource {
|
||||
if (dataSource != null && dataSource.isSelect()) {
|
||||
if (dataSource && 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');
|
||||
@ -79,6 +79,10 @@ export class BatchDeleteMenuOperation extends ProcessMenuOperation {
|
||||
}
|
||||
|
||||
confirmCallback(): void {
|
||||
this.confirmCallbackBindImpl()
|
||||
}
|
||||
|
||||
protected confirmCallbackBindImpl(): void {
|
||||
Log.info(TAG, 'Batch delete confirm');
|
||||
AppStorage.SetOrCreate("isDelete", 1);
|
||||
|
||||
@ -87,7 +91,7 @@ export class BatchDeleteMenuOperation extends ProcessMenuOperation {
|
||||
|
||||
// 2. onDeleteStart exit selection mode
|
||||
let onOperationStart: Function = this.menuContext.onOperationStart;
|
||||
if(onOperationStart != null) onOperationStart();
|
||||
onOperationStart && onOperationStart();
|
||||
|
||||
this.menuContext.broadCast.emit(BroadcastConstants.DELETE_PROGRESS_DIALOG,
|
||||
[$r('app.string.action_delete'), this.count]);
|
||||
@ -114,6 +118,10 @@ export class BatchDeleteMenuOperation extends ProcessMenuOperation {
|
||||
}
|
||||
|
||||
cancelCallback(): void {
|
||||
this.cancelCallbackBindImpl()
|
||||
}
|
||||
|
||||
protected cancelCallbackBindImpl(): void {
|
||||
Log.info(TAG, 'Batch delete cancel');
|
||||
}
|
||||
}
|
||||
|
@ -44,13 +44,17 @@ export class ClearRecycleMenuOperation extends BatchDeleteMenuOperation {
|
||||
return;
|
||||
}
|
||||
|
||||
this.confirmCallback = this.confirmCallback.bind(this);
|
||||
this.cancelCallback = this.cancelCallback.bind(this);
|
||||
this.confirmCallback = (): void => this.confirmCallbackBindImpl();
|
||||
this.cancelCallback = (): void => this.cancelCallbackBindImpl();
|
||||
|
||||
this.menuContext.broadCast.emit(BroadcastConstants.SHOW_DELETE_DIALOG, [$r('app.string.recycleAlbum_clear_message'), $r('app.string.dialog_clear'), this.confirmCallback, this.cancelCallback]);
|
||||
}
|
||||
|
||||
confirmCallback(): void {
|
||||
this.confirmCallbackBindImpl()
|
||||
}
|
||||
|
||||
protected confirmCallbackBindImpl(): void {
|
||||
Log.info(TAG, 'Clear Recycle confirm');
|
||||
// 1. Variable initialization
|
||||
this.onOperationEnd = this.menuContext.onOperationEnd;
|
||||
|
@ -62,11 +62,11 @@ export class CopyMenuOperation extends ProcessMenuOperation {
|
||||
if (this.menuContext.deviceId != null) {
|
||||
this.menuContext.broadCast.emit(BroadcastConstants.SHOW_PROGRESS_DIALOG,
|
||||
[$r('app.string.download_progress_message'),
|
||||
MediaOperationType.Copy, this.cancelFunc.bind(this)]);
|
||||
MediaOperationType.Copy, (): void => this.cancelFuncBindImpl()]);
|
||||
} else {
|
||||
this.menuContext.broadCast.emit(BroadcastConstants.SHOW_PROGRESS_DIALOG,
|
||||
[$r('app.string.copy_progress_message', this.albumInfo.displayName),
|
||||
MediaOperationType.Copy, this.cancelFunc.bind(this)]);
|
||||
MediaOperationType.Copy, (): void => this.cancelFuncBindImpl()]);
|
||||
}
|
||||
|
||||
if (dataSource == null) {
|
||||
@ -114,8 +114,8 @@ export class CopyMenuOperation extends ProcessMenuOperation {
|
||||
this.menuContext.broadCast.emit(BroadcastConstants.FIND_SAME_FILE_DIALOG,
|
||||
[assets, this.count, (): void => {
|
||||
this.copy(assets.sourceAsset, assets.targetAsset);
|
||||
}, this.onOperateContinue.bind(this), this.onOperateCancelled.bind(this),
|
||||
this.setFindSameOperation.bind(this)]);
|
||||
}, (): void => this.onOperateContinueBindImpl(), (): void => this.onOperateCancelledBindImpl(),
|
||||
(newOp: number): void => this.setFindSameOperation(newOp)]);
|
||||
break;
|
||||
case FindSameOperation.REPLACE:
|
||||
this.copy(assets.sourceAsset, assets.targetAsset);
|
||||
@ -160,6 +160,10 @@ export class CopyMenuOperation extends ProcessMenuOperation {
|
||||
}
|
||||
|
||||
cancelFunc(): void {
|
||||
this.cancelFuncBindImpl()
|
||||
}
|
||||
|
||||
private cancelFuncBindImpl(): void {
|
||||
Log.info(TAG, "progress cancel");
|
||||
this.onOperatePause();
|
||||
let cancelMessage = $r('app.string.copy_cancel_message', this.getExpectProgress().toString());
|
||||
@ -167,10 +171,10 @@ export class CopyMenuOperation extends ProcessMenuOperation {
|
||||
if(this.menuContext.broadCast != null) {
|
||||
if (this.menuContext.deviceId != null) {
|
||||
this.menuContext.broadCast.emit(BroadcastConstants.DOWNLOAD_CANCEL_OPERATE,
|
||||
[cancelMessage, this.onOperateContinue.bind(this), this.onOperateCancelled.bind(this)]);
|
||||
[cancelMessage, (): void => this.onOperateContinueBindImpl(), (): void => this.onOperateCancelledBindImpl()]);
|
||||
} else {
|
||||
this.menuContext.broadCast.emit(BroadcastConstants.CANCEL_OPERATE,
|
||||
[cancelMessage, this.onOperateContinue.bind(this), this.onOperateCancelled.bind(this)]);
|
||||
[cancelMessage, (): void => this.onOperateContinueBindImpl(), (): void => this.onOperateCancelledBindImpl()]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -178,6 +182,10 @@ export class CopyMenuOperation extends ProcessMenuOperation {
|
||||
|
||||
// Copy cancel callback
|
||||
onOperateContinue(): void {
|
||||
this.onOperateContinueBindImpl()
|
||||
}
|
||||
|
||||
private onOperateContinueBindImpl(): void {
|
||||
Log.info(TAG, 'Operate Continue');
|
||||
this.isPause = false;
|
||||
this.cyclicOperation();
|
||||
|
@ -59,7 +59,7 @@ export class MoveMenuOperation extends ProcessMenuOperation {
|
||||
|
||||
this.menuContext.broadCast.emit(
|
||||
BroadcastConstants.SHOW_PROGRESS_DIALOG, [$r('app.string.move_progress_message', this.albumInfo.displayName),
|
||||
MediaOperationType.Move, this.cancelFunc.bind(this)]);
|
||||
MediaOperationType.Move, (): void => this.cancelFuncBindImpl()]);
|
||||
|
||||
if (dataSource == null) {
|
||||
this.items = this.menuContext.items;
|
||||
@ -89,8 +89,8 @@ export class MoveMenuOperation extends ProcessMenuOperation {
|
||||
this.menuContext.broadCast.emit(BroadcastConstants.FIND_SAME_FILE_DIALOG,
|
||||
[assets, this.count, () => {
|
||||
this.move(assets.sourceAsset, this.albumInfo.relativePath, assets.targetAsset);
|
||||
}, this.onOperateContinue.bind(this), this.onOperateCancelled.bind(this),
|
||||
this.setFindSameOperation.bind(this)]);
|
||||
}, (): void => this.onOperateContinueBindImpl(), (): void => this.onOperateCancelledBindImpl(),
|
||||
(newOp: number): void => this.setFindSameOperationBindImpl(newOp)]);
|
||||
break;
|
||||
case FindSameOperation.REPLACE:
|
||||
this.move(assets.sourceAsset, this.albumInfo.relativePath, assets.targetAsset);
|
||||
@ -124,17 +124,25 @@ export class MoveMenuOperation extends ProcessMenuOperation {
|
||||
}
|
||||
|
||||
cancelFunc(): void {
|
||||
this.cancelFuncBindImpl()
|
||||
}
|
||||
|
||||
private cancelFuncBindImpl(): void {
|
||||
Log.info(TAG, "progress cancel");
|
||||
this.onOperatePause();
|
||||
let cancelMessage = $r('app.string.move_cancel_message', this.getExpectProgress().toString());
|
||||
if(this.menuContext.broadCast != null) {
|
||||
this.menuContext.broadCast.emit(BroadcastConstants.CANCEL_OPERATE,
|
||||
[cancelMessage, this.onOperateContinue.bind(this), this.onOperateCancelled.bind(this)]);
|
||||
[cancelMessage, (): void => this.onOperateContinueBindImpl(), (): void => this.onOperateCancelledBindImpl()]);
|
||||
}
|
||||
}
|
||||
|
||||
// Move cancel callback
|
||||
onOperateContinue(): void {
|
||||
this.onOperateContinueBindImpl()
|
||||
}
|
||||
|
||||
private onOperateContinueBindImpl(): void {
|
||||
Log.info(TAG, 'Operate Continue');
|
||||
this.isPause = false;
|
||||
this.cyclicOperation();
|
||||
|
@ -72,7 +72,10 @@ export class ProcessMenuOperation implements MenuOperation, AsyncCallback<String
|
||||
|
||||
// Asynchronous callback for getSelection
|
||||
callback(uris: string[]): void {
|
||||
this.callbackBindImpl(uris)
|
||||
}
|
||||
|
||||
protected callbackBindImpl(uris: string[]): void {
|
||||
}
|
||||
|
||||
onCompleted(): void {
|
||||
@ -142,6 +145,10 @@ export class ProcessMenuOperation implements MenuOperation, AsyncCallback<String
|
||||
|
||||
// Operate cancel callback
|
||||
onOperateCancelled(): void {
|
||||
this.onOperateCancelledBindImpl()
|
||||
}
|
||||
|
||||
protected onOperateCancelledBindImpl(): void {
|
||||
Log.info(TAG, 'Operate Cancel');
|
||||
this.isCancelled = true;
|
||||
this.onProcessDone();
|
||||
@ -162,6 +169,10 @@ export class ProcessMenuOperation implements MenuOperation, AsyncCallback<String
|
||||
}
|
||||
|
||||
setFindSameOperation(newOperation: number): void {
|
||||
this.setFindSameOperationBindImpl(newOperation)
|
||||
}
|
||||
|
||||
protected setFindSameOperationBindImpl(newOperation: number): void {
|
||||
Log.info(TAG, "setFindSameOperation " + newOperation);
|
||||
this.findSameOperation = newOperation;
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ const TAG = "ThirdDeleteMenuOperation"
|
||||
export class ThirdDeleteOperation extends ProcessMenuOperation {
|
||||
constructor(menuContext: MenuContext) {
|
||||
super(menuContext);
|
||||
this.callback = this.callback.bind(this);
|
||||
this.callback = (uris: string[]): void => this.callbackBindImpl(uris);
|
||||
}
|
||||
|
||||
doAction(): void {
|
||||
@ -48,8 +48,8 @@ export class ThirdDeleteOperation extends ProcessMenuOperation {
|
||||
return;
|
||||
}
|
||||
|
||||
this.confirmCallback = this.confirmCallback.bind(this);
|
||||
this.cancelCallback = this.cancelCallback.bind(this);
|
||||
this.confirmCallback = (): void => this.confirmCallbackBindImpl();
|
||||
this.cancelCallback = (): void => this.cancelCallbackBindImpl();
|
||||
|
||||
let resource: Resource = this.getDeleteMessageResource(dataSource);
|
||||
let deleteResource: Resource = $r('app.string.dialog_delete');
|
||||
@ -76,6 +76,10 @@ export class ThirdDeleteOperation extends ProcessMenuOperation {
|
||||
}
|
||||
|
||||
confirmCallback(): void {
|
||||
this.confirmCallbackBindImpl()
|
||||
}
|
||||
|
||||
private confirmCallbackBindImpl(): void {
|
||||
Log.info(TAG, 'Batch delete confirm');
|
||||
AppStorage.SetOrCreate("isDelete", 1);
|
||||
|
||||
@ -115,6 +119,10 @@ export class ThirdDeleteOperation extends ProcessMenuOperation {
|
||||
}
|
||||
|
||||
cancelCallback(): void {
|
||||
this.cancelCallbackBindImpl()
|
||||
}
|
||||
|
||||
private cancelCallbackBindImpl(): void {
|
||||
Log.info(TAG, 'Batch delete cancel');
|
||||
let onOperationCancel: Function = this.menuContext.onOperationCancel;
|
||||
if(onOperationCancel != null) onOperationCancel();
|
||||
|
@ -41,7 +41,7 @@ export class AlbumsDataSource extends ItemDataSource {
|
||||
}
|
||||
|
||||
getData(index: number): LazyItem<AlbumDataItem> {
|
||||
return new LazyItem<AlbumDataItem>(this.getDataByIndex(index), index, this.onDataUpdate.bind(this))
|
||||
return new LazyItem<AlbumDataItem>(this.getDataByIndex(index), index, (index: number): void => this.onDataUpdateBindImpl(index))
|
||||
}
|
||||
|
||||
getDataByIndex(index: number): AlbumDataItem {
|
||||
@ -141,6 +141,10 @@ export class AlbumsDataSource extends ItemDataSource {
|
||||
}
|
||||
|
||||
onDataUpdate(index: number): void {
|
||||
this.onDataUpdateBindImpl(index)
|
||||
}
|
||||
|
||||
private onDataUpdateBindImpl(index: number): void {
|
||||
Log.info(TAG, "onDataUpdate " + index);
|
||||
this.notifyDataChange(index);
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ export class GroupItemDataSource extends ItemDataSource {
|
||||
if (this.groupDataItem[index] != null && this.groupDataItem[index] != undefined) {
|
||||
this.groupDataItem[index].index = index;
|
||||
}
|
||||
return new LazyItem<MediaDataItem>(this.groupDataItem[index], index, this.onDataUpdate.bind(this));
|
||||
return new LazyItem<MediaDataItem>(this.groupDataItem[index], index, (index: number): void => this.onDataUpdateBindImpl(index));
|
||||
}
|
||||
|
||||
getDataByIndex(index: number): MediaDataItem {
|
||||
@ -139,8 +139,12 @@ export class GroupItemDataSource extends ItemDataSource {
|
||||
this.groupDataItem = await this.groupDataImpl.reloadGroupItemData(isGrid);
|
||||
return this.groupDataItem.length == 0;
|
||||
}
|
||||
|
||||
|
||||
onDataUpdate(index: number): void {
|
||||
this.onDataUpdateBindImpl(index)
|
||||
}
|
||||
|
||||
private onDataUpdateBindImpl(index: number): void {
|
||||
Log.debug(TAG, "onDataUpdate " + index);
|
||||
if (index != -1) {
|
||||
this.notifyDataChange(index);
|
||||
|
Loading…
Reference in New Issue
Block a user