当前位置: 首页>>代码示例>>Java>>正文


Java DataSource.close方法代码示例

本文整理汇总了Java中com.facebook.datasource.DataSource.close方法的典型用法代码示例。如果您正苦于以下问题:Java DataSource.close方法的具体用法?Java DataSource.close怎么用?Java DataSource.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.facebook.datasource.DataSource的用法示例。


在下文中一共展示了DataSource.close方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onFailureInternal

import com.facebook.datasource.DataSource; //导入方法依赖的package包/类
private void onFailureInternal(String id,
        DataSource<CloseableReference<CloseableImage>> dataSource,
        Throwable throwable, boolean isFinished) {
    if (FLog.isLoggable(Log.WARN)) {
        FLog.w(DraweeSpan.class, id + " load failure", throwable);
    }
    // ignored this result
    if (!getId().equals(id)
            || dataSource != mDataSource
            || !mIsRequestSubmitted) {
        dataSource.close();
        return;
    }
    if (isFinished) {
        mDataSource = null;
        // Set the previously available image if available.
        setDrawableInner(mDrawable);
    }
}
 
开发者ID:Bilibili,项目名称:drawee-text-view,代码行数:20,代码来源:DraweeSpan.java

示例2: close

import com.facebook.datasource.DataSource; //导入方法依赖的package包/类
@Override
public boolean close() {
  if (!super.close()) {
    return false;
  }
  for (DataSource<?> dataSource : mDataSources) {
    dataSource.close();
  }
  return true;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:ListDataSource.java

示例3: onFailureInternal

import com.facebook.datasource.DataSource; //导入方法依赖的package包/类
private void onFailureInternal(
    String id,
    DataSource<T> dataSource,
    Throwable throwable,
    boolean isFinished) {
  // ignore late callbacks (data source that failed is not the one we expected)
  if (!isExpectedDataSource(id, dataSource)) {
    logMessageAndFailure("ignore_old_datasource @ onFailure", throwable);
    dataSource.close();
    return;
  }
  mEventTracker.recordEvent(
      isFinished ? Event.ON_DATASOURCE_FAILURE : Event.ON_DATASOURCE_FAILURE_INT);
  // fail only if the data source is finished
  if (isFinished) {
    logMessageAndFailure("final_failed @ onFailure", throwable);
    mDataSource = null;
    mHasFetchFailed = true;
    // Set the previously available image if available.
    if (mRetainImageOnFailure && mDrawable != null) {
      mSettableDraweeHierarchy.setImage(mDrawable, 1f, true);
    } else if (shouldRetryOnTap()) {
      mSettableDraweeHierarchy.setRetry(throwable);
    } else {
      mSettableDraweeHierarchy.setFailure(throwable);
    }
    getControllerListener().onFailure(mId, throwable);
    // IMPORTANT: do not execute any instance-specific code after this point
  } else {
    logMessageAndFailure("intermediate_failed @ onFailure", throwable);
    getControllerListener().onIntermediateImageFailed(mId, throwable);
    // IMPORTANT: do not execute any instance-specific code after this point
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:35,代码来源:AbstractDraweeController.java

示例4: onProgressUpdateInternal

import com.facebook.datasource.DataSource; //导入方法依赖的package包/类
private void onProgressUpdateInternal(
    String id,
    DataSource<T> dataSource,
    float progress,
    boolean isFinished) {
  // ignore late callbacks (data source that failed is not the one we expected)
  if (!isExpectedDataSource(id, dataSource)) {
    logMessageAndFailure("ignore_old_datasource @ onProgress", null);
    dataSource.close();
    return;
  }
  if (!isFinished) {
    mSettableDraweeHierarchy.setProgress(progress, false);
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:AbstractDraweeController.java

示例5: onFailure

import com.facebook.datasource.DataSource; //导入方法依赖的package包/类
@Override
public void onFailure(DataSource<CloseableReference<CloseableImage>> dataSource) {
  if (mDataSource == dataSource) {
    Assertions.assumeNotNull(mBitmapUpdateListener).onImageLoadEvent(ImageLoadEvent.ON_ERROR);
    Assertions.assumeNotNull(mBitmapUpdateListener).onImageLoadEvent(ImageLoadEvent.ON_LOAD_END);
    mDataSource = null;
  }

  dataSource.close();
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:11,代码来源:PipelineRequestHelper.java

示例6: onCancellation

import com.facebook.datasource.DataSource; //导入方法依赖的package包/类
@Override
public void onCancellation(DataSource<CloseableReference<CloseableImage>> dataSource) {
  if (mDataSource == dataSource) {
    mDataSource = null;
  }

  dataSource.close();
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:9,代码来源:PipelineRequestHelper.java

示例7: abortRequest

import com.facebook.datasource.DataSource; //导入方法依赖的package包/类
@ReactMethod
public void abortRequest(final int requestId) {
  DataSource<Void> request = removeRequest(requestId);
  if (request != null) {
    request.close();
  }
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:8,代码来源:ImageLoaderModule.java

示例8: onHostDestroy

import com.facebook.datasource.DataSource; //导入方法依赖的package包/类
@Override
public void onHostDestroy() {
  // cancel all requests
  synchronized (mEnqueuedRequestMonitor) {
    for (int i = 0, size = mEnqueuedRequests.size(); i < size; i++) {
      @Nullable DataSource<Void> enqueuedRequest = mEnqueuedRequests.valueAt(i);
      if (enqueuedRequest != null) {
        enqueuedRequest.close();
      }
    }
    mEnqueuedRequests.clear();
  }
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:14,代码来源:ImageLoaderModule.java

示例9: onNewResultInternal

import com.facebook.datasource.DataSource; //导入方法依赖的package包/类
private void onNewResultInternal(String id,
        DataSource<CloseableReference<CloseableImage>> dataSource,
        CloseableReference<CloseableImage> result,
        boolean isFinished) {
    // ignored this result
    if (!getId().equals(id)
            || dataSource != mDataSource
            || !mIsRequestSubmitted) {
        CloseableReference.closeSafely(result);
        dataSource.close();
        return;
    }
    Drawable drawable;
    try {
        drawable = createDrawable(result);
    } catch (Exception exception) {
        CloseableReference.closeSafely(result);
        onFailureInternal(id, dataSource, exception, isFinished);
        return;
    }
    CloseableReference previousImage = mFetchedImage;
    Drawable previousDrawable = mDrawable;
    mFetchedImage = result;
    try {
        // set the new image
        if (isFinished) {
            mDataSource = null;
            setImage(drawable);
        }
    } finally {
        if (previousDrawable != null && previousDrawable != drawable) {
            releaseDrawable(previousDrawable);
        }
        if (previousImage != null && previousImage != result) {
            CloseableReference.closeSafely(previousImage);
        }
    }
}
 
开发者ID:Bilibili,项目名称:drawee-text-view,代码行数:39,代码来源:DraweeSpan.java

示例10: onNewResultInternal

import com.facebook.datasource.DataSource; //导入方法依赖的package包/类
private void onNewResultInternal(
    String id,
    DataSource<T> dataSource,
    @Nullable T image,
    float progress,
    boolean isFinished,
    boolean wasImmediate) {
  // ignore late callbacks (data source that returned the new result is not the one we expected)
  if (!isExpectedDataSource(id, dataSource)) {
    logMessageAndImage("ignore_old_datasource @ onNewResult", image);
    releaseImage(image);
    dataSource.close();
    return;
  }
  mEventTracker.recordEvent(
      isFinished ? Event.ON_DATASOURCE_RESULT : Event.ON_DATASOURCE_RESULT_INT);
  // create drawable
  Drawable drawable;
  try {
    drawable = createDrawable(image);
  } catch (Exception exception) {
    logMessageAndImage("drawable_failed @ onNewResult", image);
    releaseImage(image);
    onFailureInternal(id, dataSource, exception, isFinished);
    return;
  }
  T previousImage = mFetchedImage;
  Drawable previousDrawable = mDrawable;
  mFetchedImage = image;
  mDrawable = drawable;
  try {
    // set the new image
    if (isFinished) {
      logMessageAndImage("set_final_result @ onNewResult", image);
      mDataSource = null;
      mSettableDraweeHierarchy.setImage(drawable, 1f, wasImmediate);
      getControllerListener().onFinalImageSet(id, getImageInfo(image), getAnimatable());
      // IMPORTANT: do not execute any instance-specific code after this point
    } else {
      logMessageAndImage("set_intermediate_result @ onNewResult", image);
      mSettableDraweeHierarchy.setImage(drawable, progress, wasImmediate);
      getControllerListener().onIntermediateImageSet(id, getImageInfo(image));
      // IMPORTANT: do not execute any instance-specific code after this point
    }
  } finally {
    if (previousDrawable != null && previousDrawable != drawable) {
      releaseDrawable(previousDrawable);
    }
    if (previousImage != null && previousImage != image) {
      logMessageAndImage("release_previous_result @ onNewResult", previousImage);
      releaseImage(previousImage);
    }
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:55,代码来源:AbstractDraweeController.java

示例11: onNewResult

import com.facebook.datasource.DataSource; //导入方法依赖的package包/类
@Override
public void onNewResult(DataSource<CloseableReference<CloseableImage>> dataSource) {
  if (!dataSource.isFinished()) {
    // only interested in final image, no need to close the dataSource
    return;
  }

  try {
    if (mDataSource != dataSource) {
      // Shouldn't ever happen, but let's be safe (dataSource got closed by callback still fired?)
      return;
    }

    mDataSource = null;

    CloseableReference<CloseableImage> imageReference = dataSource.getResult();
    if (imageReference == null) {
      // Shouldn't ever happen, but let's be safe (dataSource got closed by callback still fired?)
      return;
    }

    CloseableImage image = imageReference.get();
    if (!(image instanceof CloseableBitmap)) {
      // only bitmaps are supported
      imageReference.close();
      return;
    }

    mImageRef = imageReference;

    Bitmap bitmap = getBitmap();
    if (bitmap == null) {
      // Shouldn't ever happen, but let's be safe.
      return;
    }

    BitmapUpdateListener listener = Assertions.assumeNotNull(mBitmapUpdateListener);
    listener.onBitmapReady(bitmap);
    listener.onImageLoadEvent(ImageLoadEvent.ON_LOAD);
    listener.onImageLoadEvent(ImageLoadEvent.ON_LOAD_END);
  } finally {
    dataSource.close();
  }
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:45,代码来源:PipelineRequestHelper.java

示例12: closeSafely

import com.facebook.datasource.DataSource; //导入方法依赖的package包/类
private void closeSafely(DataSource<T> dataSource) {
    if (dataSource != null) {
        dataSource.close();
    }
}
 
开发者ID:PureDark,项目名称:H-Viewer,代码行数:6,代码来源:RetainingDataSourceSupplier.java

示例13: closeSource

import com.facebook.datasource.DataSource; //导入方法依赖的package包/类
private void closeSource(int requestId) {
    DataSource source = mRequestSourceMap.remove(requestId);
    if (source != null) {
        source.close();
    }
}
 
开发者ID:Piasy,项目名称:BigImageViewer,代码行数:7,代码来源:FrescoImageLoader.java

示例14: getBitmapFromCache

import com.facebook.datasource.DataSource; //导入方法依赖的package包/类
/**
 * 从Fresco的缓存中获取Bitmap
 * @return
 */
private Bitmap getBitmapFromCache(String imgUrl){

    Bitmap bm = null;

    ImagePipeline imagePipeline = Fresco.getImagePipeline();
    ImageRequest request = ImageRequestBuilder
            .newBuilderWithSource(Uri.parse(imgUrl))
            .build();


    DataSource<CloseableReference<CloseableImage>> dataSource =
            imagePipeline.fetchImageFromBitmapCache(request, this);
    try{
        CloseableReference<CloseableImage> imageReference = dataSource.getResult();
        if(imageReference != null){
            try{
                // do something
                CloseableImage image = imageReference.get();
                if(image instanceof CloseableBitmap){

                    Bitmap bitmap = ((CloseableBitmap)image).getUnderlyingBitmap();

                    Log.i(TAG, "getBitmapFromCache>>> get cached bitmap success");
                    bm = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight());

                    return bm;
                }
            }finally {
                CloseableReference.closeSafely(imageReference);
            }
        }else {
            // cache miss
            return null;
        }
    }finally {
        dataSource.close();
    }

    return null;
}
 
开发者ID:zjupure,项目名称:SneezeReader,代码行数:45,代码来源:ShareActivity.java


注:本文中的com.facebook.datasource.DataSource.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。