Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.95 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.         Thread t = new Thread() {
  18.             public void run() {
  19.                 app.invokeLater(new Runnable() {
  20.                     public void run() {
  21.                         app.pushModalScreen(popup);
  22.                     }
  23.                 });
  24.                
  25.                 synchronized(monitor) {}
  26.  
  27.                 app.invokeLater(new Runnable() {
  28.                     public void run() {
  29.                         popup.close();
  30.                     }
  31.                 });
  32.             }
  33.         };
  34.        
  35.         t.start();
  36.     }
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement