@@ -0,0 +1,1453 @@
+/*%0A * Copyright (c) 2015-present, Facebook, Inc.%0A * All rights reserved.%0A *%0A * This source code is licensed under the BSD-style license found in the%0A * LICENSE file in the root directory of this source tree. An additional grant%0A * of patent rights can be found in the PATENTS file in the same directory.%0A */%0A%0Apackage com.facebook.datasource;%0A%0A/**%0A * Base implementation of %7B@link DataSubscriber%7D that ensures that the data source is closed when%0A * the subscriber has finished with it.%0A * %3Cp%3E%0A * Sample usage:%0A * %3Cpre%3E%0A * %3Ccode%3E%0A * imagePipeline.isInDiskCache(%0A * uri,%0A * new BaseBooleanSubscriber() %7B%0A *   public void onNewResultImpl(boolean isFound) %7B%0A *     // caller's code here%0A *   %7D%0A * %7D);%0A * %3C/code%3E%0A * %3C/pre%3E%0A */%0Apublic abstract class BaseBooleanSubscriber implements DataSubscriber%3CBoolean%3E%7B%0A  @Override%0A  public void onNewResult(DataSource%3CBoolean%3E dataSource) %7B%0A    try %7B%0A      onNewResultImpl(dataSource.getResult());%0A    %7D finally %7B%0A      dataSource.close();%0A    %7D%0A  %7D%0A%0A  @Override%0A  public void onFailure(DataSource%3CBoolean%3E dataSource) %7B%0A    try %7B%0A      onFailureImpl(dataSource);%0A    %7D finally %7B%0A      dataSource.close();%0A    %7D%0A  %7D%0A%0A  @Override%0A  public void onCancellation(DataSource%3CBoolean%3E dataSource) %7B%0A  %7D%0A%0A  @Override%0A  public void onProgressUpdate(DataSource%3CBoolean%3E dataSource) %7B%0A  %7D%0A%0A  protected abstract void onNewResultImpl(boolean isFoundInDisk);%0A%0A  protected abstract void onFailureImpl(DataSource%3CBoolean%3E dataSource);%0A%7D%0A

Simplify disk cache API