Skip to content

Commit 2492344

Browse files
author
Hristo Hristov
authored
Image cache is cleared when livesync happens (#4672)
1 parent 2c27b1a commit 2492344

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

tns-core-modules/ui/styling/background.android.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { View } from "../core/view";
22
import { CacheLayerType, isDataURI, isFileOrResourcePath, layout, RESOURCE_PREFIX, FILE_PREFIX } from "../../utils/utils";
33
import { parse } from "../../css-value";
44
import { path, knownFolders } from "../../file-system";
5-
import { android as androidApp } from "../../application";
5+
import * as application from "../../application";
66
export * from "./background-common"
77

88
interface AndroidView {
@@ -228,15 +228,22 @@ export function initImageCache(context: android.content.Context, mode = CacheMod
228228
imageFetcher.initCache();
229229
}
230230

231-
androidApp.on("activityStarted", (args) => {
231+
function onLivesync(args): void {
232+
if (imageFetcher) {
233+
imageFetcher.clearCache();
234+
}
235+
}
236+
application.on("livesync", onLivesync);
237+
238+
application.android.on("activityStarted", (args) => {
232239
if (!imageFetcher) {
233240
initImageCache(args.activity);
234241
} else {
235242
imageFetcher.initCache();
236243
}
237244
});
238245

239-
androidApp.on("activityStopped", (args) => {
246+
application.android.on("activityStopped", (args) => {
240247
if (imageFetcher) {
241248
imageFetcher.closeCache();
242249
}

0 commit comments

Comments
 (0)