Custom List with lazy loading

后端 未结 2 879
予麋鹿
予麋鹿 2021-01-16 15:48

I have successfully implemented like this for lazy loading in custom list \"enter

and

2条回答
  •  温柔的废话
    2021-01-16 15:59

    I am sure that I seen a good answer to this question on my travels, but can't find it now. I do recommend reviewing the BB forums here: http://supportforums.blackberry.com/t5/Java-Development/bd-p/java_dev as there are similar questions there.

    For now, just the highlights of what you need to do:

    1. Create an image downloading runnable to process the download - you have pretty much already done this in your previous code.
    2. Use the Observer pattern (search the internet for this), so that the BitmapField is the Observer for the completion of your image downloading. So when the image has been downloaded, the Runnable invokes the observer, which can then update the Bitmap.
    3. Use a Thread pool with a limited number of Threads (I would say 3), so that you do not start a whole load of image downloads at the same time. Search the internet for information on Thread Pool for help implementing this. You had not done this step in your previous example, and you can get away with running all the downloads, but I expect at some stage that this will fail.

    Put these together and you have your solution. Not trivial I know. Good luck.

提交回复
热议问题