Add update partial method for listview
This commit is contained in:
parent
3269df63d6
commit
0cb62033ef
23
listview.lua
23
listview.lua
|
@ -18,6 +18,10 @@ local function redrawLine(idx)
|
|||
frame.setCursorPos(1, idx-paginationOffset+1)
|
||||
if drawLine then
|
||||
drawLine(frame, backingList[idx])
|
||||
else
|
||||
frame.setBackgroundColor(colors.red)
|
||||
frame.clearLine()
|
||||
frame.setBackgroundColor(colors.black)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -59,6 +63,10 @@ local function redraw()
|
|||
end
|
||||
backingIdx = backingIdx + 1
|
||||
end
|
||||
else
|
||||
frame.setBackgroundColor(colors.red)
|
||||
frame.clear()
|
||||
frame.setBackgroundColor(colors.black)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -69,6 +77,20 @@ local function updatePage(newOffset)
|
|||
end
|
||||
end
|
||||
|
||||
local function updatePartial(filter)
|
||||
if drawLine then
|
||||
local tw, th = frame.getSize()
|
||||
local backingIdx = paginationOffset
|
||||
for idx = 1, th, 1 do
|
||||
frame.setCursorPos(1, idx)
|
||||
if backingList[backingIdx] ~= nil and filter(backingList[backingIdx]) then
|
||||
drawLine(frame, backingList[backingIdx])
|
||||
end
|
||||
backingIdx = backingIdx + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return {
|
||||
setTerm=setTerm,
|
||||
|
@ -78,4 +100,5 @@ return {
|
|||
clearFrom=clearFrom,
|
||||
redraw=redraw,
|
||||
updatePage=updatePage,
|
||||
updatePartial=updatePartial,
|
||||
}
|
||||
|
|
|
@ -101,6 +101,7 @@ local function onTouch(self, touch_x, touch_y)
|
|||
else
|
||||
permset.add(allowed_items, obj.answer.name)
|
||||
end
|
||||
listview.updatePartial(function (item) return item.answer ~= nil and item.answer.name == obj.answer.name end)
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue