Merge pull request #1798 from houqp/houqp-master

minor refactor
pull/1785/head
Huang Xin 8 years ago
commit b3beb71432

@ -7,8 +7,8 @@ local ReaderHinting = EventListener:new{
function ReaderHinting:onHintPage()
if not self.view.hinting then return true end
for i=1, DHINTCOUNT do
if self.view.state.page + i <= self.ui.document.info.number_of_pages then
self.ui.document:hintPage(
if self.view.state.page + i <= self.document.info.number_of_pages then
self.document:hintPage(
self.view.state.page + i,
self.zoom:getZoom(self.view.state.page + i),
self.view.state.rotation,

@ -259,11 +259,14 @@ function ReaderUI:init()
self:registerPostInitCallback(function()
self.document:loadDocument()
-- read additional settings after the document has been loaded
-- (but not rendered yet)
-- used to read additional settings after the document has been
-- loaded (but not rendered yet)
self:handleEvent(Event:new("PreRenderDocument", self.doc_settings))
self.document:render()
-- CREngine only reports correct page count after rendering is done
self:handleEvent(Event:new("PostRenderDocument", self.doc_settings))
end)
-- typeset controller
self:registerModule("typeset", ReaderTypeset:new{

@ -58,9 +58,7 @@ function ReaderStatistics:initData(config)
if self.is_enabled then
local book_properties = self:getBookProperties()
self:savePropertiesInToData(book_properties)
if config.data.stats then
self.data = config.data.stats
else
if not self.data then
--first time merge data
self:inplaceMigration();
end
@ -490,9 +488,12 @@ function ReaderStatistics:saveSettings(fields)
end
function ReaderStatistics:onReadSettings(config)
-- delay initialization for accurate total pages count of the doc
UIManager:scheduleIn(0.1, function() self:initData(config) end)
self.data = config.data.stats
end
return ReaderStatistics
function ReaderStatistics:onPostRenderDocument()
-- we have correct page count now, do the actual initialization work
self:initData()
end
return ReaderStatistics

Loading…
Cancel
Save