Generic functions type fix (R-V) part two

Generic functions type fix (R-V) part two

Signed-off-by: Maksim Khramov <khramov.WX1235557@huawei-partners.com>

Generic functions type fix (R-V) part two
This commit is contained in:
Maksim Khramov 2023-06-07 14:23:25 +03:00
parent ba26803691
commit c3d9d6f80b
15 changed files with 42 additions and 47 deletions

View File

@ -41,6 +41,6 @@ class TrashMediaDataItemCache {
}
}
let trashMediaDataItemCache: TrashMediaDataItemCache = stashOrGetObject(new TrashMediaDataItemCache(), TAG);
let trashMediaDataItemCache: TrashMediaDataItemCache = stashOrGetObject<TrashMediaDataItemCache>(new TrashMediaDataItemCache(), TAG);
export { trashMediaDataItemCache };
export { trashMediaDataItemCache };

View File

@ -253,7 +253,7 @@ class ScreenManager {
}
private async setFullScreen(): Promise<void> {
let topWindow: window.Window = AppStorage.Get(WindowConstants.MAIN_WINDOW);
let topWindow: window.Window = AppStorage.Get<window.Window>(WindowConstants.MAIN_WINDOW);
Log.debug(TAG, 'getTopWindow start');
try {
await topWindow.setLayoutFullScreen(true)
@ -269,7 +269,7 @@ class ScreenManager {
this.statusBarHeight = 0;
this.naviBarHeight = 0;
this.leftBlank = [0, 0, 0, 0];
AppStorage.SetOrCreate(BroadcastConstants.LEFT_BLANK, this.leftBlank);
AppStorage.SetOrCreate<number[]>(BroadcastConstants.LEFT_BLANK, this.leftBlank);
} catch (err) {
Log.error(TAG, "setSplitScreen err: " + err);
}
@ -307,7 +307,7 @@ class ScreenManager {
async setNavigationBarColor(barColor: string, barContentColor: string): Promise<void> {
Log.debug(TAG, 'setNavigationBarColor start');
let topWindow: window.Window = AppStorage.Get(WindowConstants.MAIN_WINDOW);
let topWindow: window.Window = AppStorage.Get<window.Window>(WindowConstants.MAIN_WINDOW);
try {
let systemBarProperties: window.SystemBarProperties = {
navigationBarColor: barColor,
@ -324,7 +324,7 @@ class ScreenManager {
setSystemUi(isShowBar: boolean): void {
Log.debug(TAG, 'setSystemUi start');
let topWindow: window.Window = AppStorage.Get(WindowConstants.MAIN_WINDOW);
let topWindow: window.Window = AppStorage.Get<window.Window>(WindowConstants.MAIN_WINDOW);
Log.debug(TAG, 'getTopWindow start');
let names: string[] = ["navigation"];
if (!isShowBar) {
@ -360,7 +360,7 @@ class ScreenManager {
this.leftBlank = [this.leftBlank[0], this.leftBlank[1], this.leftBlank[2], area.bottomRect.height];
if (leftBlankBefore.status != this.statusBarHeight || leftBlankBefore.navi != this.naviBarHeight) {
Log.info(TAG, "leftBlank changed: " + JSON.stringify(leftBlankBefore) + "-" + JSON.stringify(this.leftBlank))
AppStorage.SetOrCreate(BroadcastConstants.LEFT_BLANK, this.leftBlank);
AppStorage.SetOrCreate<number[]>(BroadcastConstants.LEFT_BLANK, this.leftBlank);
}
}
@ -393,21 +393,21 @@ class ScreenManager {
} else {
this.horizontal = true;
}
AppStorage.SetOrCreate(SCREEN_ORIENTATION_HORIZONTAL, this.horizontal);
AppStorage.SetOrCreate<boolean>(SCREEN_ORIENTATION_HORIZONTAL, this.horizontal);
}
isHorizontal(): boolean {
if (AppStorage.Get(SCREEN_ORIENTATION_HORIZONTAL) == null) {
AppStorage.SetOrCreate(SCREEN_ORIENTATION_HORIZONTAL, this.horizontal);
if (AppStorage.Get<boolean>(SCREEN_ORIENTATION_HORIZONTAL) == null) {
AppStorage.SetOrCreate<boolean>(SCREEN_ORIENTATION_HORIZONTAL, this.horizontal);
}
return AppStorage.Get(SCREEN_ORIENTATION_HORIZONTAL);
return AppStorage.Get<boolean>(SCREEN_ORIENTATION_HORIZONTAL);
}
isSidebar(): boolean {
if (AppStorage.Get(SCREEN_SIDEBAR) == null) {
AppStorage.SetOrCreate(SCREEN_SIDEBAR, this.sidebar);
if (AppStorage.Get<boolean>(SCREEN_SIDEBAR) == null) {
AppStorage.SetOrCreate<boolean>(SCREEN_SIDEBAR, this.sidebar);
}
return AppStorage.Get(SCREEN_SIDEBAR);
return AppStorage.Get<boolean>(SCREEN_SIDEBAR);
}
getColumnsWidth(count: number): number {
@ -430,7 +430,7 @@ class ScreenManager {
setKeepScreenOn(): void {
Log.info(TAG, 'setKeepScreenOn start');
let topWindow: window.Window = AppStorage.Get('mainWindow');
let topWindow: window.Window = AppStorage.Get<window.Window>('mainWindow');
try {
topWindow.setKeepScreenOn(true, (): void => Log.info(TAG, 'setKeepScreenOn Succeeded'))
} catch (err) {
@ -440,7 +440,7 @@ class ScreenManager {
setKeepScreenOff(): void {
Log.info(TAG, 'setKeepScreenOff start');
let topWindow: window.Window = AppStorage.Get('mainWindow');
let topWindow: window.Window = AppStorage.Get<window.Window>('mainWindow');
try {
topWindow.setKeepScreenOn(false, (): void => Log.info(TAG, 'setKeepScreenOff Succeeded'))
} catch (err) {
@ -449,6 +449,6 @@ class ScreenManager {
}
}
let screenManager: ScreenManager = stashOrGetObject(new ScreenManager(), TAG);
let screenManager: ScreenManager = stashOrGetObject<ScreenManager>(new ScreenManager(), TAG);
export { screenManager };

View File

@ -36,6 +36,6 @@ class SelectManager {
}
}
let selectManager: SelectManager = stashOrGetObject(new SelectManager(), TAG);
let selectManager: SelectManager = stashOrGetObject<SelectManager>(new SelectManager(), TAG);
export { selectManager };

View File

@ -77,7 +77,7 @@ export class ThirdDeleteOperation extends ProcessMenuOperation {
confirmCallback(): void {
Log.info(TAG, 'Batch delete confirm');
AppStorage.SetOrCreate("isDelete", 1);
AppStorage.SetOrCreate<number>("isDelete", 1);
// 1. Variable initialization
this.onOperationEnd = this.menuContext.onOperationEnd;

View File

@ -274,7 +274,7 @@ export class MediaDataManager {
getCurrentIndex(): number {
return this.mediaData.currentIndex;
}Scree
}
getIsShowAlbumName(): boolean {
return this.mediaData.isShowAlbumName == 1 ? true : false;

View File

@ -52,8 +52,8 @@ export class ServiceExtAbility extends Extension {
if (uris == undefined || uris.length ===0) {
return;
}
AppStorage.SetOrCreate("uris", uris);
AppStorage.SetOrCreate("appName", appName);
AppStorage.SetOrCreate<string[]>("uris", uris);
AppStorage.SetOrCreate<string>("appName", appName);
let windowClass: window.Window = this.globalThis.getObject("windowClass") as window.Window;
try {
@ -72,8 +72,8 @@ export class ServiceExtAbility extends Extension {
let requestInfo = dialogRequest.getRequestInfo(want);
Log.info(TAG, "requestInfo param : " + JSON.stringify(requestInfo));
let requestCallback = dialogRequest.getRequestCallback(want);
AppStorage.SetOrCreate("requestCallback", requestCallback);
let requestCallback: dialogRequest.RequestCallback = dialogRequest.getRequestCallback(want);
AppStorage.SetOrCreate<dialogRequest.RequestCallback>("requestCallback", requestCallback);
Log.info(TAG, "Succeeded in get requestCallback");
windowClass.bindDialogTarget(requestInfo, (): void => {

View File

@ -31,8 +31,8 @@ export struct ThirdDeleteDialog {
private thirdAppName: string;
aboutToAppear(): void {
this.uris = AppStorage.Get("uris");
this.thirdAppName = AppStorage.Get("appName");
this.uris = AppStorage.Get<string[]>("uris");
this.thirdAppName = AppStorage.Get<string>("appName");
}
build() {

View File

@ -100,7 +100,7 @@ struct SelectPhotoBrowser {
this.browserDataSource.setAlbumId((param.albumInfo as SimpleAlbumDataItem).id);
}
this.browserDataSource.groupDataItem = AppStorage.Get(Constants.APP_KEY_PHOTO_BROWSER);
this.browserDataSource.groupDataItem = AppStorage.Get<MediaDataItem[]>(Constants.APP_KEY_PHOTO_BROWSER);
let pos = 0;
if (!Number.isNaN(param.position)) {
pos = new Number(param.position).valueOf()

View File

@ -141,7 +141,7 @@ struct ThirdSelectAlbumSetPage {
this.initGridRowCount();
this.updateActionBar();
AppStorage.SetOrCreate(Constants.ENTRY_FROM_HAP, Constants.ENTRY_FROM_NONE);
AppStorage.SetOrCreate<number>(Constants.ENTRY_FROM_HAP, Constants.ENTRY_FROM_NONE);
}
private jumpToAllAlbumGridPage(allAlbumDataItem: AlbumDataItem): void {

View File

@ -95,7 +95,7 @@ struct ThirdSelectPhotoBrowser {
this.bundleName = params.bundleName.toString();
this.isSelectUpperLimited = params.isSelectUpperLimited as boolean;
}
this.browserDataSource.groupDataItem = AppStorage.Get(Constants.APP_KEY_PHOTO_BROWSER);
this.browserDataSource.groupDataItem = AppStorage.Get<MediaDataItem[]>(Constants.APP_KEY_PHOTO_BROWSER);
if (this.isMultiPick == true) {
this.totalSelectedCount = this.browserDataSource.getSelectedCount();
}
@ -225,8 +225,8 @@ struct ThirdSelectPhotoBrowser {
Log.debug(TAG, "setPickResult " + this.isFromFa);
if (this.isFromFa) {
this.appBroadcast.emit(BroadcastConstants.SAVE_FORM_EDITOR_DATA,
[AppStorage.Get(Constants.FORM_ITEM_NAME), AppStorage.Get(Constants.FORM_ITEM_ALBUM_ID),
AppStorage.Get(Constants.FORM_ITEM_DISPLAY_NAME), this.currentIndex, false]);
[AppStorage.Get<object>(Constants.FORM_ITEM_NAME), AppStorage.Get<object>(Constants.FORM_ITEM_ALBUM_ID),
AppStorage.Get<object>(Constants.FORM_ITEM_DISPLAY_NAME), this.currentIndex, false]);
return;
}
let uriArray: string[] = [];

View File

@ -144,9 +144,9 @@ struct ThirdSelectPhotoGridPage {
}
if (this.isFromFa) {
this.filterMediaType = MediaConstants.SELECT_TYPE_IMAGE;
AppStorage.SetOrCreate(Constants.FORM_ITEM_NAME, param.itemName);
AppStorage.SetOrCreate(Constants.FORM_ITEM_ALBUM_ID, param.itemId);
AppStorage.SetOrCreate(Constants.FORM_ITEM_DISPLAY_NAME, param.itemDisplayName);
AppStorage.SetOrCreate<object>(Constants.FORM_ITEM_NAME, param.itemName);
AppStorage.SetOrCreate<object>(Constants.FORM_ITEM_ALBUM_ID, param.itemId);
AppStorage.SetOrCreate<object>(Constants.FORM_ITEM_DISPLAY_NAME, param.itemDisplayName);
}
this.groupDataSource.setSelectType(this.filterMediaType);
Log.info(TAG, "ThirdSelectPhotoGridPage isMultiPick: " + this.isMultiPick + ", " +
@ -220,7 +220,7 @@ struct ThirdSelectPhotoGridPage {
Log.warn(TAG, 'targetIndex is not found');
return;
}
AppStorage.SetOrCreate(Constants.APP_KEY_PHOTO_BROWSER, children);
AppStorage.SetOrCreate<MediaDataItem[]>(Constants.APP_KEY_PHOTO_BROWSER, children);
router.push({
uri: 'feature/thirdSelect/view/ThirdSelectPhotoBrowser',
params: {

View File

@ -153,7 +153,7 @@ export struct TimelinePage {
Log.warn(TAG, 'targetIndex is not found');
return;
}
AppStorage.SetOrCreate(Constants.APP_KEY_PHOTO_BROWSER, children);
AppStorage.SetOrCreate<MediaDataItem[]>(Constants.APP_KEY_PHOTO_BROWSER, children);
router.push({
uri: 'feature/browser/view/PhotoBrowser',
params: {
@ -170,7 +170,7 @@ export struct TimelinePage {
Log.warn(TAG, 'targetIndex is not found');
return;
}
AppStorage.SetOrCreate(Constants.APP_KEY_PHOTO_BROWSER, children);
AppStorage.SetOrCreate<MediaDataItem[]>(Constants.APP_KEY_PHOTO_BROWSER, children);
router.push({
uri: 'feature/browser/view/SelectPhotoBrowser',
params: {

View File

@ -102,7 +102,7 @@ struct ResourceDeletePage {
private setDeleteResult(result: dialogRequest.ResultCode): void {
Log.info(TAG, "start to setDeleteResult : " + result);
try {
let requestCallback = AppStorage.Get("requestCallback");
let requestCallback: dialogRequest.RequestCallback = AppStorage.Get<dialogRequest.RequestCallback>("requestCallback");
let myResult = {
result: result,
}
@ -114,4 +114,4 @@ struct ResourceDeletePage {
Log.info(TAG, "getRequestInfo err : " + JSON.stringify(err));
}
}
}
}

View File

@ -27,7 +27,7 @@ interface SettingsType {
@CustomDialog
export struct SettingDialog {
private broadCast: Broadcast = broadcastManager.getBroadcast();
@StorageLink('form_playback_interval') time: number = AppStorage.Get(Constants.FROM_PLAYBACK_INTERVAL);
@StorageLink('form_playback_interval') time: number = AppStorage.Get<number>(Constants.FROM_PLAYBACK_INTERVAL);
@StorageLink('leftBlank') leftBlank: number[] = [0, 0, 0, 0];
@StorageLink('isHorizontal') isHorizontal: boolean = screenManager.isHorizontal();
@StorageLink('isSidebar') isSidebar: boolean = screenManager.isSidebar();
@ -122,4 +122,4 @@ export struct SettingDialog {
bottom: this.isHorizontal || this.isSidebar ? 0 : Constants.DIALOG_BOTTOM_OFFSET + px2vp(this.leftBlank[3])
})
}
}
}

View File

@ -30,12 +30,7 @@ export class TimelineDataItem implements DateAdded {
constructor(fileAssert: MediaLib.FileAsset, mediaFileAsset: MediaLib.FileAsset[], index: number) {
Log.info(TAG, "construct " + fileAssert.dateAdded + ":" + fileAssert.count);
this.dateAdded = fileAssert.dateAdded * 1000;
for (let i = 0; i < fileAssert.count; i++) {
// Fake items to fill length;
this.groupChild.push(new MediaDataItem("", [], "", 0));
}
this.groupChild = new Array<MediaDataItem>(fileAssert.count);
let selections: string = MediaLib.FileKey.MEDIA_TYPE + ' = ? or ' + MediaLib.FileKey.MEDIA_TYPE + ' = ?';
let selectionArgs: string[] = [MediaLib.MediaType.IMAGE.toString(), MediaLib.MediaType.VIDEO.toString()];
for (let i = 0;i < this.groupChild.length; i++) {