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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Trusted Contributor
Posts: 242
Registered: ‎03-16-2010
My Device: 9530
Accepted Solution

On close of popup only proceed

 

Hello,

 

         In my fieldChanged(), I call a popup message. The popup has a Close button that closes the popup. I don't want the app to do any work until the popup is not closed. I am not able to achieve it. The code is :

 

    public void fieldChanged(Field f, int context) {
        System.out.println("Into ------------ BUTTON CLICKED = " + f + " C0NTEXT = " + context + " btnClicked = " + btnClicked);
        if (f instanceof CheckboxField) {
            CheckboxField cb = (CheckboxField) f;
            // Get details associated with the selected checkbox
            UiApplication.getUiApplication().invokeAndWait(new Runnable() {
                    public void run() {
                        getScreen().getUiEngine().pushScreen(new MessagePopup(mm1)); 
                        return;
                    }
                });
                // Change some data and invalidate
                if (mm.read == false) {
                    mm.read = true;
                    cb.setCookie(mm);
                    unreadCount -= 1;
                    if (unreadCount < 0)
                        unreadCount = 0;
                    System.out.println("UNREADCOUNT =  " + unreadCount + " ******************* ");
                    inboxBtn.setText("Inbox " + unreadCount);
                    invalidate();
                }
                System.out.println("CheckBox Complete");
             }
        }

   // POPUP CLASS
    class MessagePopup extends PopupScreen  implements FieldChangeListener  {
        private BitmapButtonField okBtn;
        
        public MessagePopup(MailMessage mm) { 
            super(new VerticalFieldManager(VERTICAL_SCROLL | VERTICAL_SCROLLBAR));
            okBtn = new BitmapButtonField(Bitmap.getBitmapResource("res/cancel_btn.png"));
            okBtn.setChangeListener(this);
            add(new LabelField("Label "));
            add(okBtn);
        }
        
        public void fieldChanged(Field field, int context) { 
            if (field == okBtn)
                this.close(); 
        } 
        
        protected boolean keyChar(char key, int status, int time) { 
            if (Keypad.KEY_ESCAPE == key) { 
                this.close(); 
                return true; 
            } else 
                return super.keyChar(key, status, time); 
        } 
    }

 

 

The output is: popup is shown and I see the following SOP's

CheckboxField Selected********** READ = false****
UNREADCOUNT = 4 *******************

CheckBox Complete

 

According to me, when I click Ok button in the popup then the below 2 lines i.e.

UNREADCOUNT = 4 *******************

CheckBox Complete

 

should be executed.

 

Any idea how do I work out with this scenario. Any help is highly appreciative.

 

 

Thanks

 

 


--------------------------------------------------------------------------------
For any helpful answers give kudo's (star) to the helper.
Developer
Posts: 1,807
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.3.2.858, Z10 (STL100-3)-10.3.1.2576, Z30 (STA100-5)-10.3.1.2582, Passport (SQW100-1)-10.3.1.2576, PlayBook (16GB)-2.1.0.1917
My Carrier: Verizon

Re: On close of popup only proceed

If I understand correctly, you don't want "if(mm.read == false)" to get executed until the screen closes?

 

If that is correct then replace "pushScreen" with "pushModalScreen". Modal screens block until the screen closes. You don't need to an invokeAndWait operation since the modal screen will block execution anyway.

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Highlighted
Trusted Contributor
Posts: 242
Registered: ‎03-16-2010
My Device: 9530

Re: On close of popup only proceed

 

Thanks rcmania, you are right Modal screens blocks further execution till it is closed.

 

Once again Thanks a lot.


--------------------------------------------------------------------------------
For any helpful answers give kudo's (star) to the helper.