PDA

View Full Version : How to avoid flick when changing list?



cdiscla
8 Feb 2012, 3:33 AM
I'm building an app using SenchaTouch; the app connects to a web server that returns query results; queries are dynamic so i need to create at runtime models, bind to a store and bind the store to the list by modifying the template on the fly.
After a lot of work, it runs but i've seen that when i change list, it shows me the previous list and, after a little time, it shows the new, by giving a not so good "flick" effect.
Is there a way to avoid it?
Thanks and greetings !
c.

mitchellsimoens
8 Feb 2012, 9:07 AM
I don't know what you mean by flick effect? Also what do you mean changing lists? Just by using something like setActiveItem?

cdiscla
8 Feb 2012, 9:18 AM
Yes, this happens every time that i call setActiveItem.
When the user taps on an item i call setActiveItem and call a function that gets data from a WS; data structure can be different (n-fields to show) so i change the model at runtime and according to these data i re-bind a store and exec the following code:

MbiApp.views.ListUserQueryValues.bindStore(newStore);
MbiApp.views.ListUserQueryValues.itemTpl=UserQueryItemTemplate;
MbiApp.views.ListUserQueryValues.initComponent();
MbiApp.views.ListUserQueryValues.refresh();

I hope and think there is a better way but don't know it.

Thanks in advance
c.

mitchellsimoens
8 Feb 2012, 9:19 AM
Instead of doing all that... I would create a new list for when I call setActiveItem as you are already basically doing that just manually. I also wouldn't call initComponent

cdiscla
8 Feb 2012, 9:24 AM
Thank you, i will try it.
So it is better to create a new list every time? Don't i risk to have memory problems?

Greetings.

mitchellsimoens
8 Feb 2012, 9:25 AM
Not if you remove old lists.

cdiscla
9 Feb 2012, 2:15 AM
Thank you for your answers, but still have a problem :-(

Now i remove the old view, it runs for the first time but in the following "taps" the user is redirected to the home screen; the code i use is:

MyApp.views.viewport.remove("ListUserQueryContainer");
MyApp.views.ListUserQueryContainer=getList();

console.log(MbiApp.views.ListUserQueryContainer);

MyApp.views.viewport.add("ListUserQueryContainer");
MyApp.views.viewport.doLayout();

In the getList() function i return a new Ext.Panel with id:"ListUserQueryContainer".
What am i doing wrong?
Thanks in advance !

cdiscla
9 Feb 2012, 6:58 AM
...sorry, i've solved; i was missing a (important as usual) doLayout() !

Thanks for everything !