mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Merge pull request #1587 from frankyifei/2015-8-1
fix filechooser crash and loop menu pages
This commit is contained in:
@@ -57,13 +57,15 @@ function FileChooser:genItemTableFromPath(path)
|
||||
if self.show_hidden or not string.match(f, "^%.[^.]") then
|
||||
local filename = self.path.."/"..f
|
||||
local attributes = lfs.attributes(filename)
|
||||
if attributes.mode == "directory" and f ~= "." and f~=".." then
|
||||
if self.dir_filter(filename) then
|
||||
table.insert(dirs, {name = f, attr = attributes})
|
||||
end
|
||||
elseif attributes.mode == "file" then
|
||||
if self.file_filter(filename) then
|
||||
table.insert(files, {name = f, attr = attributes})
|
||||
if attributes ~= nil then
|
||||
if attributes.mode == "directory" and f ~= "." and f~=".." then
|
||||
if self.dir_filter(filename) then
|
||||
table.insert(dirs, {name = f, attr = attributes})
|
||||
end
|
||||
elseif attributes.mode == "file" then
|
||||
if self.file_filter(filename) then
|
||||
table.insert(files, {name = f, attr = attributes})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -805,6 +805,8 @@ function Menu:onNextPage()
|
||||
if end_position ~= self.selected.y then
|
||||
self:updateItems(end_position)
|
||||
end
|
||||
self.page = 1
|
||||
self:updateItems(1)
|
||||
end
|
||||
return true
|
||||
end
|
||||
@@ -812,6 +814,8 @@ end
|
||||
function Menu:onPrevPage()
|
||||
if self.page > 1 then
|
||||
self.page = self.page - 1
|
||||
elseif self.page == 1 then
|
||||
self.page = self.page_num
|
||||
end
|
||||
self:updateItems(1)
|
||||
return true
|
||||
|
||||
@@ -511,16 +511,20 @@ end
|
||||
function TouchMenu:onNextPage()
|
||||
if self.page < self.page_num then
|
||||
self.page = self.page + 1
|
||||
self:updateItems()
|
||||
elseif self.page == self.page_num then
|
||||
self.page = 1
|
||||
end
|
||||
self:updateItems()
|
||||
return true
|
||||
end
|
||||
|
||||
function TouchMenu:onPrevPage()
|
||||
if self.page > 1 then
|
||||
self.page = self.page - 1
|
||||
self:updateItems()
|
||||
elseif self.page == 1 then
|
||||
self.page = self.page_num
|
||||
end
|
||||
self:updateItems()
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user