语言

Menu
Sites
Language
Genlist content_get method called twice

Hi All,

I am using Genlist, with Items created of two class types, 

1. default

2. full

I have observed that the content_get() method is called twice for each item?

Why is it so, is there a defect with the platform or I may be doing something mysterious.

Please give your inputs.

Thanx,

Ashwini

响应

10 回复
Jean Yang

Hi,

can you please explain more about your issue, do you use the sample code to create your app, share the code where you call your gl_content_get_cb will be help to found the issue.

thanks.

colin Rao

f.y.i.

For the default style,  each item have three part [elm.swallow.icon, elm.text, elm.swallow.end], the swallow part will call the content_get, the text part will call the text_get. So, I think it's right to call content_get twice for each item.

For the full style, each item only have one part [elm.swallow.content], I think in this case the content_get only get called once for each item.

Could you try to check the part name in the content_get function, such as dlog it to console to check the difference. 

Ashwini Kumar

Hi,

I am using the style "full".

Only has content get. This is called twice.

regards,

Ashwini

Jean Yang

 

Hi,

 

For the IDE help ducument there is a exaplain for func in Elm_Genlist_Item_Class:

The func structure contains pointers to functions that are called when an item is going to be created or deleted. All of them receive a data parameter that points to the same data passed to the elm_genlist_item_append() and related item creation functions, and an obj parameter that points to the genlist object itself.

I have try the full mode and and the content_get was called twice, but acutally in my code only has 1 time operation(elm_genlist_item_append) which related to item create /deleted, seems this is design like this.

For more, I checked the sample code in IDE:

In genlist demo, function gl_content_get_cb, there is one line strange code I list below, seems they know the content get will called twice.

if (rand() % 2) return NULL;

Alex Dem

Hi,
Yes, in UI Controls native example for genlist item_style=full 'gl_content_get_cb' is called twice for every method.
but looks like string: if (rand() % 2) return NULL; does not relate to item_style=full  or  item_style=default.
Alexey.

Jean Yang

Hi Alex, 

Yes, you are right,the code if(rand()%2 return NULL; will apply to all style, not only for full or default, I guess this intent is just to response once for content get call back.

Alex Dem

Hi, I have checked
For some styles content_get CB is called 4 times (default, default style, double label)
For 'message' CB is not called at all.
For other : twice

Without the string if(rand()%2 return NULL; icon will added to the begin and to the end of every item (default, default style, double label). And one time for other item, except 'message' style ('group_index' & 'full' styles have their own logic)

With this string icons are added randomly just.
Alexey.

Carsten Haitzler

content_get will be called every time the genlist needs the content. content objects returned may be deleted by genlist at any point. in the case of large lists, content_get will be called for lots of non-visible items because genlist is attempting to calulate sizing of tiems based on their content (width of the list so it may have to scroll horizontally, and every item could have a different height based on content). so this is one path you will get more than one call over the lifetime of an item in a gnelist.

as you scroll through the list, as needed, items will call the content_get to get the actual content for the swallow parts.

in addition the content_get is called PER swallow part in the item. the const char *part string param will name the part it is asking for. return different content per part as desired (or NULL for no content at all).

this is the "contract" between you and genlist. if you want to be really fast - make sure you are fast in returning new content objects. don't, for example, go do some sqlite or file i/o query to figure out what to return - ensure results are already in memory. if they are not, this is your opportunity to queue a thread worker to go do the "slow fetch i/o" and WHEN that worker is done, call an update on this item, which will force a call on content_get again and now you can return data that is now cached/stored in ram.

i hope this helps.

Jean Yang

Hi Carsten,

Thanks for your clarification, so as you mentioned--content_get will be called every time the genlist needs the content.  But I found that when I create an 1 item genlist, it also called twice, is this mean when we create genlist,1 time for getting the content, and the others are for adapting the genlist( the width, or genlist size,or some non-visible items). 

Carsten Haitzler

Could be for adapting or once PER swallow part - eg standard genlist item class has 2 swallow areas - the one at the start and another at the end of the item. soit'll be called once per swallow with the string passed in as above named differently so you know which part it wants.