Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Posts: 160
Registered: ‎01-27-2012
My Device: Playbook
My Carrier: Rogers

Images in s listview

I'm trying to implement a long list of images in a listview (essentially a custom image picker).  The issue is that the images themselves are quite large so for memory management  I load the image, scaled them down using Qimage and then present it to then  using attached ImageSCaler.  Here's a sample of the code:

 

        ImageView {
            id:imageviewID

        }
            attachedObjects: [
                ImageScaler {
                    id: loader
                    imageSource: ListItemData.thumbURL                   
                    onImageChanged: {
                        imageviewID.image = loader.image
                    }
                }]
    }

My sample gallery has 50 images.   My issue is that as the listview scrolls along it clears the cache off screen and then it lags reloading the images once you scroll back.   Since I've scaled the images down, I don't expect it will occupy too much memory and I'd like to just leave the images in cache, instead of reloading.  Does anyone have any suggestions how I can implment this?

 

I've reviewed this sample but it seems to load small files and I need to some how rescale them.

 

ttps://developer.blackberry.com/cascades/documentation/ui/lists/asynch_data.html

 

Does anyone have any suggestions how can I implement this?

---
If you find my post helpful please "like" it and "accept as a solution"
Developer
Posts: 160
Registered: ‎01-27-2012
My Device: Playbook
My Carrier: Rogers

Re: Images in s listview

Any help about listview would be greatly appreciated as I've struggled with this topic for over a month now.  I've identified that the issue is that even if I do something like:

 

Imageview{

imageSource: ListItemData.URL

}

 

This listitemdata changes as it scrolls off the screen as listviews appear to reindex themselves, forcing an onImageSourceChanged.  I can't find any details about how listviews index.    How can I get the Imageview so that caches and then pulls from an index cache instead of reloading by executing an onImageSourceChanged?

---
If you find my post helpful please "like" it and "accept as a solution"
Developer
Posts: 526
Registered: ‎05-17-2009
My Device: 9900
My Carrier: ATT

Re: Images in s listview

At a basic level, ListView keeps say 20 list items in memory and then as you scroll it cycles them and updates the data in each list item with the next in the list.

Check this out here... http://blackberry.github.com/Qt2Cascades-Samples/docs/tools-contiguouscache-src-imagemodel-hpp.html

http://blackberry.github.com/Qt2Cascades-Samples/docs/tools-contiguouscache-src-imagemodel-cpp.html
Like all of my posts
Developer
Posts: 160
Registered: ‎01-27-2012
My Device: Playbook
My Carrier: Rogers

Re: Images in s listview

Thank you.

 

That example overwrites the entire data(indexPath) function.  For listitemdata, does that actually call the data(IndexPath) method?   So is the method then to modify the data(IndexPath) by inserting the contingouscached image in the returned QVariant(QvariantMap) and then just return the rest of the QVariant @ index Path?

---
If you find my post helpful please "like" it and "accept as a solution"
Developer
Posts: 526
Registered: ‎05-17-2009
My Device: 9900
My Carrier: ATT

Re: Images in s listview

I dont quite follow exactly, but what I think you should do is use the image property of ImageView, and have a helper c++ class/function that has a cache in it, takes the url as an argument and returns a bb::cascades::Image

so instead of:
ImageView {
imageSource: ListItemData.URL
}

have something like
ImageView {
image: listItemContainer.ListItem.view.someFunction(ListItemData.URL) //id to root of the list item, calls a function in the list view that may link to a c++ class that has your cache
}
Like all of my posts