From 24923445bde1908c6b59ada1cbe6c005bb6ffbe0 Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Tue, 8 Aug 2017 16:52:39 +0300 Subject: [PATCH] Image cache is cleared when livesync happens (#4672) --- tns-core-modules/ui/styling/background.android.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tns-core-modules/ui/styling/background.android.ts b/tns-core-modules/ui/styling/background.android.ts index e71e073be..59ac8a070 100644 --- a/tns-core-modules/ui/styling/background.android.ts +++ b/tns-core-modules/ui/styling/background.android.ts @@ -2,7 +2,7 @@ import { View } from "../core/view"; import { CacheLayerType, isDataURI, isFileOrResourcePath, layout, RESOURCE_PREFIX, FILE_PREFIX } from "../../utils/utils"; import { parse } from "../../css-value"; import { path, knownFolders } from "../../file-system"; -import { android as androidApp } from "../../application"; +import * as application from "../../application"; export * from "./background-common" interface AndroidView { @@ -228,7 +228,14 @@ export function initImageCache(context: android.content.Context, mode = CacheMod imageFetcher.initCache(); } -androidApp.on("activityStarted", (args) => { +function onLivesync(args): void { + if (imageFetcher) { + imageFetcher.clearCache(); + } +} +application.on("livesync", onLivesync); + +application.android.on("activityStarted", (args) => { if (!imageFetcher) { initImageCache(args.activity); } else { @@ -236,7 +243,7 @@ androidApp.on("activityStarted", (args) => { } }); -androidApp.on("activityStopped", (args) => { +application.android.on("activityStopped", (args) => { if (imageFetcher) { imageFetcher.closeCache(); }