Exemplo n.º 1
0
  /**
   * Blocks current thread until subject object is released. It should be used to block UI thread
   * before the <tt>View</tt> is hidden.
   */
  public synchronized void waitForObjectRelease() {
    if (providedObject != null) {
      try {
        logger.info("Waiting for object release... " + hashCode());
        this.wait(REMOVAL_TIMEOUT);
        if (providedObject != null) {
          throw new RuntimeException("Timeout waiting for preview surface removal");
        }
        logger.info("Object released! " + hashCode());
      } catch (InterruptedException e) {
        throw new RuntimeException(e);
      }
    }

    ensureViewDestroyed();
  }
Exemplo n.º 2
0
 /**
  * Should be called by consumer to obtain the object. It is causing hidden <tt>View</tt> to be
  * displayed and eventually {@link #onObjectCreated(Object)} method to be called which results in
  * object creation.
  *
  * @return provided object.
  */
 public synchronized T obtainObject() {
   ensureViewCreated();
   if (this.providedObject == null) {
     try {
       logger.info("Waiting for object..." + hashCode());
       this.wait(CREATE_TIMEOUT);
       if (providedObject == null) {
         throw new RuntimeException("Timeout waiting for surface");
       }
       logger.info("Returning object! " + hashCode());
     } catch (InterruptedException e) {
       throw new RuntimeException(e);
     }
   }
   return providedObject;
 }