What is it for a spinner?

Hello,

While I load the items from a database (SQLite stored in the Sandbox) I try to use a spinner to indicate the user to wait for a moment.

Ok, I suppose this is the spinner is used for, but while the items are loaded, the spinner is stopped.

Seems the processor is busy and till the items are loaded the spinner can’t be working, but then I just don’t need the spinner, so, What is it for a spinner!?

Here you can see what I talking about:

[sharedmedia=core:attachments:135]

And here is the code called when I select an option:

local function filtraEstablecementos() local num\_estrelas = filtros[10] local i,j,l local ids\_tras\_filtro = {} local subcadena\_consulta = "" local nivel\_zona\_actual\_aux2 local function filtra() if not ultimo\_nivel then nivel\_zona\_actual\_aux2 = nivel\_zona\_actual else nivel\_zona\_actual\_aux2 = nivel\_zona\_actual\_aux end local function completaCadena() local cadena = "" local k if num\_estrelas \> 0 then cadena = cadena.." AND categoria="..num\_estrelas end for k=1,#filtros-1 do if filtros[k] == 1 then local ind = correspondencia\_filtros[k] cadena = cadena.." AND id IN (SELECT idHotel from iconosHotel WHERE idIcono="..ind..")" end end if entrada\_buscador ~= "" then cadena = cadena.." AND nombre LIKE '%"..entrada\_buscador.."%'" end return cadena end for i = 1,#array\_zonas do if (nivel\_zona\_actual\_aux2 == array\_zonas[i].id) then --and (#pila\_niveis \> 0) then local array\_id\_establecementos if que\_vexo == "hoteis" then array\_id\_establecementos = array\_zonas[i].id\_hoteis elseif que\_vexo == "apartamentos" then array\_id\_establecementos = array\_zonas[i].id\_apartamentos end subcadena\_consulta = completaCadena() for j=1,#array\_id\_establecementos do for fileira in db:nrows("SELECT id FROM hoteles WHERE id="..array\_id\_establecementos[j]..subcadena\_consulta) do table.insert(ids\_tras\_filtro,fileira.id) end end end end montaScrollDereita(ids\_tras\_filtro) end cargando:start() cargando.isVisible = true aviso\_non\_resultados.isVisible = false local tmr = timer.performWithDelay(400,filtra) end

Hi @alberto1,

For this process (loading a larger “set” of items), you might consider the native “setActivityIndicator” API. Here’s the documentation:

http://docs.coronalabs.com/api/library/native/setActivityIndicator.html

Brent

Hi Brent,

 
Thanks for your reply.
I try what you suggest but I getting the same issue, as you can see:

[sharedmedia=core:attachments:145]

And, even running right, what is it for a sipnner?

I suppose a spinner must do the same as the activity indicator…

The spinner looks like the native activity indicator. The difference is that the spinner doesnt run on its own thread, which means any blocking actions such as loading an image will render the spinner unable to animate.

The spinner was desinged primarily to be used with async network actions, such as downloading a file

Ok, Danny!

I understand till my app loads items from a database (for example), the spinner doesn’t run because it hasn’t got its own thread.

But, what about the activity indicator? I deduce the activity indicator has its own thread, so it must run while the items are been loaded, isn’t it? 

I need a way to indicate the user must wait till the information is loaded (and the information is loaded from local database and files), so, what’s the best choice?

I’d appreciate so much your help.

Hi @alberto1,

The “native” activity indicator is probably worth testing. Just remember that you can’t start and stop the indicator in the same code chunk… you need to start it when the process begins, and then queue a callback or other function to stop it when the process is complete.

http://docs.coronalabs.com/api/library/native/setActivityIndicator.html

Brent

Brent, I was struggling with the native activity indicator today and I’m so glad for your comment above. Is this behavior pattern unique to the activity indicator or is it a broader scheme related to the native objects? I would have thought this would be listed in the Gotchas section at http://docs.coronalabs.com/api/library/native/setActivityIndicator.html …  I’m still not sure I understand why. Is there something I can read up on this? I’m referring to 

Just remember that you can’t start and stop the indicatorin the same code chunk… you need to start it when the process begins, and then queue a callback or other function to stop it when the process is complete.

Thanks so much for your help! Regards,

Kerem

Hi @alberto1,

For this process (loading a larger “set” of items), you might consider the native “setActivityIndicator” API. Here’s the documentation:

http://docs.coronalabs.com/api/library/native/setActivityIndicator.html

Brent

Hi Brent,

 
Thanks for your reply.
I try what you suggest but I getting the same issue, as you can see:

[sharedmedia=core:attachments:145]

And, even running right, what is it for a sipnner?

I suppose a spinner must do the same as the activity indicator…

The spinner looks like the native activity indicator. The difference is that the spinner doesnt run on its own thread, which means any blocking actions such as loading an image will render the spinner unable to animate.

The spinner was desinged primarily to be used with async network actions, such as downloading a file

Ok, Danny!

I understand till my app loads items from a database (for example), the spinner doesn’t run because it hasn’t got its own thread.

But, what about the activity indicator? I deduce the activity indicator has its own thread, so it must run while the items are been loaded, isn’t it? 

I need a way to indicate the user must wait till the information is loaded (and the information is loaded from local database and files), so, what’s the best choice?

I’d appreciate so much your help.

Hi @alberto1,

The “native” activity indicator is probably worth testing. Just remember that you can’t start and stop the indicator in the same code chunk… you need to start it when the process begins, and then queue a callback or other function to stop it when the process is complete.

http://docs.coronalabs.com/api/library/native/setActivityIndicator.html

Brent

Brent, I was struggling with the native activity indicator today and I’m so glad for your comment above. Is this behavior pattern unique to the activity indicator or is it a broader scheme related to the native objects? I would have thought this would be listed in the Gotchas section at http://docs.coronalabs.com/api/library/native/setActivityIndicator.html …  I’m still not sure I understand why. Is there something I can read up on this? I’m referring to 

Just remember that you can’t start and stop the indicatorin the same code chunk… you need to start it when the process begins, and then queue a callback or other function to stop it when the process is complete.

Thanks so much for your help! Regards,

Kerem