How can i optimize the following table insertion?

This code takes two seconds to process.

 

print(“before loop scholarships:”…system.getTimer())
for i = 1, scholarshipTableSize do

– Insert the row into the tableView
tableView:insertRow
{
     isCategory = false,
     rowHeight = 75,
     rowColor =
     {
          default = { 255, 232, 4 },
          over = { 0, 158, 255 },
     },
     lineColor = { 0, 0, 0 },
}
end

print(“after loop scholarships:”…system.getTimer())

scholarshipTableSize is somewhere around 1200. How can I optimize this insertion so that it performs faster?

Thanks

Honestly, that’s quite a lot of work. I believe that the recommendation for the max number of rows is only a few hundred, but you are trying to insert 1000’s which is a slightly different issue.

Question: Do you need to use a tableView or could you render the rows yourself using your own display groups in a scrollView? I believe this would be quicker to render.

Advice: I think that you would be better off inserting only 100 and then using a timer to intermittently insert 10 or so at a time, maybe the timer interval would be 500 milliseconds.

More advice: If you are trying to show that many rows it probably shows a flaw in the app UI logic, tbh. If you look at apps like the iOS Twitter client, you’ll see that they load a given number of rows and then allow the user to “pull down/up” to load more results. I think this would be better in your situation… You’re not hiding information from the user, but you are giving them the option to control the performance, to a degree.

Addendum: If they scroll down too far you could start trimming rows off the top, if UI performance drops. Also, there is actually a missing feature in the scrolling widgets which stops you from extending the scrollable size of the view.

HI Horacebury, Thanks for your answer.

Turns out, when I tried a newer build 2013.1137, the tableview was filled instantly :slight_smile: well… almost, 3 ms maybe.

Thanks,

Simon

Cool. Have you tried the latest build, 1156?

No I have not, thanks for reminding me :slight_smile:

Off topic: Do you have any idea why my http.request inside my app works fine for iOS devices, but no callbacks are made when testing on my android devices ? 

Naturally, I have the 

    android =

    {

        usesPermissions =

        {

            “android.permission.INTERNET”,

            “android.permission.WRITE_EXTERNAL_STORAGE”,

        },

    },

in my build.settings.

Thanks for your time. I have been scratching my head all day yesterday for this matter

Honestly, that’s quite a lot of work. I believe that the recommendation for the max number of rows is only a few hundred, but you are trying to insert 1000’s which is a slightly different issue.

Question: Do you need to use a tableView or could you render the rows yourself using your own display groups in a scrollView? I believe this would be quicker to render.

Advice: I think that you would be better off inserting only 100 and then using a timer to intermittently insert 10 or so at a time, maybe the timer interval would be 500 milliseconds.

More advice: If you are trying to show that many rows it probably shows a flaw in the app UI logic, tbh. If you look at apps like the iOS Twitter client, you’ll see that they load a given number of rows and then allow the user to “pull down/up” to load more results. I think this would be better in your situation… You’re not hiding information from the user, but you are giving them the option to control the performance, to a degree.

Addendum: If they scroll down too far you could start trimming rows off the top, if UI performance drops. Also, there is actually a missing feature in the scrolling widgets which stops you from extending the scrollable size of the view.

HI Horacebury, Thanks for your answer.

Turns out, when I tried a newer build 2013.1137, the tableview was filled instantly :slight_smile: well… almost, 3 ms maybe.

Thanks,

Simon

Cool. Have you tried the latest build, 1156?

No I have not, thanks for reminding me :slight_smile:

Off topic: Do you have any idea why my http.request inside my app works fine for iOS devices, but no callbacks are made when testing on my android devices ? 

Naturally, I have the 

    android =

    {

        usesPermissions =

        {

            “android.permission.INTERNET”,

            “android.permission.WRITE_EXTERNAL_STORAGE”,

        },

    },

in my build.settings.

Thanks for your time. I have been scratching my head all day yesterday for this matter