MCPcopy Index your code
hub / github.com/NativeScript/NativeScript / initImageCache

Function initImageCache

packages/core/application/helpers-common.ts:171–191  ·  view source on GitHub ↗
(context: android.content.Context, mode = CacheMode.diskAndMemory, memoryCacheSize = 0.25, diskCacheSize: number = 10 * 1024 * 1024)

Source from the content-addressed store, hash-verified

169let _currentCacheMode: CacheMode;
170
171export function initImageCache(context: android.content.Context, mode = CacheMode.diskAndMemory, memoryCacheSize = 0.25, diskCacheSize: number = 10 * 1024 * 1024): void {
172 if (_currentCacheMode === mode) {
173 return;
174 }
175
176 _currentCacheMode = mode;
177 if (!getImageFetcher()) {
178 setImageFetcher(org.nativescript.widgets.image.Fetcher.getInstance(context));
179 } else {
180 getImageFetcher().clearCache();
181 }
182
183 const params = new org.nativescript.widgets.image.Cache.CacheParams();
184 params.memoryCacheEnabled = mode !== CacheMode.none;
185 params.setMemCacheSizePercent(memoryCacheSize); // Set memory cache to % of app memory
186 params.diskCacheEnabled = mode === CacheMode.diskAndMemory;
187 params.diskCacheSize = diskCacheSize;
188 const imageCache = org.nativescript.widgets.image.Cache.getInstance(params);
189 getImageFetcher().addImageCache(imageCache);
190 getImageFetcher().initCache();
191}

Callers 1

Calls 7

getImageFetcherFunction · 0.85
setImageFetcherFunction · 0.85
addImageCacheMethod · 0.80
initCacheMethod · 0.80
clearCacheMethod · 0.65
getInstanceMethod · 0.45

Tested by

no test coverage detected