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
slashkyle
Posts: 818
Registered: ‎10-16-2012
My Device: Red Z10
My Carrier: Telus

how to delete stack of pages

I'm working on creating a stack of pages, but I've encountered an issue with deleting them properly

 

Currently i create pages as variants

onPopTranslationEnded i check if variant exists, if so I delete the page.

Before Now there was always only 1 page on the stack.

 

However I'm now working on a stack of pages (more than 1 page on the stack)  I can delete them by object name if closed 1 by 1, but If I swipe the back button and close them all at once, it only deletes the top most page.

 

What I'm not sure is how to diffentiate Pop All Pages between Pop 1 page, so when popping all i can iterate through and delete each open page 1 by 1.

Please use plain text.
Developer
Zmey
Posts: 1,512
Registered: ‎12-18-2012
My Device: PlayBook, Z10, DAC

Re: how to delete stack of pages

Last time I checked it was calling onPopTransitionEnded for every page which was popped, but not in reverse order as I would expect.

So, if there were page1, page2, page3 and all of them were popped, it will call onPopTransitionEnded for page1, then page2, then page3.

To verify this add console.log() to onPopTransitionEnded.

Andrey Fidrya, @zmeyc on twitter
Please use plain text.
Developer
slashkyle
Posts: 818
Registered: ‎10-16-2012
My Device: Red Z10
My Carrier: Telus

Re: how to delete stack of pages

You are correct it does delete the first pushed page towards the last. I was checking for the last page, so I'll try and change this so it checks if a prior page is being deleted beforehand.

 

Thanks for the help =)

Please use plain text.
Developer
ekke
Posts: 1,460
Registered: ‎04-08-2010
My Device: Z10 (red Limited Edition), Q10, Z30
My Carrier: Telekom.de, O2, Vodafone

Re: how to delete stack of pages

yep - this reverse order also confused me the first time I ran into it

 

another thing I'm doing to have some more control about pages from the stack

all my pages have a

property string pageName: "myName"

 

then from onPopTransitionEnded - or elsewhere when getting a page

I can test

if page.pageName == "myName" do something special

 

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
International Development Mobile Apps BlackBerry 10 Cascades
Cascades - Workshops / Trainings / Bootcamps

Open Source Enthusiast
blog: http://ekkes-corner.org videos: http://www.youtube.com/user/ekkescorner
bb10-development: http://appbus.org Twitter: @ekkescorner
Please use plain text.
Developer
slashkyle
Posts: 818
Registered: ‎10-16-2012
My Device: Red Z10
My Carrier: Telus

Re: how to delete stack of pages

[ Edited ]

even better than creating a variable, you can simply tap into objectName :smileywink:  This is how i'm doing it and it's working great now, didn't expect the reverse page order at all either.

 

if (page.objectName == somePage.objectName) {
    console.log("We've got a Match")
}

you can also use top.objectName to tell which page is the current viewable page

 

 

:Offtopic:

The unfortuante part is, now that I have this working I've discovered that it wont be as easy to put data into a new listview for each page (I belive it's going to require a new datamodel for each listview) and I'm not prepared for that so i'll probably stick with replacing my current listview content and work towards a multi-page solution in the future.

Please use plain text.
Developer
ekke
Posts: 1,460
Registered: ‎04-08-2010
My Device: Z10 (red Limited Edition), Q10, Z30
My Carrier: Telekom.de, O2, Vodafone

Re: how to delete stack of pages

I'm using objectname only if accessing an object from C++,

so in very less cases

 

I don't know if objectname causes some overhead internally to make it searchable from C++ and so I want to avoid any overhead.

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
International Development Mobile Apps BlackBerry 10 Cascades
Cascades - Workshops / Trainings / Bootcamps

Open Source Enthusiast
blog: http://ekkes-corner.org videos: http://www.youtube.com/user/ekkescorner
bb10-development: http://appbus.org Twitter: @ekkescorner
Please use plain text.
Developer
slashkyle
Posts: 818
Registered: ‎10-16-2012
My Device: Red Z10
My Carrier: Telus

Re: how to delete stack of pages

hmm, interesting theory... the docs don't really clarify weather or not it would only that if unset it remains NULL.

https://developer.blackberry.com/native/reference/cascades/bb__cascades__baseobject.html#property-ob...

 

You may be right, because AFAIK the easiest thing you can reference from qml in c++ is the object name so if set it would very possibly be there ready and waiting for c++ to call it...

 

I suppose I should re-think my approach =)

Please use plain text.
Developer
ekke
Posts: 1,460
Registered: ‎04-08-2010
My Device: Z10 (red Limited Edition), Q10, Z30
My Carrier: Telekom.de, O2, Vodafone

Re: how to delete stack of pages

I'm a somewhat old-school-developer

started with Assembler and Cobol ;-)

 

so I'm always thinking about performance and RAM - even with fast processors and GB of RAM today

 

and so I'm thinking that objectnames have to managed by cascades to use them to findChild() from C++,

so I'm reducing the size of this kind of index

 

also I'm using ID's only where needed

I'm always having ID's to better structure the code, but in complex applications I'm commenting the not-needed IDs

because I think QML has to create a tree of the known IDs and if there are less, then less processing times and less RAM

 

maybe I'm wrong with my expectations, but think it's not a bad idea

 

you won't find this in my sample apps because they're small and only samples

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
International Development Mobile Apps BlackBerry 10 Cascades
Cascades - Workshops / Trainings / Bootcamps

Open Source Enthusiast
blog: http://ekkes-corner.org videos: http://www.youtube.com/user/ekkescorner
bb10-development: http://appbus.org Twitter: @ekkescorner
Please use plain text.