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
ksykulev
Posts: 58
Registered: ‎07-09-2009
My Device: Blackberry Bold

Partial Loaded List

I'm looking to implement something like the search list in the BlackBerry App World.

Where as it recieves data it displays more results on the screen.

How would I go about doing that?

 

 

 

Thanks.

Please use plain text.
Developer
ksykulev
Posts: 58
Registered: ‎07-09-2009
My Device: Blackberry Bold

Re: Partial Loaded List

Maybe I should start with a simpler question..

Is it possible to stream data from an HttpConnection object?

So while the device is retrieving data can I while its getting the bytes at the same time be parsing it?

Please use plain text.
Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Partial Loaded List

Sure, but you have to invent all of this.

 

You will run your HTTP connection in a separate thread, probably servicing a queue of pending HTTP requests.  This "engine" will implement some type if listener mechanism, so that your GUI can be notified of completed requests.

 

As each request is fullfilled, the HTTP engine will fire a data event that is caught by the UI. The UI will recover the data and populate a UI component (Bitmapfield or whatever), adding it to the list and refreshing the display.

 

Of course, it's not quite that simple but certainly do-able.

 

I would start with implementing the HTTP engine as a thread.

 

 

Please use plain text.
Developer
ksykulev
Posts: 58
Registered: ‎07-09-2009
My Device: Blackberry Bold

Re: Partial Loaded List

I was hoping that blackberry had something built in to do that.. but I figured I would need to fabricate something of the sort.

So right now I have a restful webservice that returns XML data to my blackberry application. The method I want to use returns a single list of objects. However with my connection thread I have created, I cannot seem to find a way to only partially load the entire list of data.

For instance:


HttpConnection conn = null;
OutputStream out = null;

InputStream in = null;
StringBuffer inBuffer = new StringBuffer();
int inChar;

conn = (HttpConnection) ConnectionManager.getInstance().open(url);
conn.setRequestMethod(requestMode); //this will be HttpConnection.GET


This code will retrieve the entire set of data:

if (responseCode != HttpConnection.HTTP_OK) {
....
}else{
out = conn.openOutputStream();
out.write(data.getBytes());
out.flush();
getResponseContent( conn ); //Parses data function
}


Also something like this..

in = conn.openInputStream();
while ((inChar = in.read()) != -1) {
//append incoming characters to the buffer
inBuffer.append((char)inChar);
}
responseContent = inBuffer.toString();


Is there a way to actually walk through the data as it is being received by the HttpConnection?

Or is there some other method that I can use to achieve this.

 

Thanks.

Please use plain text.
Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Partial Loaded List

If this is just text going in a list, why bother?

 

I though you were going back out after grahics resources (referenced by the list)

 

Is the list 10,000 lines, or something?

 

 

 

Please use plain text.
Developer
ksykulev
Posts: 58
Registered: ‎07-09-2009
My Device: Blackberry Bold

Re: Partial Loaded List

Well the list contains both images AND text. It looks something the search results in the BB app store.

An image with text next to it. Then each item is clickable, and contains more descriptive text in the subpage.

The images are loaded on a seperate image queue thread. And that part works just fine..

 

Problem is when this list gets long, which happens alot, the XML returned is quite substaintial. And on a phone that is not 3g, this take a long long time to load all the data. That was my reasoning behind trying to load the as the data gets recieved. So that way the user doesn't need to wait there forever for the entire screen to load. 

 

My initial thought was the parse the data as it gets recieved and search for the closing tags of each element, and when that is found, create an element. 

Please use plain text.
Developer
ksykulev
Posts: 58
Registered: ‎07-09-2009
My Device: Blackberry Bold

Re: Partial Loaded List

PS 10,000 lines long.. could be possible depending on the situation.

On average the data return is about 30-50kb.

Please use plain text.