mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
@@ -28,6 +28,7 @@ local FileChooser = Menu:extend{
|
||||
strcoll = strcoll,
|
||||
collate = "strcoll", -- or collate = "access",
|
||||
reverse_collate = false,
|
||||
path_pages = {}, -- store last browsed location(page) for each path
|
||||
}
|
||||
|
||||
function FileChooser:init()
|
||||
@@ -148,8 +149,14 @@ function FileChooser:genItemTableFromPath(path)
|
||||
return item_table
|
||||
end
|
||||
|
||||
function FileChooser:updateItems(select_number)
|
||||
Menu.updateItems(self, select_number) -- call parent's updateItems()
|
||||
self.path_pages[self.path] = self.page
|
||||
end
|
||||
|
||||
function FileChooser:refreshPath()
|
||||
self:swithItemTable(nil, self:genItemTableFromPath(self.path))
|
||||
self.page = self.path_pages[self.path] or 1
|
||||
self:swithItemTable(nil, self:genItemTableFromPath(self.path), -1)
|
||||
end
|
||||
|
||||
function FileChooser:changeToPath(path)
|
||||
|
||||
@@ -675,6 +675,12 @@ function Menu:swithItemTable(new_title, new_item_table, itemnumber)
|
||||
self.page = math.ceil(itemnumber / self.perpage)
|
||||
end
|
||||
|
||||
-- make sure current page is in right page range
|
||||
local max_pages = math.ceil(#new_item_table / self.perpage)
|
||||
if self.page > max_pages then
|
||||
self.page = max_pages
|
||||
end
|
||||
|
||||
self.item_table = new_item_table
|
||||
self:updateItems(1)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user