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

Java Development

Reply
Regular Contributor
heretocode
Posts: 70
Registered: ‎12-19-2011
My Device: Bold 9780

Thread problem

Hi all

 

I have a scrollable horizontal field manager. this manager contains  15 bitmap field.I have one manager on which i am showing the image and one other manager on which i am showing list data related to this particular bitmap field.

I need to do update image on manager and data on focus moves from one bitmap to other.it is taking some time.because i am fecthing data from database.On scroll app looks like it hangs.How i can manage a smooth scroll here.Is the use of thread is good one.

Please use plain text.
Developer
simon_hain
Posts: 16,214
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Thread problem

all blocking operations, for example database access, should be done on a separate thread.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Regular Contributor
heretocode
Posts: 70
Registered: ‎12-19-2011
My Device: Bold 9780

Re: Thread problem

Thanks simon for reply

  Now i use thread here.And it works fine.But if user scroll field manager again and again many threads start and the last updation comes with a gap of time.Is there any way to manage this things.Like can i start only last thread and all other will stop.

Please use plain text.
Developer
simon_hain
Posts: 16,214
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Thread problem

for multiple threads i usually use a runnablequeue. stopping an already running thread is tricky, use the search for more information about that.

you could run your query with a delay and cancel it before it executes, for example.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
peter_strange
Posts: 19,609
Registered: ‎07-14-2008
My Device: Not Specified

Re: Thread problem

In this particular case, where you really require all images to be present to allow reasonable scrolling speed, I would not try to fetch the image as part of the scroll action. 

 

I think you have two options:

1) Wait till  the user has all the images before displaying.  And cache the images so that they are not downloaded twice. 

2) Alternatively, display a placeholder image and replace this as the actual images are downloaded.  This is how I would do it. 

 

Or have I misunderstood?

Please use plain text.
Regular Contributor
heretocode
Posts: 70
Registered: ‎12-19-2011
My Device: Bold 9780

Re: Thread problem

@peter 

You got it right.I need to do the same.

will you  suggest me any link for  cache images. 

Please use plain text.
Developer
peter_strange
Posts: 19,609
Registered: ‎07-14-2008
My Device: Not Specified

Re: Thread problem

Please use plain text.