Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.84 KB | None | 0 0
  1. public class PleaseWaitPopup extends PopupScreen {
  2.     private PleaseWaitPopup(String msg) {
  3.         super(new VerticalFieldManager());
  4.         add(new LabelField(msg));
  5.     }
  6.    
  7.     /**
  8.      * This method shows the user a 'please wait' dialog while waiting for a monitor to be unlocked.
  9.      * Execution of the current thread is blocked until the monitor is unlocked.
  10.      * @param msg Message to be shown to the user
  11.      * @param monitor
  12.      */
  13.     public static void waitForUnlock(String msg, final Object monitor) {
  14.         final PleaseWaitPopup popup = new PleaseWaitPopup(msg);
  15.         final UiApplication app = UiApplication.getUiApplication();
  16.        
  17.         app.invokeLater(new Runnable() {
  18.             public void run() {
  19.                 app.pushModalScreen(popup);
  20.             }
  21.         });
  22.        
  23.         synchronized(monitor) {}
  24.  
  25.         app.invokeLater(new Runnable() {
  26.             public void run() {
  27.                 popup.close();
  28.             }
  29.         });
  30.     }
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement