mirror of
https://gitee.com/openharmony/applications_launcher
synced 2025-02-16 22:09:22 +00:00
launcher修改全局变量
Signed-off-by: zhengyongjie <15531316327@163.com>
This commit is contained in:
parent
0870decc4b
commit
f72d43f7e2
@ -18,8 +18,6 @@ import LruCache from './LruCache';
|
||||
import DiskLruCache from './DiskLruCache';
|
||||
|
||||
const TAG = 'AppResourceCacheManager';
|
||||
const KEY_ICON = 'icon';
|
||||
const DISK_CACHE_MISS = -1;
|
||||
|
||||
/**
|
||||
* A Manager class that provides get/set/clear cache methods for app image data.
|
||||
@ -27,6 +25,8 @@ const DISK_CACHE_MISS = -1;
|
||||
export default class AppResourceCacheManager {
|
||||
private readonly memoryCache;
|
||||
private readonly diskCache;
|
||||
private KEY_ICON: string = 'icon';
|
||||
private DISK_CACHE_MISS: number = -1;
|
||||
|
||||
constructor() {
|
||||
this.memoryCache = new LruCache();
|
||||
@ -42,7 +42,7 @@ export default class AppResourceCacheManager {
|
||||
getCache(cacheKey: string, cacheType: string) {
|
||||
const cache = this.getCacheFromMemory(cacheKey, cacheType);
|
||||
if (cache == undefined || cache == null || cache == '') {
|
||||
if (cacheType === KEY_ICON) {
|
||||
if (cacheType === this.KEY_ICON) {
|
||||
const cacheFromDisk = this.getCacheFromDisk(cacheKey, cacheType);
|
||||
this.setCacheToMemory(cacheKey, cacheType, cacheFromDisk);
|
||||
return cacheFromDisk;
|
||||
@ -62,7 +62,7 @@ export default class AppResourceCacheManager {
|
||||
setCache(cacheKey: string, cacheType: string, value: object | string) {
|
||||
Log.showDebug(TAG, `setCache cacheKey: ${cacheKey}, cacheType: ${cacheType}`);
|
||||
this.setCacheToMemory(cacheKey, cacheType, value);
|
||||
if (cacheType === KEY_ICON) {
|
||||
if (cacheType === this.KEY_ICON) {
|
||||
this.setCacheToDisk(cacheKey, cacheType, value);
|
||||
}
|
||||
}
|
||||
@ -77,7 +77,7 @@ export default class AppResourceCacheManager {
|
||||
|
||||
deleteCache(cacheKey: string, cacheType: string): void {
|
||||
this.memoryCache.remove(cacheKey);
|
||||
if (cacheType === KEY_ICON) {
|
||||
if (cacheType === this.KEY_ICON) {
|
||||
this.diskCache.remove(cacheKey);
|
||||
}
|
||||
}
|
||||
@ -106,7 +106,7 @@ export default class AppResourceCacheManager {
|
||||
|
||||
private getCacheFromDisk(cacheKey: string, cacheType: string) {
|
||||
const data = this.diskCache.getCache(cacheKey);
|
||||
return data !== DISK_CACHE_MISS ? data : null;
|
||||
return data !== this.DISK_CACHE_MISS ? data : null;
|
||||
}
|
||||
|
||||
private setCacheToDisk(cacheKey: string, cacheType: string, value: object | string): void {
|
||||
|
@ -25,7 +25,6 @@ import List from '@ohos.util.List';
|
||||
import FormConstants from '../common/constants/FormConstants';
|
||||
|
||||
const TAG = 'CardsDataPool';
|
||||
const SEPARATOR = '&';
|
||||
|
||||
/**
|
||||
* card resource pool
|
||||
@ -35,6 +34,7 @@ export default abstract class CardsDataPool {
|
||||
private mLastStartIndex: number = 0;
|
||||
private mLastEndIndex: number = 0;
|
||||
private mDataSize: number = 0;
|
||||
private SEPARATOR: string = '&';
|
||||
private mPoolDataMap: Map<string, ArrayList<CardItemInfo>> = new Map();
|
||||
mFormModel: FormModel = FormModel.getInstance();
|
||||
|
||||
@ -156,8 +156,8 @@ export default abstract class CardsDataPool {
|
||||
if (formInfo === null) {
|
||||
return '';
|
||||
}
|
||||
return formInfo.moduleName + SEPARATOR + formInfo.bundleName + SEPARATOR +
|
||||
formInfo.abilityName + SEPARATOR + formInfo.cardName + SEPARATOR + formInfo.cardDimension;
|
||||
return formInfo.moduleName + this.SEPARATOR + formInfo.bundleName + this.SEPARATOR +
|
||||
formInfo.abilityName + this.SEPARATOR + formInfo.cardName + this.SEPARATOR + formInfo.cardDimension;
|
||||
}
|
||||
|
||||
private async getTransMediumFormIndex(startIndex: number, smallList: ArrayList<CardItemInfo>,
|
||||
|
@ -20,12 +20,13 @@ import { Log } from '@ohos/common';
|
||||
import dataSourceListCfg from '../../../resources/rawfile/service_form_config.json';
|
||||
|
||||
const TAG = 'BigDataDataSource';
|
||||
const CONFIG_NAME = 'big_data_source_list';
|
||||
|
||||
/**
|
||||
* 推荐卡片资源池数据源:大数据预置卡片列表
|
||||
*/
|
||||
export default class BigDataDataSource extends BaseDataSource {
|
||||
private CONFIG_NAME: string = 'big_data_source_list';
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
@ -45,7 +46,7 @@ export default class BigDataDataSource extends BaseDataSource {
|
||||
public getSourceDataList(): string[] {
|
||||
let obj = JSON.parse(JSON.stringify(dataSourceListCfg));
|
||||
for (let key in obj) {
|
||||
if (key === CONFIG_NAME) {
|
||||
if (key === this.CONFIG_NAME) {
|
||||
let bigDataSourceList: string[] = obj[key];
|
||||
Log.showInfo(TAG, 'get bigDataSourceList len: ' + bigDataSourceList.length);
|
||||
Log.showInfo(TAG, 'get bigDataSourceList: ' + JSON.stringify(bigDataSourceList));
|
||||
|
@ -22,7 +22,6 @@ import {
|
||||
|
||||
const TAG = 'AppFormWeightManager';
|
||||
|
||||
const ENTER_RECOMMEND_INTERVAL_DAYS = 1;
|
||||
|
||||
/**
|
||||
* FA卡片属性的APP权重管理接口
|
||||
@ -38,6 +37,7 @@ export interface IAppFormWeightManager {
|
||||
export default class AppFormWeightManager implements IAppFormWeightManager {
|
||||
private mAppUsageWeight: Map<string, number> = new Map();
|
||||
private mRefreshTime: number = 0;
|
||||
private ENTER_RECOMMEND_INTERVAL_DAYS: number = 1;
|
||||
|
||||
private constructor() {
|
||||
}
|
||||
@ -81,7 +81,7 @@ export default class AppFormWeightManager implements IAppFormWeightManager {
|
||||
let current: number = await systemTime.getCurrentTime();
|
||||
let isNeedRefresh: boolean = false;
|
||||
let isIntervalDaysExceedsThreshold: boolean = (current - this.mRefreshTime) >
|
||||
NumberConstants.CONSTANT_DAY_TIME_MILLIS * ENTER_RECOMMEND_INTERVAL_DAYS;
|
||||
NumberConstants.CONSTANT_DAY_TIME_MILLIS * this.ENTER_RECOMMEND_INTERVAL_DAYS;
|
||||
if (isIntervalDaysExceedsThreshold) {
|
||||
this.mRefreshTime = current;
|
||||
isNeedRefresh = true;
|
||||
|
@ -32,8 +32,6 @@ import ArrayList from '@ohos.util.ArrayList';
|
||||
import AppFormWeightManager from './AppFormWeightManager';
|
||||
|
||||
const TAG = 'RecommendManager';
|
||||
const REFRESH_INTERVAL_TIME = 3;
|
||||
const ENTER_RECOMMEND_INTERVAL_DAYS = 1;
|
||||
|
||||
/**
|
||||
* 推荐服务卡片管理接口
|
||||
@ -56,6 +54,9 @@ export default class RecommendManager implements IRecommendManager {
|
||||
private readonly mAppUpdateDataSource: AppUpdateDataSource;
|
||||
private readonly mAppInstallDataSource: AppInstallDataSource;
|
||||
private mEnterNum: number = 0;
|
||||
private REFRESH_INTERVAL_TIME: number = 3;
|
||||
private ENTER_RECOMMEND_INTERVAL_DAYS: number = 1;
|
||||
|
||||
private mRefreshTime: number;
|
||||
|
||||
private constructor() {
|
||||
@ -139,10 +140,10 @@ export default class RecommendManager implements IRecommendManager {
|
||||
let current: number = await systemTime.getCurrentTime();
|
||||
let isNeedRefresh: boolean = false;
|
||||
let isIntervalDaysExceedsThreshold: boolean =
|
||||
(current - this.mRefreshTime) > NumberConstants.CONSTANT_DAY_TIME_MILLIS * ENTER_RECOMMEND_INTERVAL_DAYS;
|
||||
(current - this.mRefreshTime) > NumberConstants.CONSTANT_DAY_TIME_MILLIS * this.ENTER_RECOMMEND_INTERVAL_DAYS;
|
||||
Log.showInfo(TAG, `enter serviceCardSheet ${this.mEnterNum} times, ` +
|
||||
`Whether the last time is more than one day: ${isIntervalDaysExceedsThreshold}.`);
|
||||
if (this.mEnterNum >= REFRESH_INTERVAL_TIME && isIntervalDaysExceedsThreshold) {
|
||||
if (this.mEnterNum >= this.REFRESH_INTERVAL_TIME && isIntervalDaysExceedsThreshold) {
|
||||
this.mEnterNum = 0;
|
||||
this.mRefreshTime = current;
|
||||
isNeedRefresh = true;
|
||||
|
@ -28,7 +28,6 @@ import { FormStyleConfig } from '../common/FormStyleConfig';
|
||||
import FeatureConstants from '../common/constants/FeatureConstants';
|
||||
|
||||
const TAG = 'FormViewModel';
|
||||
const KEY_FORM_LIST = 'formListInfo';
|
||||
|
||||
/**
|
||||
* Class FormViewModel.
|
||||
@ -40,6 +39,7 @@ export class FormViewModel {
|
||||
private readonly mFormStyleConfig: FormStyleConfig;
|
||||
private readonly mFormListInfoCacheManager: FormListInfoCacheManager;
|
||||
private mAllFormsInfo?: CardItemInfo[];
|
||||
private KEY_FORM_LIST:string = 'formListInfo';
|
||||
|
||||
private constructor() {
|
||||
Log.showInfo(TAG, 'constructor start');
|
||||
@ -127,7 +127,7 @@ export class FormViewModel {
|
||||
this.mPageDesktopModel.setPageIndex(curPageIndex - 1);
|
||||
}
|
||||
}
|
||||
const formInfoList: any = this.mFormListInfoCacheManager.getCache(KEY_FORM_LIST);
|
||||
const formInfoList: any = this.mFormListInfoCacheManager.getCache(this.KEY_FORM_LIST);
|
||||
if (formInfoList === CommonConstants.INVALID_VALUE) {
|
||||
return;
|
||||
}
|
||||
@ -138,9 +138,9 @@ export class FormViewModel {
|
||||
}
|
||||
}
|
||||
if (formInfoList.length === 0) {
|
||||
this.mFormListInfoCacheManager.setCache(KEY_FORM_LIST, null);
|
||||
this.mFormListInfoCacheManager.setCache(this.KEY_FORM_LIST, null);
|
||||
} else {
|
||||
this.mFormListInfoCacheManager.setCache(KEY_FORM_LIST, formInfoList);
|
||||
this.mFormListInfoCacheManager.setCache(this.KEY_FORM_LIST, formInfoList);
|
||||
}
|
||||
}
|
||||
}
|
@ -33,7 +33,6 @@ import { PageDesktopDragHandler } from '../PageDesktopDragHandler';
|
||||
import { PageDesktopViewModel } from '../../viewmodel/PageDesktopViewModel';
|
||||
|
||||
const TAG = 'SwiperPage';
|
||||
const APP_INFO_REFRESH_DELAY = 1000;
|
||||
|
||||
interface AppListInfo {
|
||||
appGridInfo: LauncherDragItemInfo[][]
|
||||
@ -72,6 +71,7 @@ export default struct SwiperPage {
|
||||
private mIconSize: number = 0;
|
||||
private mGridSpaceWidth: number = 0;
|
||||
private mGridSpaceHeight: number = 0;
|
||||
private APP_INFO_REFRESH_DELAY: number = 1000;
|
||||
|
||||
private updateAppListInfo(): void {
|
||||
this.mAppListInfo = this.appListInfo.appGridInfo[this.swiperPage];
|
||||
@ -164,7 +164,7 @@ export default struct SwiperPage {
|
||||
AppStorage.setOrCreate('isSwappingPage', true);
|
||||
setTimeout(() => {
|
||||
AppStorage.setOrCreate('isSwappingPage', false);
|
||||
}, APP_INFO_REFRESH_DELAY);
|
||||
}, this.APP_INFO_REFRESH_DELAY);
|
||||
}
|
||||
|
||||
private buildLog(item: LauncherDragItemInfo): boolean {
|
||||
|
@ -44,8 +44,6 @@ import { PageDesktopGridStyleConfig } from '../common/PageDesktopGridStyleConfig
|
||||
import formHost from '@ohos.app.form.formHost';
|
||||
|
||||
const TAG = 'PageDesktopViewModel';
|
||||
const KEY_APP_LIST = 'appListInfo';
|
||||
const KEY_FORM_LIST = 'formListInfo';
|
||||
|
||||
export class PageDesktopViewModel extends BaseViewModel {
|
||||
private readonly pageDesktopStyleConfig: PageDesktopGridStyleConfig = null;
|
||||
@ -56,6 +54,8 @@ export class PageDesktopViewModel extends BaseViewModel {
|
||||
private readonly mPageDesktopModel: PageDesktopModel;
|
||||
private readonly mBadgeManager: BadgeManager;
|
||||
private readonly mFormListInfoCacheManager: FormListInfoCacheManager;
|
||||
private KEY_APP_LIST: string = 'appListInfo';
|
||||
private KEY_FORM_LIST: string = 'formListInfo';
|
||||
private mBundleInfoList;
|
||||
private mHideBundleInfoList = new Array<any>();
|
||||
private mGridConfig;
|
||||
@ -208,11 +208,11 @@ export class PageDesktopViewModel extends BaseViewModel {
|
||||
const folderInfoList = await this.mFolderModel.getFolderList();
|
||||
Log.showDebug(TAG, 'getAppList folderInfoList length: ' + folderInfoList.length);
|
||||
this.appendFolderData(folderInfoList, bundleInfoListTemp);
|
||||
let formInfoList: any = this.mFormListInfoCacheManager.getCache(KEY_FORM_LIST);
|
||||
let formInfoList: any = this.mFormListInfoCacheManager.getCache(this.KEY_FORM_LIST);
|
||||
if (formInfoList == CommonConstants.INVALID_VALUE) {
|
||||
formInfoList = await this.mFormModel.getAllFormsInfoFromRdb();
|
||||
if (formInfoList && formInfoList.length > 0) {
|
||||
this.mFormListInfoCacheManager.setCache(KEY_FORM_LIST, formInfoList);
|
||||
this.mFormListInfoCacheManager.setCache(this.KEY_FORM_LIST, formInfoList);
|
||||
}
|
||||
}
|
||||
this.appendFormData(formInfoList, bundleInfoListTemp);
|
||||
@ -588,7 +588,7 @@ export class PageDesktopViewModel extends BaseViewModel {
|
||||
appInfo.appGridInfo = this.integrateSwiper(appListInfo);
|
||||
Log.showInfo(TAG, 'pagingFiltering appListInfo length:' + appListInfo.length);
|
||||
AppStorage.setOrCreate('selectDesktopAppItem', '');
|
||||
AppStorage.setOrCreate(KEY_APP_LIST, appInfo);
|
||||
AppStorage.setOrCreate(this.KEY_APP_LIST, appInfo);
|
||||
}
|
||||
|
||||
private integrateSwiper(list) {
|
||||
@ -1317,12 +1317,12 @@ export class PageDesktopViewModel extends BaseViewModel {
|
||||
Log.showDebug(TAG, `createCardToDeskTop formCardItem id: ${formCardItem.cardId}`);
|
||||
const cardItemInfo = this.createNewCardItemInfo(formCardItem);
|
||||
|
||||
let formInfoList: any = this.mFormListInfoCacheManager.getCache(KEY_FORM_LIST);
|
||||
let formInfoList: any = this.mFormListInfoCacheManager.getCache(this.KEY_FORM_LIST);
|
||||
if (formInfoList == CommonConstants.INVALID_VALUE) {
|
||||
formInfoList = new Array<CardItemInfo>();
|
||||
}
|
||||
formInfoList.push(cardItemInfo);
|
||||
this.mFormListInfoCacheManager.setCache(KEY_FORM_LIST, formInfoList);
|
||||
this.mFormListInfoCacheManager.setCache(this.KEY_FORM_LIST, formInfoList);
|
||||
|
||||
const result = await this.mFormModel.updateFormInfoById(cardItemInfo);
|
||||
if (result) {
|
||||
|
@ -39,7 +39,6 @@ import { RecentMissionInfo } from '@ohos/common';
|
||||
import launcherBundleManager from '@ohos.bundle.launcherBundleManager';
|
||||
|
||||
const TAG = 'SmartDockModel';
|
||||
const KEY_NAME = 'name';
|
||||
|
||||
/**
|
||||
* SmartDock Model
|
||||
@ -54,6 +53,7 @@ export default class SmartDockModel {
|
||||
private readonly mDevice = CommonConstants.DEFAULT_DEVICE_TYPE;
|
||||
private readonly mResourceManager: ResourceManager;
|
||||
protected mAppModel: AppModel;
|
||||
private KEY_NAME: string = 'name';
|
||||
|
||||
private constructor() {
|
||||
this.mSmartDockLayoutConfig = layoutConfigManager.getFunctionConfig(SmartDockLayoutConfig.SMART_DOCK_LAYOUT_INFO);
|
||||
@ -536,7 +536,7 @@ export default class SmartDockModel {
|
||||
* @return cache
|
||||
*/
|
||||
getAppName(cacheKey: string): string {
|
||||
return this.mResourceManager.getAppResourceCache(cacheKey, KEY_NAME);
|
||||
return this.mResourceManager.getAppResourceCache(cacheKey, this.KEY_NAME);
|
||||
}
|
||||
|
||||
async getSnapshot(missionIds: MissionInfo[], name: string): Promise<any> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user