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: 92
Registered: ‎06-02-2009
My Device: Rogers Curve 8900
My Carrier: Rogers

Problems pushing a Screen from OptionsProvider Screen

My app's OptionsProvider MainScreen has a list of configurations. Users can add and edit configurations, and select an active configuration from this list. When the user chooses to add or edit a configuration, the MainScreen pushes a new Screen onto the stack, where the user can edit different variables.

 

This works fine on any of the device simulators I have tried. It also works fine on many devices. However, recently I have discovered that on the Storm (wasn't able to get version), and on the Curve 8900 (v.4.6.1.94, Platform 4.2.0.69), this new pushed Screen is extremely slow, taking about 15 seconds to show up, and having long delays between pushing a key and posting a keyDown event.

 

Is this indicative of a problem in the underlying Blackberry framework, or am I doing something wrong?

BlackBerry Development Advisor
Posts: 15,784
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Problems pushing a Screen from OptionsProvider Screen

Where are you seeing the delay?  Is this between calling pushScreen and the screen being displayed?  Or are there other methods that are taking up a large amount of time?
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 92
Registered: ‎06-02-2009
My Device: Rogers Curve 8900
My Carrier: Rogers

Re: Problems pushing a Screen from OptionsProvider Screen

Yes, there is a delay between pushScreen and the screen being displayed. There is also a delay between the physical act of pressing a button, and the arrival of a KeyCodeEvent. When profiling, while the UI seems very unresponsive, the JDE profiler reports the device to be around 98% idle.
Developer
Posts: 92
Registered: ‎06-02-2009
My Device: Rogers Curve 8900
My Carrier: Rogers

Re: Problems pushing a Screen from OptionsProvider Screen

[ Edited ]
Also tested this today with OS 4.6.1.231 on the 8900 with the same result.
Message Edited by DFallak on 06-04-2009 04:53 PM
BlackBerry Development Advisor
Posts: 15,784
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Problems pushing a Screen from OptionsProvider Screen

I haven't been able to reproduce this.  Can you provide some sample code that triggers this behaviour?
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 92
Registered: ‎06-02-2009
My Device: Rogers Curve 8900
My Carrier: Rogers

Re: Problems pushing a Screen from OptionsProvider Screen

After much sanitizing, here's my OptionsProvider class. While doing my sanitizing I noticed that it may be related to the paint() method. I had taken most of my code out, and the UI seemed to become more responsive. I incrementally added things back in, and tested again. On the iteration where I restored the paint() method (possibly along with something else) the UI became unresponsive again (only on my device). It is still responsive in the simulator.

 

 

import net.rim.blackberry.api.options.OptionsProvider; import net.rim.device.api.system.Application; import net.rim.device.api.system.Display; import net.rim.device.api.ui.ContextMenu; import net.rim.device.api.ui.Field; import net.rim.device.api.ui.FieldChangeListener; import net.rim.device.api.ui.Graphics; import net.rim.device.api.ui.Keypad; import net.rim.device.api.ui.MenuItem; import net.rim.device.api.ui.Screen; import net.rim.device.api.ui.UiApplication; import net.rim.device.api.ui.component.BasicEditField; import net.rim.device.api.ui.component.ObjectListField; import net.rim.device.api.ui.container.MainScreen; import net.rim.device.api.ui.container.VerticalFieldManager; /** * BlackBerry Options provider */ final class ClientOptionsProvider implements OptionsProvider { private ObjectListField m_configList; /** * Dialog used to edit application configuration information. */ private EditDialog m_editDialog; /** * MenuItem instances used by the context menu */ private MenuItem m_ConfigMenuItem; /** * @see net.rim.blackberry.api.options.OptionsProvider#getTitle() */ public String getTitle() { return "Screen Push Test"; } /** * @see net.rim.blackberry.api.options.OptionsProvider#populateMainScreen(net.rim.device.api.ui.container.MainScreen) */ public void populateMainScreen(MainScreen mainScrn) { m_configList = new ObjectListField() { protected void makeContextMenu(ContextMenu contextMenu) { if (m_ConfigMenuItem == null) { m_ConfigMenuItem = new MenuItem("Configure", 0, 0) { public void run() { Application.getApplication().invokeLater(new Runnable() { public void run() { editConfig(); } }); } }; } contextMenu.addItem(m_ConfigMenuItem); super.makeContextMenu(contextMenu); contextMenu.setDefaultItem(m_ConfigMenuItem); } }; String[] configs = new String[] { "Config 1", "Config 2", "Config 3" }; m_configList.set(configs); mainScrn.add(m_configList); } /** * @see net.rim.blackberry.api.options.OptionsProvider#save() */ public void save() { } /** * Displays a dialog to the user */ private void editConfig() { if (m_editDialog == null) { m_editDialog = new EditDialog(); } EditDialog editDialog = m_editDialog; editDialog.doModal(); } /** * Dialog used to allow users the ability to modify a configuration */ public final static class EditDialog extends Screen implements FieldChangeListener { protected int m_nBgColour = 0x00FFFFFF; /** * Constructor. */ public EditDialog() { super(new VerticalFieldManager(), DEFAULT_MENU); add(new BasicEditField("Name: ", null)); } /** * Show dialog in modal mode. */ public final void doModal() { final UiApplication app = UiApplication.getUiApplication(); if (Application.isEventDispatchThread()) { app.pushModalScreen(this); } else { app.invokeAndWait(new Runnable() { public void run() { app.pushModalScreen(EditDialog.this); } }); } } /** * @see net.rim.device.api.ui.Manager#sublayout(int, int) */ protected void sublayout(int w, int h) { layoutDelegate(250, 125); short nXPos = (short)((Display.getWidth() - 250) >> 1); short nYPos = (short)((Display.getHeight() - 125) >> 1); setPositionDelegate(2, 2); setPosition(nXPos, nYPos); setExtent(250, 125); } /** * @see net.rim.device.api.ui.Screen#keyDown(int, int) */ protected boolean keyDown(int nKey, int nTime) { if (Keypad.key(nKey) == Keypad.KEY_ESCAPE) { close(); return true; } return super.keyDown(nKey, nTime); } /** * @see net.rim.device.api.ui.FieldChangeListener#fieldChanged(net.rim.device.api.ui.Field, * int) */ public void fieldChanged(Field fld, int ctxt) { close(); } /** * @see net.rim.device.api.ui.Screen#paint(net.rim.device.api.ui.Graphics) */ protected void paint(Graphics gfx) { int nWidth = getWidth(); int nHeight = getHeight(); gfx.setColor(m_nBgColour); gfx.fillRect(0, 0, nWidth, nHeight); gfx.setColor(0x00000000); super.paint(gfx); gfx.drawRect(0, 0, nWidth, nHeight); } } }

 

 

Highlighted
Retired
Posts: 856
Registered: ‎07-15-2008
My Device: Passport
My Carrier: Bell

Re: Problems pushing a Screen from OptionsProvider Screen

This has been submitted to the Issue Tracker at: https://www.blackberry.com/jira/browse/JAVAAPI-106

 

Let's not do the work twice - put any new comments into the Issue Tracker.

Tim Windsor
Open Source Technical Lead