Kodi Community Forum

Full Version: Determining if a notification dialog is open
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Currently working on a v19 version of my addon and I'm implementing several dialogs, background progress dialogs, and notification dialogs.

I've found in testing that if I have one function generate a notification and a follow on function generate another notification, that problems can occur.

For example:
python:

def func1():
current_dialog = xbmcgui.Dialog()
current_dialog.notification('Test1','Test1',xbmcgui.NOTIFICATION_INFO,5000,sound=False)
... do stuff...
xbmc.executebuiltin('Dialog.Close(notification,true)')
xbmc.sleep(NOTIFICATION_DEINIT_TIME) #Close the notification and wait for de-init to ensure any follow on notification are correctly shown, unsure if there's a better way to do this
del current_dialog

def func2():
current_dialog = xbmcgui.Dialog()
current_dialog.notification('Test2,'Test2',xbmcgui.NOTIFICATION_INFO,5000,sound=False)
... do stuff...
xbmc.executebuiltin('Dialog.Close(notification,true)')
xbmc.sleep(NOTIFICATION_DEINIT_TIME) #Close the notification and wait for de-init to ensure any follow on notification are correctly shown, unsure if there's a better way to do this
del current_dialog

If I call the first function and notification, then the second function and notification there can be a race condition where the first notification isn't fully closed/removed and the second notification wont appear.

Is there a way to determine if a dialog or notification is visible/open to avoid any race conditions? It doesn't appear that xbmcgui.getCurrentWindowId() works for dialog.notification.

Thanks in advance
(2021-01-15, 23:20)zachmorris Wrote: [ -> ]Currently working on a v19 version of my addon and I'm implementing several dialogs, background progress dialogs, and notification dialogs.

I've found in testing that if I have one function generate a notification and a follow on function generate another notification, that problems can occur.

For example:
python:

def func1():
current_dialog = xbmcgui.Dialog()
current_dialog.notification('Test1','Test1',xbmcgui.NOTIFICATION_INFO,5000,sound=False)
... do stuff...
xbmc.executebuiltin('Dialog.Close(notification,true)')
xbmc.sleep(NOTIFICATION_DEINIT_TIME) #Close the notification and wait for de-init to ensure any follow on notification are correctly shown, unsure if there's a better way to do this
del current_dialog

def func2():
current_dialog = xbmcgui.Dialog()
current_dialog.notification('Test2,'Test2',xbmcgui.NOTIFICATION_INFO,5000,sound=False)
... do stuff...
xbmc.executebuiltin('Dialog.Close(notification,true)')
xbmc.sleep(NOTIFICATION_DEINIT_TIME) #Close the notification and wait for de-init to ensure any follow on notification are correctly shown, unsure if there's a better way to do this
del current_dialog

If I call the first function and notification, then the second function and notification there can be a race condition where the first notification isn't fully closed/removed and the second notification wont appear.

Is there a way to determine if a dialog or notification is visible/open to avoid any race conditions? It doesn't appear that xbmcgui.getCurrentWindowId() works for dialog.notification.

Thanks in advance

I have a service process which does a lot of background processing with timers and events.  I use a combination of addon settings and global variables to manage race conditions.  For example, I'll set an addon setting or global variable when action 1 occurs and then when action 2 starts I check if action 1 is still active before doing anything.  if it is, action 2 exits.  Action1 resets the setting or variable when it ends.  Likewise in reverse is action 2 fires first.  Probably not the most elegant solution but it has been bulletproof for me.


Jeff
Maybe xbmc.getCondVisibility('Window.IsActive(notification)') ? I've never tried it so don't know if it'll work.
(2021-01-16, 19:50)Roman_V_M Wrote: [ -> ]Maybe xbmc.getCondVisibility('Window.IsActive(notification)') ? I've never tried it so don't know if it'll work.

That worked. Thank you!