mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
fix(Application): inBackground handling & missing once (#10307)
This commit is contained in:
@@ -128,6 +128,7 @@ export class ApplicationCommon {
|
|||||||
|
|
||||||
// Application events go through the global events.
|
// Application events go through the global events.
|
||||||
on: ApplicationEvents['on'] = globalEvents.on.bind(globalEvents);
|
on: ApplicationEvents['on'] = globalEvents.on.bind(globalEvents);
|
||||||
|
once: ApplicationEvents['on'] = globalEvents.once.bind(globalEvents);
|
||||||
off: ApplicationEvents['off'] = globalEvents.off.bind(globalEvents);
|
off: ApplicationEvents['off'] = globalEvents.off.bind(globalEvents);
|
||||||
notify: ApplicationEvents['notify'] = globalEvents.notify.bind(globalEvents);
|
notify: ApplicationEvents['notify'] = globalEvents.notify.bind(globalEvents);
|
||||||
hasListeners: ApplicationEvents['hasListeners'] = globalEvents.hasListeners.bind(globalEvents);
|
hasListeners: ApplicationEvents['hasListeners'] = globalEvents.hasListeners.bind(globalEvents);
|
||||||
|
|||||||
@@ -138,11 +138,11 @@ class NativeScriptLifecycleCallbacks extends android.app.Application.ActivityLif
|
|||||||
|
|
||||||
this.activitiesCount++;
|
this.activitiesCount++;
|
||||||
if (this.activitiesCount === 1) {
|
if (this.activitiesCount === 1) {
|
||||||
Application.android.notify({
|
Application.android.setInBackground(false, {
|
||||||
eventName: Application.foregroundEvent,
|
// todo: deprecate event.android in favor of event.activity
|
||||||
object: Application.android,
|
|
||||||
android: activity,
|
android: activity,
|
||||||
} as ApplicationEventData);
|
activity,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Application.android.notify({
|
Application.android.notify({
|
||||||
@@ -157,11 +157,11 @@ class NativeScriptLifecycleCallbacks extends android.app.Application.ActivityLif
|
|||||||
// console.log('NativeScriptLifecycleCallbacks onActivityStopped');
|
// console.log('NativeScriptLifecycleCallbacks onActivityStopped');
|
||||||
this.activitiesCount--;
|
this.activitiesCount--;
|
||||||
if (this.activitiesCount === 0) {
|
if (this.activitiesCount === 0) {
|
||||||
Application.android.notify({
|
Application.android.setInBackground(true, {
|
||||||
eventName: Application.backgroundEvent,
|
// todo: deprecate event.android in favor of event.activity
|
||||||
object: Application.android,
|
|
||||||
android: activity,
|
android: activity,
|
||||||
} as ApplicationEventData);
|
activity,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Application.android.notify({
|
Application.android.notify({
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ global.CFRunLoopWakeUp = function (runloop) {};
|
|||||||
global.NativeScriptGlobals = {
|
global.NativeScriptGlobals = {
|
||||||
events: {
|
events: {
|
||||||
on: (args) => {},
|
on: (args) => {},
|
||||||
|
once: (args) => {},
|
||||||
off: (args) => {},
|
off: (args) => {},
|
||||||
notify: (args) => {},
|
notify: (args) => {},
|
||||||
hasListeners: (args) => {},
|
hasListeners: (args) => {},
|
||||||
|
|||||||
Reference in New Issue
Block a user