11-13-2010 03:16 AM
I am just using static method for streamconnection to retreive images over from server.
Now my problem is that it takes to much time to load.
so i want that at the first just insert null images to all the fields and there after as the thread retrieves the image same time it will update the field with that image.
Solved! Go to Solution.
11-13-2010 03:20 AM
Why don't you use the HttpConnection instead of StreamConnection.
And image Size is to Big or small. It should not take much time to download.
Press Kudo to say thank to developer.
Also Press the Accept as solution Button when u got the Solution.
11-13-2010 04:42 AM
if i am using httpconnection and if there are number of images then what?
so what i want is first initially load 5 or 10 images to the screen there after as the images retrieve draw them to the screen.
11-13-2010 10:41 AM
Not sure how we can help here. The approach you are suggesting is exactly what i would recommend. Start a background Thread, have it process a list of images, and as they arrive, advise the Ui Processing so that it can update the screen.
11-13-2010 11:28 AM
Get familiar with "observer pattern":
In your case, observer (or listener, in BlackBerry speak) will be your UI element which wants to paint the image. Initially, you will have null as the reference to the image and your paint() method will skip painting it.
Later, once the image is downloaded in a separate thread, that thread will notify your UI via some listening method registered to be notified about that image. That method will populate your internal reference to the image and call invalidate().
invalidate() will cause your paint() method to be called. At this point, paint() will notice a non-null reference to the image and will draw it as intended.
There might be other approaches - the above is one of the many. It is both object-oriented and efficient enough.
11-15-2010 01:42 AM