[RESOLVED] Loading Remote Images with TableView

So, I am using code provided by robmiracle to pull some RSS data down. I can get it to load in everything I want, but the only way I’ve found to cache the thumbnail images does not seem to be working. The first page’s thumbnails will not load unless I scroll them off the screen and come back, and often times the thumbnails are getting inserted into the wrong rows (or piling up in the upper right corner). Is there a better way of doing this then having it download in the ‘onRowRender’ function? I thought about perhaps adding a function to download all the thumbnails (with some sort of progress bar indicator), then go into the list. Thoughts?

Sean

[code]
local function onRowRender( event )

local row = event.target
local rowGroup = event.view
g = display.newGroup()

local title = display.newRetinaText( stories[i].title, 0, 60, native.systemFont, 20 )
title:setReferencePoint( display.TopLeftReferencePoint )
title.y = row.height * 0.1; title.x = _w * .03
title:setTextColor( 0 )
g:insert( title )

local description = display.newRetinaText( stories[i].puredescription, 0, 52, _h / 2, 60, native.systemFont, 18 )
description:setReferencePoint( display.TopLeftReferencePoint )
description.y = title.y + 25; description.x = _w * .03
description:setTextColor( 0 )
g:insert( description )

local function networkListener( event )
if ( event.isError ) then
print ( “Network error - download failed” )
else
if ( “temp” … i … “.png” == nil ) then
print( “not ready yet.” )
row.reRender = true
else
thumbImg = display.newImage( “temp” … i … “.png”, system.TemporaryDirectory, 0, 0 )
thumbImg:scale( .15, .15 )
thumbImg.y = row.height * .50; thumbImg.x = _w / 1.1
g:insert( thumbImg )
end
end

print ( "RESPONSE: " … event.response )
end

network.download( stories[i].thumbnail.url, “GET”, networkListener, “temp” … i … “.png”, system.TemporaryDirectory )

rowGroup:insert( g )
end
[/code] [import]uid: 157382 topic_id: 31909 reply_id: 331909[/import]

Just FYI, I figured this problem out. I put a test in to check if the file exists, and if it did not I placed a temporary icon there and initiated the download. That way when the row re-renders later, the proper icon will exist and will be displayed. [import]uid: 157382 topic_id: 31909 reply_id: 127906[/import]

Just FYI, I figured this problem out. I put a test in to check if the file exists, and if it did not I placed a temporary icon there and initiated the download. That way when the row re-renders later, the proper icon will exist and will be displayed. [import]uid: 157382 topic_id: 31909 reply_id: 127906[/import]