2
0
mirror of https://github.com/koreader/koreader synced 2024-11-18 03:25:46 +00:00

Implement UIManager:unschedule(action). Fixes #1007.

This commit is contained in:
Frans de Jonge 2014-11-06 12:59:00 +01:00
parent 011c5b6544
commit 8cd80288a0
2 changed files with 13 additions and 1 deletions

View File

@ -90,7 +90,7 @@ function Device:onPowerEvent(ev)
self.screen:setRotationMode(0)
Screensaver:show()
self:prepareSuspend()
UIManager:scheduleIn(2, function() self:Suspend() end)
UIManager:scheduleIn(10, self.Suspend)
elseif (ev == "Power" or ev == "Resume") and self.screen_saver_mode then
DEBUG("Resuming...")
-- restore to previous rotation mode
@ -113,6 +113,8 @@ function Device:Suspend()
end
function Device:Resume()
local UIManager = require("ui/uimanager")
UIManager:unschedule(self.Suspend)
self.screen:refresh(1)
self.screen_saver_mode = false
end

View File

@ -191,6 +191,16 @@ function UIManager:scheduleIn(seconds, action)
self:schedule(when, action)
end
function UIManager:unschedule(action)
for i = #self._execution_stack, 1, -1 do
local task = self._execution_stack[i]
if task.action == action then
-- remove from table
table.remove(self._execution_stack, i)
end
end
end
-- register a widget to be repainted
function UIManager:setDirty(widget, refresh_type)
-- "auto": request full refresh