diff --git a/application/application-common.ts b/application/application-common.ts index 192c40791..377c8cdf9 100644 --- a/application/application-common.ts +++ b/application/application-common.ts @@ -50,8 +50,4 @@ export function loadCss() { } } } -} - -global.__onLiveSync = function () { - frame.reloadPage(); } \ No newline at end of file diff --git a/application/application.android.ts b/application/application.android.ts index 6bafb8e40..7b501d7fc 100644 --- a/application/application.android.ts +++ b/application/application.android.ts @@ -4,6 +4,7 @@ import frame = require("ui/frame"); import types = require("utils/types"); import observable = require("data/observable"); import enums = require("ui/enums"); +import fileResolverModule = require("file-system/file-name-resolver"); global.moduleMerge(appModule, exports); @@ -71,6 +72,8 @@ var initEvents = function () { return; } + (androidApp).paused = true; + if (activity === androidApp.foregroundActivity) { if (exports.onSuspend) { exports.onSuspend(); @@ -91,6 +94,8 @@ var initEvents = function () { return; } + (androidApp).paused = false; + if (activity === androidApp.foregroundActivity) { if (exports.onResume) { exports.onResume(); @@ -347,3 +352,18 @@ function onConfigurationChanged(context: android.content.Context, intent: androi }); } } + +global.__onLiveSync = function () { + if (exports.android && exports.android.paused) { + return; + } + + // Clear file resolver cache to respect newly added files. + fileResolverModule.clearCache(); + + // Reload app.css in case it was changed. + appModule.loadCss(); + + // Reload current page. + frame.reloadPage(); +} \ No newline at end of file diff --git a/application/application.ios.ts b/application/application.ios.ts index a1910d018..4f2dc6241 100644 --- a/application/application.ios.ts +++ b/application/application.ios.ts @@ -5,6 +5,7 @@ import view = require("ui/core/view"); import definition = require("application"); import enums = require("ui/enums"); import uiUtils = require("ui/utils"); +import fileResolverModule = require("file-system/file-name-resolver"); global.moduleMerge(appModule, exports); @@ -227,3 +228,18 @@ exports.start = function () { throw new Error("iOS Application already started!"); } } + +global.__onLiveSync = function () { + if (!started) { + return; + } + + // Clear file resolver cache to respect newly added files. + fileResolverModule.clearCache(); + + // Reload app.css in case it was changed. + appModule.loadCss(); + + // Reload current page. + frame.reloadPage(); +} \ No newline at end of file diff --git a/file-system/file-name-resolver.d.ts b/file-system/file-name-resolver.d.ts index 2d9e5d370..5b18d44e1 100644 --- a/file-system/file-name-resolver.d.ts +++ b/file-system/file-name-resolver.d.ts @@ -12,9 +12,11 @@ declare module "file-system/file-name-resolver" { export class FileNameResolver { constructor(context: PlatformContext); resolveFileName(path: string, ext: string): string; + clearCache(): void; } export function resolveFileName(path: string, ext: string): string; + export function clearCache(): void; //@private export function findFileMatch(path: string, ext: string, candidates: Array, context: PlatformContext): string diff --git a/file-system/file-name-resolver.ts b/file-system/file-name-resolver.ts index fdf023498..b9e7c785a 100644 --- a/file-system/file-name-resolver.ts +++ b/file-system/file-name-resolver.ts @@ -126,6 +126,10 @@ export class FileNameResolver implements definition.FileNameResolver { return result; } + public clearCache(): void { + this._cache = {}; + } + private resolveFileNameImpl(path: string, ext: string): string { var result: string = null; path = fs.path.normalize(path); @@ -239,3 +243,8 @@ export function resolveFileName(path: string, ext: string): string { return resolverInstance.resolveFileName(path, ext); } +export function clearCache(): void { + if (resolverInstance) { + resolverInstance.clearCache(); + } +} \ No newline at end of file