blackberry / BB10-WebWorks-Framework

The BB10 WebWorks Framework is packaged within an application BAR file to run on a BB10 device (or simulator)
60 stars 34 forks source link

[Feature] Active Frame/Covers should be updateable in the Background #654

Closed djpip27 closed 11 years ago

djpip27 commented 11 years ago

Take BlackBerry World for example and minimize the application. Scroll to the right and then return to view the active frame. The cover changes to display another item in the store without actually opening the application again.

Unless I'm mistaken this functionality is missing from WebWorks.

Could I request, either this event listener should be raised each time the cover/active frame is visible or a new event like blackberry.event.addEventListener("drawcover", onDrawCover); be added so applications can 'rotate' the images shown on an Active Frame, like BlackBerry World does?

blackberry.event.addEventListener("entercover", onEnterCover);

kwallis commented 11 years ago

Hey there. Across the board, there is no event that is triggered periodically to an application when it is in the Cover state. It is up to the application to determine when it wants to update the cover. You can set the "run_when_backgrounded" permission in your config.xml, and then you can run javascript when in cover state. Perhaps you can try setTimeout or setInterval to periodically update your cover?

djpip27 commented 11 years ago

Thanks for suggesting this, I ended up using this and tried the setInterval method which worked nicely. There is one problem however which I'm unsure how to solve:

I push a cover using blackberry.ui.cover.setContent() with an image and then add a label using blackberry.ui.cover.labels.push() and call blackberry.ui.cover.updateCover();. When the application then uses the setInterval method it then pushes 'another' cover - which never appears because I assume it's 'behind' the original on display?

The only workaround I've found is to call blackberry.ui.cover.resetCover(); but this then introduces an ugly flicker where the covers momentarily disappear showing the last state the application was in before my new one shows. Is there any way to avoid this?

bryanhiggins commented 11 years ago

@djpip27 currently only a single label is supported which is why you don't see a difference using labels.push. Instead, set your new label like this:

blackberry.ui.cover.labels = [ "Label text" ];
djpip27 commented 11 years ago

Thanks, this has solved my problem. I now have active frames which update when the application is minimized and they look great and feel native, whilst using webworks. Thanks for your help - the application is: UK Traffic Information in-case anyone is interested.