Fix circular dependency on context menu

This commit is contained in:
Matt
2021-12-30 09:44:25 -05:00
parent 5c3740b8a9
commit aa7a412a94
3 changed files with 81 additions and 36 deletions

View File

@@ -9,7 +9,6 @@ import sys
import json
from .loghandler import LazyLogger
from .functions import show_menu
log = LazyLogger(__name__)
addon = xbmcaddon.Addon()
@@ -65,36 +64,3 @@ def get_kodi_version():
log.error("Version Error : RAW Version Data: {0}".format(result))
return version
class ContextMonitor(threading.Thread):
stop_thread = False
def run(self):
item_id = None
log.debug("ContextMonitor Thread Started")
while not xbmc.Monitor().abortRequested() and not self.stop_thread:
if xbmc.getCondVisibility("Window.IsActive(fullscreenvideo) | Window.IsActive(visualisation)"):
xbmc.sleep(1000)
else:
if xbmc.getCondVisibility("Window.IsVisible(contextmenu)"):
if item_id:
xbmc.executebuiltin("Dialog.Close(contextmenu,true)")
params = {}
params["item_id"] = item_id
show_menu(params)
container_id = xbmc.getInfoLabel("System.CurrentControlID")
item_id = xbmc.getInfoLabel("Container(" + str(container_id) + ").ListItem.Property(id)")
xbmc.sleep(100)
log.debug("ContextMonitor Thread Exited")
def stop_monitor(self):
log.debug("ContextMonitor Stop Called")
self.stop_thread = True

79
resources/lib/monitors.py Normal file
View File

@@ -0,0 +1,79 @@
from __future__ import division, absolute_import, print_function, unicode_literals
import threading
import xbmc
from .functions import show_menu
from .loghandler import LazyLogger
from .widgets import check_for_new_content
from .tracking import timer
log = LazyLogger(__name__)
class ContextMonitor(threading.Thread):
stop_thread = False
def run(self):
item_id = None
log.debug("ContextMonitor Thread Started")
while not xbmc.Monitor().abortRequested() and not self.stop_thread:
if xbmc.getCondVisibility("Window.IsActive(fullscreenvideo) | Window.IsActive(visualisation)"):
xbmc.sleep(1000)
else:
if xbmc.getCondVisibility("Window.IsVisible(contextmenu)"):
if item_id:
xbmc.executebuiltin("Dialog.Close(contextmenu,true)")
params = {}
params["item_id"] = item_id
show_menu(params)
container_id = xbmc.getInfoLabel("System.CurrentControlID")
item_id = xbmc.getInfoLabel("Container(" + str(container_id) + ").ListItem.Property(id)")
xbmc.sleep(100)
log.debug("ContextMonitor Thread Exited")
def stop_monitor(self):
log.debug("ContextMonitor Stop Called")
self.stop_thread = True
class LibraryChangeMonitor(threading.Thread):
last_library_change_check = 0
library_check_triggered = False
exit_now = False
time_between_checks = 10
def __init__(self):
threading.Thread.__init__(self)
def stop(self):
self.exit_now = True
@timer
def check_for_updates(self):
log.debug("Trigger check for updates")
self.library_check_triggered = True
def run(self):
log.debug("Library Monitor Started")
monitor = xbmc.Monitor()
while not self.exit_now and not monitor.abortRequested():
if self.library_check_triggered and not xbmc.Player().isPlaying():
log.debug("Doing new content check")
check_for_new_content()
self.library_check_triggered = False
self.last_library_change_check = time.time()
if self.exit_now or monitor.waitForAbort(self.time_between_checks):
break
log.debug("Library Monitor Exited")

View File

@@ -11,12 +11,12 @@ import xbmcgui
from resources.lib.downloadutils import DownloadUtils, save_user_details
from resources.lib.loghandler import LazyLogger
from resources.lib.play_utils import Service, PlaybackService, send_progress
from resources.lib.kodi_utils import HomeWindow, ContextMonitor
from resources.lib.kodi_utils import HomeWindow
from resources.lib.widgets import set_background_image, set_random_movies
from resources.lib.websocket_client import WebSocketClient
from resources.lib.menu_functions import set_library_window_values
from resources.lib.server_detect import check_server, check_safe_delete_available, check_connection_speed
from resources.lib.library_change_monitor import LibraryChangeMonitor
from resources.lib.monitors import LibraryChangeMonitor, ContextMonitor
from resources.lib.datamanager import clear_old_cache_data
from resources.lib.tracking import set_timing_enabled
from resources.lib.image_server import HttpImageServerThread