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

Need to update ui after navigation movement.

Hi all

I am developing an app in which i am showing images in a gallery and on navigation movement of this gallery i need to update ui.On updation I need to get an image from server and need to show it.but i want to do it after navigation movement stopped.Is there any listener for this.What should i do.

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: Need to update UI after navigation movement.

I'm not sure navigationMovement is a good candidate for this sort of process, since it is not invoked when scrolling via touch.

 

Instead I would look at a scroll listener.  If you want to wait until the person has stop scrolling, then have a Thread pick up the current scroll position frequently, and when it doesn't change for a bit, then you know the user has stopped and you can try to locate the image they are stopped on.

 

Alternatively you can use focus changes.  Listener for focus being placed on an image, then delay a bit, and if it is still the focus, start the processing.  This is probably the easiest to implement.

 

I think to comment further we need to understand your requirement in more detail. 

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

Re: Need to update UI after navigation movement.

Thanks peter for reply

here is my code  

 

CustomPictureField pictureField = new CustomPictureField(curWidth) {
protected boolean navigationMovement(int dx, int dy, int status,
int time) {

if (dx > 0
&& imagesCurrentPosition < StaticBitmapData.imagesChecked
.size() - 1) {
imagesCurrentPosition++;

}

else if (dx < 0 && imagesCurrentPosition > 0) {

imagesCurrentPosition--;
}
if (previousValue != imagesCurrentPosition) {


Thread th = new Thread() {
public void run() {


callMeWithScrollField(imagesCurrentPosition);
};
};
th.start();

previousValue = imagesCurrentPosition;
}
return super.navigationMovement(dx, dy, status, time);
}

};

 

 

 

Here is the method  and getImages method simply return Bitmap from URL;

callMeWithScrollField(){

 if (iconImage != null)
iconImage = null;
iconImage = getImages(URL, true,
widthForPreview, heightForPreview);
channelBitmapField.setBitmap(iconImage);

}

 

I need to call this method after navigation stopped