Welcome to the Official BlackBerry® Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Developer
babygodzilla
Posts: 275
Registered: 03-10-2009

PlayerListener not working

I have a PlayerListener that's supposed to call invalidate on a Field while the Player is playing. I don't know why but the field is not being repainted. Here's the code:

 

 

public class PlayerHandler implements PlayerListener { public PlayerHandler() { } public void playerUpdate(Player player, String event, Object data) { if (event == (PlayerListener.STARTED)) { new Thread(new SelectFieldUpdate()).start(); } else if (event == (PlayerListener.STOPPED)) { field.invalidate(); } } private class SelectFieldUpdate implements Runnable { public void run() { while(player.getState() == Player.STARTED) { field.invalidate(); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } } } }

 

 of course, i add this listener to my player. any help will be appreciated.

 

Thanks!

 

Please use plain text.
Developer
BBDeveloper
Posts: 3,951
Registered: 07-15-2008

Re: PlayerListener not working

Did you use JDE debugger and the Breakpoints to check the invalidate is executing?

Use Search. "Accept Solution" If the problem is resolved.
Please use plain text.
Developer
babygodzilla
Posts: 275
Registered: 03-10-2009

Re: PlayerListener not working

[ Edited ]

yeah I tried the debugger. invalidate is definitely being called. i'm not sure if anything is actually happening though. it looks like paint may have ran once and that's it, but invalidate keeps being called, presumably because of the while loop, so that much is correct. I don't really have a good grasp of the UI Stack and such. is there something that could be interfering with the painting? needless to say the Player is running at the moment, although that should be running in a different thread as well. i tried encapsulating the insides of paint() in a Runnable, but instead nothing got drawn. no clue what's going on....

 

edit: instead of invalidate() i tried to call setText() on a different LabelField within that Runnable and I got a IllegalStateException :smileysad: what the heck does this mean?

Message Edited by babygodzilla on 04-02-2009 02:04 AM
Please use plain text.
Developer
babygodzilla
Posts: 275
Registered: 03-10-2009

Re: PlayerListener not working

anyone?
Please use plain text.
Developer
BBDeveloper
Posts: 3,951
Registered: 07-15-2008

Re: PlayerListener not working

[ Edited ]
Try this

UiApplication.getUiApplication().invokeLater(new Runnable()
{
public void run()
{
//set Text
}
});

 

Message Edited by BBDeveloper on 02-04-2009 07:49 PM

Use Search. "Accept Solution" If the problem is resolved.
Please use plain text.