Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

newTableWidget row how check if exist
Started by anaqim Sep 27 2017 03:59 AM

3 replies to this topic
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

anaqim

[GLOBAL: userInfoPane.html]
anaqim
  • Contributor

  • 770 posts
  • Corona SDK

Hi,

 

I have a table widget with images being downloaded using network.request and displayed as they arrive, which works fine.

 

But, on a slow network and while scrolling fast, sometimes these async callbacks return image info after the row has scrolled past the screen and into oblivion. It then shows error that the row (display group) is missing upon image creation. 

 

Is there a way to detect if the row still exist before trying to create the row image?

 

Thank in advance!

 

Anaqim



[TOPIC: post.html]
#2

bjsorrentino

[GLOBAL: userInfoPane.html]
bjsorrentino
  • Veteran

  • 8,506 posts
  • Corona SDK

I haven't tested it, but one suggestion is to wrap the image placement/creation within a conditional block that checks the value of the "getRowAtIndex()" API. This API will return nil if the row is not currently in view, so in theory it would simply skip the image rendering if the API returns nil for the index of the row you're trying to render the image into.

 

https://docs.coronalabs.com/api/type/TableViewWidget/getRowAtIndex.html

 

Brent



[TOPIC: post.html]
#3

anaqim

[GLOBAL: userInfoPane.html]
anaqim
  • Contributor

  • 770 posts
  • Corona SDK

man, so easy and i never thought of it  :huh:

works like a charm, thanks brent!



[TOPIC: post.html]
#4

anaqim

[GLOBAL: userInfoPane.html]
anaqim
  • Contributor

  • 770 posts
  • Corona SDK

if anyone else need a pointer on the subject, this is the conditional statement that works

if object:getRowAtIndex(index) then
   <your code>
end



[topic_controls]
[/topic_controls]