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:
parent
011c5b6544
commit
8cd80288a0
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user