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

Native Development

Reply
Developer
Posts: 6,141
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30

Re: Reuse page

How many recursion levels do you expect?

 

Whenever you decide that recursion is the way to go you always need to be very careful about how you manage memory and what recursive depth is the maximum.

 

You can either do it the way Zmey suggests for which at some point you will run out of memory, dependant on the amount of data each page has, or the way I suggested which is efficient but which needs it's own management of data.

 

I thought I explained it simply enough but perhaps it needs some code for you to visualise it, look back later and I'll post some code.

 

 


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 824
Registered: ‎10-16-2012
My Device: Red Z10

Re: Reuse page

[ Edited ]

BBSJdev wrote:

How many recursion levels do you expect?

 

I thought I explained it simply enough but perhaps it needs some code for you to visualise it, look back later and I'll post some code.

 

 


That would be great... and as for recursion it could be unlimited so a working example of your method would probably be the best bet memory wise as essentially i'm trying to make a file manager :smileywink:  The file picker has limitations that cannot be worked around and this likely wont ever be changed it so I need my own.

 

I've managed to get the datamodel sorted its just displaying the contents of a new folder in a new page that i'm stuck at.

Developer
Posts: 6,141
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30

Re: Reuse page

Zmey wrote...

 

   Probably the data that is displayed will occupy more memory than the page itself.

 

That's exactly my point each time you add a page you are adding more data and even though the page isn't rendered it is still present in the scene graph. The actual adding of the page or the performance I had no concerns about.

 

I have no idea what slashkyle intends to place on this page but if it is anything but trivial then memory usage is a big concern for a non-trivial amount of recursion. What level non-trivial is is obviously dependant on what data is in the page.

 


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 1,523
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: Reuse page

[ Edited ]

You can either do it the way Zmey suggests for which at some point you will run out of memory, dependant on the amount of data each page has, or the way I suggested which is efficient but which needs it's own management of data.

 

Right, but this will only happen after tens of thousands pages are pushed. I bet no one will click this deep. :smileyhappy:

 

To preserve memory, DataModel can be optimized to not store the entire filelist in memory, but to iterate the filesystem and only return the data which is currently shown on screen by ListView.

 

Or cache all the filenames for current folder to access them faster by index, but drop the cache when navigating to the next page. Recreate the cache when file info at any index is requested again (this can happen when the user has returned back to the page).

 

 


Andrey Fidrya, @zmeyc on twitter
Developer
Posts: 6,141
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30

Re: Reuse page

@Slashkyle the difference with the File Manager is that it knows that there will eventually be an end. Unix usually tops out at 32000 on some larger systems 64000 but on a mobile device this is meaningless as the user wouldn't be expected to create that many subdirectories of have the time to go through them all.

 

Actually I've just looked at the code and I can say that it uses some variation of what I've proposed.

 

To prove this start up the File Manager, go down several levels and peek back you'll see that the peek back page is the top level not the intermediate pages.

 

 

 


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 6,141
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30

Re: Reuse page

[ Edited ]

Zmey wrote:

 

Right, but this will only happen after tens of thousands pages are pushed. I bet no one will click this deep. :smileyhappy:

 

 


I bet that too. :smileyhappy: But that's not what the OP said and slashkyle is still insisting on infinite pages.

And let's face it if their is a fairly easy more efficient way of doing something even if it is a little more effort that's the one you should choose.

 

When they teach recursion in University they always teach the gotchas as well, for someone fairly new to programming techniques I would always advise against recursion if possible. Obviously in some cases such as tree sorting or searching recursion is the first choice otherwise try and avoid it. 

 

Anyway File Manager does it the way I suggested, it's not really that hard to place a second page on the navPane stack either before the page on a pop or for a push place the new page on the stack and remove the previous one after saving the data and the page and transitioned on.

 

I deliberately didn't go in to the optimisations you can do on the data yet until slashkyle understood the page pop/push methodology I proposed. :smileyhappy:

 


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 1,523
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: Reuse page

To prove this start up the File Manager, go down several levels and peek back you'll see that the peek back page is the top level not the intermediate pages.

 

That's strange, I'm seeing intermediate pages when peeking in FileManager:

 

IMG_00000241.png


Andrey Fidrya, @zmeyc on twitter
Developer
Posts: 6,141
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30

Re: Reuse page

That's because the page is placed back on the peek signal, try doing a back peek.

 

You'd also have to go more than two pages deep try misc/android/pictures for example.


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 1,523
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: Reuse page

[ Edited ]

I did up to 5 levels deep and it still works like NavigationPane.
I.e. when I drag the page, I see the page below it.
When I drag the back button, I see the page at zero index.

 

IMG_00000242.png


Andrey Fidrya, @zmeyc on twitter
Developer
Posts: 6,141
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30

Re: Reuse page

[ Edited ]

Yep you're right poor example.

 

I was looking to prove something visually from what I thought I saw in the code but forgot about the zero index peek. Doh!

 


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.