예제 #1
0
 /**
  * Removes a disposable object, which was previously added.
  *
  * @param disposable
  */
 @Override
 public void removeDisposable(Disposable disposable) {
   if (disposables != null) {
     disposables.remove(disposable);
     if (disposables.isEmpty()) {
       disposables = null;
     }
   }
 }
예제 #2
0
 /**
  * Adds a disposable object, which will be disposed when the specified view is disposed.
  *
  * @param disposable
  */
 @Override
 public void addDisposable(Disposable disposable) {
   if (disposables == null) {
     disposables = new LinkedList<Disposable>();
   }
   disposables.add(disposable);
 }
예제 #3
0
  /**
   * Gets rid of all the resources of the view. No other methods should be invoked on the view
   * afterwards.
   */
  @SuppressWarnings("unchecked")
  @Override
  public void dispose() {
    if (executor != null) {
      executor.shutdown();
      executor = null;
    }

    if (disposables != null) {
      for (Disposable d : (LinkedList<Disposable>) disposables.clone()) {
        d.dispose();
      }
      disposables = null;
    }

    removeAll();
  }