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


Java DataSource.isFinished方法代码示例

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


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

示例1: onNewResultImpl

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

  CloseableReference<CloseableImage> closeableImageRef = dataSource.getResult();
  Bitmap bitmap = null;
  if (closeableImageRef != null &&
      closeableImageRef.get() instanceof CloseableBitmap) {
    bitmap = ((CloseableBitmap) closeableImageRef.get()).getUnderlyingBitmap();
  }

  try {
    onNewResultImpl(bitmap);
  } finally {
    CloseableReference.closeSafely(closeableImageRef);
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:BaseBitmapDataSubscriber.java

示例2: onNewResultImpl

import com.facebook.datasource.DataSource; //导入方法依赖的package包/类
@Override
protected void onNewResultImpl(DataSource<CloseableReference<PooledByteBuffer>> dataSource) {
    if (!dataSource.isFinished() || dataSource.getResult() == null) {
        return;
    }

    // if we try to retrieve image file by cache key, it will return null
    // so we need to create a temp file, little bit hack :(
    PooledByteBufferInputStream inputStream = null;
    FileOutputStream outputStream = null;
    try {
        inputStream = new PooledByteBufferInputStream(dataSource.getResult().get());
        outputStream = new FileOutputStream(mTempFile);
        IOUtils.copy(inputStream, outputStream);

        mFinished = true;
        onSuccess(mTempFile);
    } catch (IOException e) {
        onFail(e);
    } finally {
        IOUtils.closeQuietly(inputStream);
        IOUtils.closeQuietly(outputStream);
    }
}
 
开发者ID:love-311,项目名称:BigImageViewer-master,代码行数:25,代码来源:ImageDownloadSubscriber.java

示例3: onNewResult

import com.facebook.datasource.DataSource; //导入方法依赖的package包/类
@Override
public void onNewResult(DataSource<CloseableReference<CloseableImage>> dataSource) {
    // isFinished() should be checked before calling onNewResultImpl(), otherwise
    // there would be a race condition: the final data source result might be ready before
    // we call isFinished() here, which would lead to the loss of the final result
    // (because of an early dataSource.close() call).
    final boolean shouldClose = dataSource.isFinished();
    try {
        onNewResultImpl(dataSource);
    } finally {
        if (shouldClose) {
           // dataSource.close();
        }
    }
}
 
开发者ID:BaoBaoJianqiang,项目名称:CustomListView,代码行数:16,代码来源:BaseBitmapDataSubscriber.java

示例4: onNewResult

import com.facebook.datasource.DataSource; //导入方法依赖的package包/类
@Override
public void onNewResult(DataSource<T> dataSource) {
    if (dataSource.hasResult()) {
        RetainingDataSource.this.onDataSourceNewResult(dataSource);
    } else if (dataSource.isFinished()) {
        RetainingDataSource.this.onDataSourceFailed(dataSource);
    }
}
 
开发者ID:PureDark,项目名称:H-Viewer,代码行数:9,代码来源:RetainingDataSourceSupplier.java

示例5: onNewResult

import com.facebook.datasource.DataSource; //导入方法依赖的package包/类
@Override
public void onNewResult(DataSource<CloseableReference<T>> dataSource) {
  if (dataSource.isFinished() && tryFinish()) {
    ListDataSource.this.onDataSourceFinished();
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:7,代码来源:ListDataSource.java

示例6: onNewResultImpl

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

        CloseableReference<CloseableImage> closeableImageRef = dataSource.getResult();
        Bitmap bitmap = null;
        if (closeableImageRef != null &&
                closeableImageRef.get() instanceof CloseableBitmap) {
            bitmap = ((CloseableBitmap) closeableImageRef.get()).getUnderlyingBitmap();
        }


        if(bitmap!=null ){
            if(bitmap.isRecycled()){
                onFailure(dataSource);
            }else {
                onNewResultImpl(bitmap,dataSource);
            }
            return;
        }

//        //如果bitmap为空
//        File cacheFile  = ImageLoader.getActualLoader().getFileFromDiskCache(finalUrl);
//        if(cacheFile ==null){
//            onFailure(dataSource);
//            return;
//        }
//        //还要判断文件是不是gif格式的
//        if (!"gif".equalsIgnoreCase(MyUtil.getRealType(cacheFile))){
//            onFailure(dataSource);
//            return;
//        }
//        Bitmap bitmapGif = GifUtils.getBitmapFromGifFile(cacheFile);//拿到gif第一帧的bitmap
//        if(width>0 && height >0) {
//            bitmapGif = MyUtil.compressBitmap(bitmapGif, true, width, height);//将bitmap压缩到指定宽高。
//        }

//        if (bitmapGif != null) {
//            onNewResultImpl(bitmap,dataSource);
//        } else {
//            onFailure(dataSource);
//        }




       /* try {
            onNewResultImpl(bitmap);
        } finally {
            //CloseableReference.closeSafely(closeableImageRef);
        }*/
    }
 
开发者ID:BaoBaoJianqiang,项目名称:CustomListView,代码行数:55,代码来源:BaseBitmapDataSubscriber.java

示例7: 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


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