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
Developer
Posts: 19,612
Registered: ‎07-14-2008
My Device: Not Specified

Re: Creating a list of verticalfieldmanager in blackberry is not scrolling well

I have looked a little further and there might be some mitigating circumstances that mean the issues I see will cause some impact, but perhaps not to scrolling/focusing.  Can you answer the questions I posed earlier and I will investigate further. 

 

To make sure we can replicate this processing, some more questions:

1) How many of these do you add?

2) Can we have sample cpp.png and pp.png images (I assume these are just test images - in your real app these would be different for each line?)

3) How long is the text in the RichTextField

Contributor
Posts: 17
Registered: ‎08-27-2013
My Device: Blackberry Torch 9860

Re: Creating a list of verticalfieldmanager in blackberry is not scrolling well

Hi,

 

1) I added ten of the fields(which i think its OK)

2. the images are the same for each of the fields. Its a temporary image, pending the time the app loads the remote image from a servlet

3. The text in the richtextfield is 255 characters long.

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

Re: Creating a list of verticalfieldmanager in blackberry is not scrolling well

Thanks for the information.

 

Have you looked at the changes I suggested yesterday?  Have they made any difference?

Contributor
Posts: 17
Registered: ‎08-27-2013
My Device: Blackberry Torch 9860

Re: Creating a list of verticalfieldmanager in blackberry is not scrolling well

I made the changes ... the app looks faster, but the scrolling is still not working well. when i scroll with the touch screen, it scrolls well, but with the track pad, its so slow, and doesn't focus on the next manager in time. That's the main issue. I am currently loading the pre-defined images to a static final bitmap object, which makes it a lot faster, cos its the same bitmap most of the list uses.

But the scroll ... not working well yet, still looking at implementing a thread pool for downloading remote images one at a time, without killing the app with so much threads.
Developer
Posts: 19,612
Registered: ‎07-14-2008
My Device: Not Specified

Re: Creating a list of verticalfieldmanager in blackberry is not scrolling well

OK, I think I have some suggestions that will help significantly with the scrolling issue.  Basically revolves around doing things once and not invoking invalidate so often.  The reason touch screen scrolling is OK is that it does not go through your onFocus and onUnfocus methods all the time.  So have a look at these if you want.

 

What I am going to try to do is provide you with some replacement code, you will have to compare and contrast to implement the suggested changes. 

 

But that won't be till much later as I'm busy atm.

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

Re: Creating a list of verticalfieldmanager in blackberry is not scrolling well

Just implemented a version of your code and running on a SImulator and performance seems OK.  Do you have problems on a Simulator, or only on device. 

Contributor
Posts: 17
Registered: ‎08-27-2013
My Device: Blackberry Torch 9860

Re: Creating a list of verticalfieldmanager in blackberry is not scrolling well

The problem is on both. the scrolling seems to drag and doesn't focus on the next field manager, especially if its outside the content area of the screen. It drags ...
Developer
Posts: 19,612
Registered: ‎07-14-2008
My Device: Not Specified

Re: Creating a list of verticalfieldmanager in blackberry is not scrolling well

[ Edited ]

I have been playing with this and spotted two additional things that I think are potentially causing problems:

 

1) your NullField

I actually see no value in the NullField.  I have removed it completely (and the need for a FocusChangeListener) from my test and the processing still works the same. 

 

As an aside, I would really like to know what you expect this to do:

 

  public void getFocusRect(XYRect rect) {
   this.getManager().getExtent(rect);
   rect.setLocation(0, 0);
  }

 

2) You don't call super.onFocus or super.onUnfocus in your ListUi class

I believe this is the cause of the problem of the scrolling outside the areas of the screen. 

 

Can you change both of these, and see the effect. 

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

Re: Creating a list of verticalfieldmanager in blackberry is not scrolling well

Further to my previous post, here is a replace ListUi class, with some optimizations.  Not the two approaches I have taken to setting the Border - the ListUi class uses onFocus/onUnfocus, the Bitmap using the states.  Of th4ese the states approach is the one I would recommend.  I only included the other as an example. 

 

You will notice how this code makes use of static Border and Background classes which are therefore not created and freed whenever focus is changed, so this is more efficient. 

 

I recommend you make similar changes to your ImageField.

 

And I removed the NullFIeld and FocusChangeListener.

 

I suspect that these changes, along with the other changes I have suggested previously will make your processing significantly faster. 

 

Let us know how you get on. 

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

Re: Creating a list of verticalfieldmanager in blackberry is not scrolling well

Sorry forgot to add the replacement class in the previous post:

 

public class ListUi extends HorizontalFieldManager {
	
	private static Border ListUi_FOCUS_BORDER = BorderFactory.createSimpleBorder(
			new XYEdges(1, 1, 1, 1), new XYEdges(0x00FFFFFF, 0x00FFFFFF,
					0x00999999, 0x00FFFFFF), Border.STYLE_SOLID);
	private static Border ListUi_UNFOCUS_BORDER = BorderFactory.createSimpleBorder(
			new XYEdges(1, 1, 1, 1), new XYEdges(0x00FFFFFF, 0x00FFFFFF,
					0x00999999, 0x00FFFFFF), Border.STYLE_DASHED);
	private static Background ListUi_FOCUS_BACKGROUND =
			BackgroundFactory.createSolidTransparentBackground(0x00003366, 20);
	private static Background ListUi_UNFOCUS_BACKGROUND = BackgroundFactory.createSolidBackground(0x00FFFFFF);
	private static Border Bitmap_FOCUS_BORDER = BorderFactory.createRoundedBorder(new XYEdges(5,
			5, 5, 5), 0x003b5998, Border.STYLE_SOLID);
	private static Border Bitmap_UNFOCUS_BORDER = BorderFactory.createRoundedBorder(new XYEdges(5,
			5, 5, 5), 0x00AAAAAA, Border.STYLE_SOLID);
	
	private Classified classified;
	boolean focus = false;
	private BitmapField bf = null;
	private NullField nullField;
	
	private VerticalFieldManager contents = new VerticalFieldManager(
		Field.USE_ALL_WIDTH);
	
	public ListUi(Classified classified, long style) {
	super(style);
	this.classified = classified;
	paintUi();
	}
	
	public void paintUi() {
	this.setPadding(new XYEdges(5, 5, 5, 5));
	
	bf = new BitmapField(Bitmap.getPredefinedBitmap(Bitmap.QUESTION), // Bitmap.getBitmapResource("cpp.png"),
			Field.FOCUSABLE) {
		public boolean navigationClick(int status, int time) {
			return true;
		}
	};
	bf.setBorder(VISUAL_STATE_NORMAL, Bitmap_UNFOCUS_BORDER);
	bf.setBorder(VISUAL_STATE_FOCUS, Bitmap_FOCUS_BORDER);
	// bf.setPadding(new XYEdges(5,5,5,5));
	this.add(bf);
	
	contents.setPadding(new XYEdges(0, 5, 0, 5));
	contents.add(new RichTextField(this.classified.getDescription()));
	
	HorizontalFieldManager picturePanel = new HorizontalFieldManager(
			Field.USE_ALL_WIDTH | Field.FIELD_HCENTER);
	
	picturePanel.add(new ImageField("", "pp.png", 64, 64));
	
	contents.add(picturePanel);
	
	this.add(contents);
	
	this.setBorder(ListUi_UNFOCUS_BORDER);
	
	}
	
	protected void onFocus(int direction) {
		this.setBackground(ListUi_FOCUS_BACKGROUND);
		this.setBorder(ListUi_FOCUS_BORDER);
		focus = true;
		super.onFocus(direction);
	}
	
	protected void onUnfocus() {
		this.setBackground(ListUi_UNFOCUS_BACKGROUND);
		this.setBorder(ListUi_UNFOCUS_BORDER);
		focus = false;
		super.onUnfocus();
	}
	
}