GVKun编程网logo

com.facebook.react.uimanager.CatalystStylesDiffMap的实例源码(react useeffect 源码)

5

对于想了解com.facebook.react.uimanager.CatalystStylesDiffMap的实例源码的读者,本文将提供新的信息,我们将详细介绍reactuseeffect源码,并且

对于想了解com.facebook.react.uimanager.CatalystStylesDiffMap的实例源码的读者,本文将提供新的信息,我们将详细介绍react useeffect 源码,并且为您提供关于com.facebook.imagepipeline.cache.ImageCacheStatsTracker的实例源码、com.facebook.imagepipeline.image.CloseableAnimatedImage的实例源码、com.facebook.imagepipeline.image.CloseableBitmap的实例源码、com.facebook.imagepipeline.image.CloseableStaticBitmap的实例源码的有价值信息。

本文目录一览:

com.facebook.react.uimanager.CatalystStylesDiffMap的实例源码(react useeffect 源码)

com.facebook.react.uimanager.CatalystStylesDiffMap的实例源码(react useeffect 源码)

项目:react-native-circle-view    文件:ReactCircleViewManager.java   
@Override
public void updateView(final CircleProgressView view,final CatalystStylesDiffMap props) {

    BaseViewPropertyApplicator.applyCommonViewProperties(view,props);

    if (props.hasKey(PROP_SHOW_TEXT_WHILE_SPINNING)) {
        view.setshowtextWhileSpinning(props.getBoolean(PROP_SHOW_TEXT_WHILE_SPINNING,false));
    }
    if (props.hasKey(PROP_AUTO_TEXT_SIZE)) {
        view.setAutoTextSize(props.getBoolean(PROP_AUTO_TEXT_SIZE,false));
    }
    if (props.hasKey(PROP_AUTO_TEXT_COLOR)) {
        view.setAutoTextColor(props.getBoolean(PROP_AUTO_TEXT_COLOR,false));
    }
    if (props.hasKey(PROP_SHOW_UNIT)) {
        view.setShowUnit(props.getBoolean(PROP_SHOW_UNIT,true));
    }
    if (props.hasKey(PROP_TEXT_SIZE)) {
        view.setTextSize(props.getInt(PROP_TEXT_SIZE,10));
    }
    if (props.hasKey(PROP_UNIT_SIZE)) {
        view.setUnitSize(props.getInt(PROP_UNIT_SIZE,10));
    }
    if (props.hasKey(PROP_CONTOUR_SIZE)) {
        view.setContourSize(props.getFloat(PROP_CONTOUR_SIZE,1));
    }
    if (props.hasKey(PROP_BAR_WIDTH)) {
        view.setBarWidth(props.getInt(PROP_BAR_WIDTH,1));
    }
    if (props.hasKey(PROP_RIM_WIDTH)) {
        view.setRimWidth(props.getInt(PROP_RIM_WIDTH,1));
    }
    if (props.hasKey(PROP_MAX_VALUE)) {
        view.setMaxValue(props.getInt(PROP_MAX_VALUE,100));
    }
    if (props.hasKey(PROP_VALUE)) {
        view.setValue(props.getInt(PROP_VALUE,0));
    }
    if (props.hasKey(PROP_VALUE_ANIMATED)) {
        view.setValueAnimated(props.getInt(PROP_VALUE_ANIMATED,42));
    }
    if (props.hasKey(PROP_СONTOUR_COLOR)) {
        view.setContourColor(Color.parseColor(props.getString(PROP_СONTOUR_COLOR)));
    }
    if (props.hasKey(PROP_RIM_COLOR)) {
        view.setRimColor(Color.parseColor(props.getString(PROP_RIM_COLOR)));
    }
    if (props.hasKey(PROP_BAR_COLOR)) {
        int size = props.getArray(PROP_BAR_COLOR).size();
        int[] colors = new int[size];
        for (int i = 0; i < size; i++) {
            colors[i] = Color.parseColor(props.getArray(PROP_BAR_COLOR).getString(i));
        }
        view.setBarColor(colors);
    }

    Log.i("CircleProgressView","updateview finish");
    super.updateView(view,props);
}

com.facebook.imagepipeline.cache.ImageCacheStatsTracker的实例源码

com.facebook.imagepipeline.cache.ImageCacheStatsTracker的实例源码

项目:GitHub    文件:ImagePipelineConfig.java   
public ImageCacheStatsTracker getimageCacheStatsTracker() {
  return mImageCacheStatsTracker;
}
项目:GitHub    文件:ImagePipelineConfig.java   
public Builder setimageCacheStatsTracker(ImageCacheStatsTracker imageCacheStatsTracker) {
  mImageCacheStatsTracker = imageCacheStatsTracker;
  return this;
}
项目:fresco    文件:ImagePipelineConfig.java   
public ImageCacheStatsTracker getimageCacheStatsTracker() {
  return mImageCacheStatsTracker;
}
项目:fresco    文件:ImagePipelineConfig.java   
public Builder setimageCacheStatsTracker(ImageCacheStatsTracker imageCacheStatsTracker) {
  mImageCacheStatsTracker = imageCacheStatsTracker;
  return this;
}

com.facebook.imagepipeline.image.CloseableAnimatedImage的实例源码

com.facebook.imagepipeline.image.CloseableAnimatedImage的实例源码

项目:GitHub    文件:BoxingFrescoLoader.java   
private Drawable createDrawableFromFetchedResult(Context context,CloseableImage image) {
    if (image instanceof CloseableStaticBitmap) {
        CloseableStaticBitmap closeableStaticBitmap = (CloseableStaticBitmap) image;
        BitmapDrawable bitmapDrawable = createBitmapDrawable(context,closeableStaticBitmap.getUnderlyingBitmap());
        return (closeableStaticBitmap.getRotationAngle() != 0 && closeableStaticBitmap.getRotationAngle() != -1 ? new OrientedDrawable(bitmapDrawable,closeableStaticBitmap.getRotationAngle()) : bitmapDrawable);
    } else if (image instanceof CloseableAnimatedImage) {
        AnimatedDrawableFactory animatedDrawableFactory = Fresco.getimagePipelineFactory().getAnimatedFactory().getAnimatedDrawableFactory(context);
        if (animatedDrawableFactory != null) {
            AnimatedDrawable animatedDrawable = (AnimatedDrawable) animatedDrawableFactory.create(image);
            if (animatedDrawable != null) {
                return animatedDrawable;
            }
        }
    }
    throw new UnsupportedOperationException("Unrecognized image class: " + image);
}
项目:GitHub    文件:AnimatedSingleUsePostprocessorProducerTest.java   
@Test
public void testNonStaticBitmapIsPassedOn() {
  SingleUsePostprocessorConsumer postprocessorConsumer = produceResults();
  CloseableAnimatedImage sourceCloseableAnimatedImage = mock(CloseableAnimatedImage.class);
  CloseableReference<CloseableImage> sourceCloseableImageRef =
      CloseableReference.<CloseableImage>of(sourceCloseableAnimatedImage);
  postprocessorConsumer.onNewResult(sourceCloseableImageRef,Consumer.IS_LAST);
  sourceCloseableImageRef.close();
  mTestExecutorService.runUntilIdle();

  mInorder.verify(mConsumer).onNewResult(any(CloseableReference.class),eq(Consumer.IS_LAST));
  mInorder.verifyNoMoreInteractions();

  assertEquals(1,mResults.size());
  CloseableReference<CloseableImage> res0 = mResults.get(0);
  assertTrue(CloseableReference.isValid(res0));
  assertSame(sourceCloseableAnimatedImage,res0.get());
  res0.close();

  verify(sourceCloseableAnimatedImage).close();
}
项目:GitHub    文件:AnimatedRepeatedPostprocessorProducerTest.java   
@Test
public void testNonStaticBitmapIsPassedOn() {
  RepeatedPostprocessorConsumer postprocessorConsumer = produceResults();
  RepeatedPostprocessorRunner repeatedPostprocessorRunner = getRunner();

  CloseableAnimatedImage sourceCloseableAnimatedImage = mock(CloseableAnimatedImage.class);
  CloseableReference<CloseableImage> sourceCloseableImageRef =
      CloseableReference.<CloseableImage>of(sourceCloseableAnimatedImage);
  postprocessorConsumer.onNewResult(sourceCloseableImageRef,eq(Consumer.NO_FLAGS));
  mInorder.verifyNoMoreInteractions();

  assertEquals(1,res0.get());
  res0.close();

  performCancelAndVerifyOnCancellation();
  verify(sourceCloseableAnimatedImage).close();
}
项目:Boxing    文件:BoxingFrescoLoader.java   
private Drawable createDrawableFromFetchedResult(Context context,closeableStaticBitmap.getRotationAngle()) : bitmapDrawable);
    } else if (image instanceof CloseableAnimatedImage) {
        AnimatedDrawableFactory animatedDrawableFactory = Fresco.getimagePipelineFactory().getAnimatedFactory().getAnimatedDrawableFactory(context);
        if (animatedDrawableFactory != null) {
            AnimatedDrawable animatedDrawable = (AnimatedDrawable) animatedDrawableFactory.create(image);
            if (animatedDrawable != null) {
                return animatedDrawable;
            }
        }
    }
    throw new UnsupportedOperationException("Unrecognized image class: " + image);
}
项目:fresco    文件:AnimatedSingleUsePostprocessorProducerTest.java   
@Test
public void testNonStaticBitmapIsPassedOn() {
  SingleUsePostprocessorConsumer postprocessorConsumer = produceResults();
  CloseableAnimatedImage sourceCloseableAnimatedImage = mock(CloseableAnimatedImage.class);
  CloseableReference<CloseableImage> sourceCloseableImageRef =
      CloseableReference.<CloseableImage>of(sourceCloseableAnimatedImage);
  postprocessorConsumer.onNewResult(sourceCloseableImageRef,res0.get());
  res0.close();

  verify(sourceCloseableAnimatedImage).close();
}
项目:fresco    文件:AnimatedRepeatedPostprocessorProducerTest.java   
@Test
public void testNonStaticBitmapIsPassedOn() {
  RepeatedPostprocessorConsumer postprocessorConsumer = produceResults();
  RepeatedPostprocessorRunner repeatedPostprocessorRunner = getRunner();

  CloseableAnimatedImage sourceCloseableAnimatedImage = mock(CloseableAnimatedImage.class);
  CloseableReference<CloseableImage> sourceCloseableImageRef =
      CloseableReference.<CloseableImage>of(sourceCloseableAnimatedImage);
  postprocessorConsumer.onNewResult(sourceCloseableImageRef,res0.get());
  res0.close();

  performCancelAndVerifyOnCancellation();
  verify(sourceCloseableAnimatedImage).close();
}
项目:GitHub    文件:AnimatedImageFactoryImpl.java   
private CloseableImage getCloseableImage(
    ImageDecodeOptions options,AnimatedImage image,Bitmap.Config bitmapConfig) {
  List<CloseableReference<Bitmap>> decodedFrames = null;
  CloseableReference<Bitmap> previewBitmap = null;
  try {
    final int frameForPreview = options.useLastFrameForPreview ? image.getFrameCount() - 1 : 0;
    if (options.forceStaticImage) {
      return new CloseableStaticBitmap(
          createPreviewBitmap(image,bitmapConfig,frameForPreview),ImmutableQualityInfo.FULL_QUALITY,0);
    }

    if (options.decodeAllFrames) {
      decodedFrames = decodeAllFrames(image,bitmapConfig);
      previewBitmap = CloseableReference.cloneOrNull(decodedFrames.get(frameForPreview));
    }

    if (options.decodePreviewFrame && previewBitmap == null) {
      previewBitmap = createPreviewBitmap(image,frameForPreview);
    }
    AnimatedImageResult animatedImageResult = AnimatedImageResult.newBuilder(image)
        .setPreviewBitmap(previewBitmap)
        .setFrameForPreview(frameForPreview)
        .setDecodedFrames(decodedFrames)
        .build();
    return new CloseableAnimatedImage(animatedImageResult);
  } finally {
    CloseableReference.closeSafely(previewBitmap);
    CloseableReference.closeSafely(decodedFrames);
  }
}
项目:GitHub    文件:AnimatedImageFactoryWebPImpltest.java   
@Test
public void testCreateDefaults() {
  WebPImage mockWebPImage = mock(WebPImage.class);

  // Expect a call to WebPImage.create
  TrivialPooledByteBuffer byteBuffer = createByteBuffer();
  when(mWebPImageMock.decode(byteBuffer.getNativePtr(),byteBuffer.size()))
      .thenReturn(mockWebPImage);

  EncodedImage encodedImage = new EncodedImage(
      CloseableReference.of(byteBuffer,FAKE_RESOURCE_RELEASER));
  encodedImage.setimageFormat(ImageFormat.UNKNowN);

  CloseableAnimatedImage closeableImage =
      (CloseableAnimatedImage) mAnimatedImageFactory.decodeWebP(
          encodedImage,ImageDecodeOptions.defaults(),DEFAULT_BITMAP_CONfig);

  // Verify we got the right result
  AnimatedImageResult imageResult = closeableImage.getimageResult();
  assertSame(mockWebPImage,imageResult.getimage());
  assertNull(imageResult.getPreviewBitmap());
  assertFalse(imageResult.hasDecodedFrame(0));

  // Should not have interacted with these.
  verifyZeroInteractions(mMockAnimatedDrawableBackendProvider);
  verifyZeroInteractions(mMockBitmapFactory);
}
项目:GitHub    文件:AnimatedImageFactoryGifImpltest.java   
@Test
public void testCreateDefaults() {
  GifImage mockGifImage = mock(GifImage.class);

  // Expect a call to GifImage.create
  TrivialPooledByteBuffer byteBuffer = createByteBuffer();
  when(mGifImageMock.decode(byteBuffer.getNativePtr(),byteBuffer.size()))
      .thenReturn(mockGifImage);

  EncodedImage encodedImage = new EncodedImage(
      CloseableReference.of(byteBuffer,FAKE_RESOURCE_RELEASER));
  encodedImage.setimageFormat(ImageFormat.UNKNowN);

  CloseableAnimatedImage closeableImage =
      (CloseableAnimatedImage) mAnimatedImageFactory.decodeGif(
          encodedImage,DEFAULT_BITMAP_CONfig);

  // Verify we got the right result
  AnimatedImageResult imageResult = closeableImage.getimageResult();
  assertSame(mockGifImage,imageResult.getimage());
  assertNull(imageResult.getPreviewBitmap());
  assertFalse(imageResult.hasDecodedFrame(0));

  // Should not have interacted with these.
  verifyZeroInteractions(mMockAnimatedDrawableBackendProvider);
  verifyZeroInteractions(mMockBitmapFactory);
}
项目:fresco    文件:AnimatedImageFactoryImpl.java   
private CloseableImage getCloseableImage(
    ImageDecodeOptions options,frameForPreview);
    }
    AnimatedImageResult animatedImageResult = AnimatedImageResult.newBuilder(image)
        .setPreviewBitmap(previewBitmap)
        .setFrameForPreview(frameForPreview)
        .setDecodedFrames(decodedFrames)
        .build();
    return new CloseableAnimatedImage(animatedImageResult);
  } finally {
    CloseableReference.closeSafely(previewBitmap);
    CloseableReference.closeSafely(decodedFrames);
  }
}
项目:fresco    文件:AnimatedImageFactoryWebPImpltest.java   
@Test
public void testCreateDefaults() {
  WebPImage mockWebPImage = mock(WebPImage.class);

  // Expect a call to WebPImage.create
  TrivialPooledByteBuffer byteBuffer = createByteBuffer();
  when(mWebPImageMock.decode(byteBuffer.getNativePtr(),imageResult.getimage());
  assertNull(imageResult.getPreviewBitmap());
  assertFalse(imageResult.hasDecodedFrame(0));

  // Should not have interacted with these.
  verifyZeroInteractions(mMockAnimatedDrawableBackendProvider);
  verifyZeroInteractions(mMockBitmapFactory);
}
项目:fresco    文件:AnimatedImageFactoryGifImpltest.java   
@Test
public void testCreateDefaults() {
  GifImage mockGifImage = mock(GifImage.class);

  // Expect a call to GifImage.create
  TrivialPooledByteBuffer byteBuffer = createByteBuffer();
  when(mGifImageMock.decode(byteBuffer.getNativePtr(),imageResult.getimage());
  assertNull(imageResult.getPreviewBitmap());
  assertFalse(imageResult.hasDecodedFrame(0));

  // Should not have interacted with these.
  verifyZeroInteractions(mMockAnimatedDrawableBackendProvider);
  verifyZeroInteractions(mMockBitmapFactory);
}
项目:GitHub    文件:ExperimentalBitmapAnimationDrawableFactory.java   
@Override
public boolean supportsImageType(CloseableImage image) {
  return image instanceof CloseableAnimatedImage;
}
项目:GitHub    文件:ExperimentalBitmapAnimationDrawableFactory.java   
@Override
public AnimatedDrawable2 createDrawable(CloseableImage image) {
  return new AnimatedDrawable2(
      createAnimationBackend(
          ((CloseableAnimatedImage) image).getimageResult()));
}
项目:GitHub    文件:AnimatedImageFactoryWebPImpltest.java   
@Test
public void testCreateWithPreviewBitmap() throws Exception {
  WebPImage mockWebPImage = mock(WebPImage.class);

  Bitmap mockBitmap = MockBitmapFactory.create(50,50,DEFAULT_BITMAP_CONfig);

  // Expect a call to WebPImage.create
  TrivialPooledByteBuffer byteBuffer = createByteBuffer();
  when(mWebPImageMock.decode(byteBuffer.getNativePtr(),byteBuffer.size()))
      .thenReturn(mockWebPImage);
  when(mockWebPImage.getWidth()).thenReturn(50);
  when(mockWebPImage.getHeight()).thenReturn(50);

  // For decoding preview frame,expect some calls.
  final AnimatedDrawableBackend mockAnimatedDrawableBackend =
      createAnimatedDrawableBackendMock(1);

  when(mMockAnimatedDrawableBackendProvider.get(
          any(AnimatedImageResult.class),isNull(Rect.class)))
      .thenReturn(mockAnimatedDrawableBackend);
  when(mMockBitmapFactory.createBitmapInternal(50,DEFAULT_BITMAP_CONfig))
      .thenReturn(CloseableReference.of(mockBitmap,FAKE_BITMAP_RESOURCE_RELEASER));
  AnimatedImageCompositor mockCompositor = mock(AnimatedImageCompositor.class);
  powermockito.whenNew(AnimatedImageCompositor.class)
      .withAnyArguments()
      .thenReturn(mockCompositor);

  ImageDecodeOptions imageDecodeOptions = ImageDecodeOptions.newBuilder()
      .setDecodePreviewFrame(true)
      .build();
  EncodedImage encodedImage = new EncodedImage(
      CloseableReference.of(byteBuffer,FAKE_RESOURCE_RELEASER));
  encodedImage.setimageFormat(ImageFormat.UNKNowN);
  CloseableAnimatedImage closeableImage =
      (CloseableAnimatedImage) mAnimatedImageFactory.decodeWebP(
          encodedImage,imageDecodeOptions,imageResult.getimage());
  assertNotNull(imageResult.getPreviewBitmap());
  assertFalse(imageResult.hasDecodedFrame(0));

  // Should not have interacted with these.
  verify(mMockAnimatedDrawableBackendProvider).get(
      any(AnimatedImageResult.class),isNull(Rect.class));
  verifyNoMoreInteractions(mMockAnimatedDrawableBackendProvider);
  verify(mMockBitmapFactory).createBitmapInternal(50,DEFAULT_BITMAP_CONfig);
  verifyNoMoreInteractions(mMockBitmapFactory);
  verify(mockCompositor).renderFrame(0,mockBitmap);
}
项目:GitHub    文件:AnimatedImageFactoryWebPImpltest.java   
@Test
public void testCreateWithDecodeAlFrames() throws Exception {
  WebPImage mockWebPImage = mock(WebPImage.class);

  Bitmap mockBitmap1 = MockBitmapFactory.create(50,DEFAULT_BITMAP_CONfig);
  Bitmap mockBitmap2 = MockBitmapFactory.create(50,expect some calls.
  final AnimatedDrawableBackend mockAnimatedDrawableBackend =
      createAnimatedDrawableBackendMock(2);
  when(
      mMockAnimatedDrawableBackendProvider.get(
          any(AnimatedImageResult.class),isNull(Rect.class)))
      .thenReturn(mockAnimatedDrawableBackend);

  when(mMockBitmapFactory.createBitmapInternal(50,DEFAULT_BITMAP_CONfig))
      .thenReturn(CloseableReference.of(mockBitmap1,FAKE_BITMAP_RESOURCE_RELEASER))
      .thenReturn(CloseableReference.of(mockBitmap2,FAKE_BITMAP_RESOURCE_RELEASER));
  AnimatedImageCompositor mockCompositor = mock(AnimatedImageCompositor.class);
  powermockito.whenNew(AnimatedImageCompositor.class)
      .withAnyArguments()
      .thenReturn(mockCompositor);

  ImageDecodeOptions imageDecodeOptions = ImageDecodeOptions.newBuilder()
      .setDecodePreviewFrame(true)
      .setDecodeAllFrames(true)
      .build();

  EncodedImage encodedImage = new EncodedImage(
      CloseableReference.of(byteBuffer,imageResult.getimage());
  assertNotNull(imageResult.getDecodedFrame(0));
  assertNotNull(imageResult.getDecodedFrame(1));
  assertNotNull(imageResult.getPreviewBitmap());

  // Should not have interacted with these.
  verify(mMockAnimatedDrawableBackendProvider).get(
      any(AnimatedImageResult.class),isNull(Rect.class));
  verifyNoMoreInteractions(mMockAnimatedDrawableBackendProvider);
  verify(mMockBitmapFactory,times(2)).createBitmapInternal(50,mockBitmap1);
  verify(mockCompositor).renderFrame(1,mockBitmap2);
}
项目:GitHub    文件:AnimatedImageFactoryGifImpltest.java   
@Test
public void testCreateWithPreviewBitmap() throws Exception {
  GifImage mockGifImage = mock(GifImage.class);

  Bitmap mockBitmap = MockBitmapFactory.create(50,DEFAULT_BITMAP_CONfig);

  // Expect a call to WebPImage.create
  TrivialPooledByteBuffer byteBuffer = createByteBuffer();
  when(mGifImageMock.decode(byteBuffer.getNativePtr(),byteBuffer.size()))
      .thenReturn(mockGifImage);
  when(mockGifImage.getWidth()).thenReturn(50);
  when(mockGifImage.getHeight()).thenReturn(50);

  // For decoding preview frame,expect some calls.
  final AnimatedDrawableBackend mockAnimatedDrawableBackend =
      createAnimatedDrawableBackendMock(1);
  when(mMockAnimatedDrawableBackendProvider.get(
      any(AnimatedImageResult.class),FAKE_RESOURCE_RELEASER));
  encodedImage.setimageFormat(ImageFormat.UNKNowN);
  CloseableAnimatedImage closeableImage =
      (CloseableAnimatedImage) mAnimatedImageFactory.decodeGif(
          encodedImage,mockBitmap);
}
项目:GitHub    文件:AnimatedImageFactoryGifImpltest.java   
@Test
public void testCreateWithDecodeAlFrames() throws Exception {
  GifImage mockGifImage = mock(GifImage.class);

  Bitmap mockBitmap1 = MockBitmapFactory.create(50,DEFAULT_BITMAP_CONfig);

  // Expect a call to GifImage.create
  TrivialPooledByteBuffer byteBuffer = createByteBuffer();
  when(mGifImageMock.decode(byteBuffer.getNativePtr(),expect some calls.
  final AnimatedDrawableBackend mockAnimatedDrawableBackend =
      createAnimatedDrawableBackendMock(2);

  when(
      mMockAnimatedDrawableBackendProvider.get(
          any(AnimatedImageResult.class),mockBitmap2);
}
项目:fresco    文件:ExperimentalBitmapAnimationDrawableFactory.java   
@Override
public boolean supportsImageType(CloseableImage image) {
  return image instanceof CloseableAnimatedImage;
}
项目:fresco    文件:ExperimentalBitmapAnimationDrawableFactory.java   
@Override
public AnimatedDrawable2 createDrawable(CloseableImage image) {
  return new AnimatedDrawable2(
      createAnimationBackend(
          ((CloseableAnimatedImage) image).getimageResult()));
}
项目:fresco    文件:AnimatedImageFactoryWebPImpltest.java   
@Test
public void testCreateWithPreviewBitmap() throws Exception {
  WebPImage mockWebPImage = mock(WebPImage.class);

  Bitmap mockBitmap = MockBitmapFactory.create(50,mockBitmap);
}
项目:fresco    文件:AnimatedImageFactoryWebPImpltest.java   
@Test
public void testCreateWithDecodeAlFrames() throws Exception {
  WebPImage mockWebPImage = mock(WebPImage.class);

  Bitmap mockBitmap1 = MockBitmapFactory.create(50,mockBitmap2);
}
项目:fresco    文件:AnimatedImageFactoryGifImpltest.java   
@Test
public void testCreateWithPreviewBitmap() throws Exception {
  GifImage mockGifImage = mock(GifImage.class);

  Bitmap mockBitmap = MockBitmapFactory.create(50,mockBitmap);
}
项目:fresco    文件:AnimatedImageFactoryGifImpltest.java   
@Test
public void testCreateWithDecodeAlFrames() throws Exception {
  GifImage mockGifImage = mock(GifImage.class);

  Bitmap mockBitmap1 = MockBitmapFactory.create(50,mockBitmap2);
}
项目:CanPhotos    文件:CanViewPagerActivity.java   
private void handleAnimateBitmap(CloseableAnimatedImage animatedImage,int position) {

        AnimatedDrawableFactory animatedDrawableFactory =
                Fresco.getimagePipelineFactory().getAnimatedDrawableFactory();
        AnimatedDrawable drawable =
                animatedDrawableFactory.create(animatedImage.getimageResult());

        Bitmap bitmap = drawable2Bitmap(drawable);
        map.put(position,bitmap);


    }

com.facebook.imagepipeline.image.CloseableBitmap的实例源码

com.facebook.imagepipeline.image.CloseableBitmap的实例源码

项目:GitHub    文件:BaseBitmapDataSubscriber.java   
@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);
  }
}
项目:android-upload-service    文件:UploadJob.java   
@Override
public void onRun() throws Throwable {
  Log.i(TAG,"RUNNING UploadJob for Item["+itemId+"] Uri["+uri.toString()+"]");

  if(MediaUtils.isPhoto(UriUtils.extractMimeType(weakReference.get(),uri))) {
    DataSource<CloseableReference<CloseableImage>> dataSource = Fresco.getimagePipeline().fetchDecodedImage(ImageRequest.fromUri(uri),weakReference.get());
    Throwable failureCause = dataSource.getFailureCause();
    if (failureCause != null) {
      throw failureCause;
    }

    CloseableReference<CloseableImage> result = dataSource.getResult();
    if (result != null) {
      CloseableImage closeableImage = result.get();
      if (closeableImage instanceof CloseableBitmap) {
        Bitmap bitmap = ((CloseableBitmap) closeableImage).getUnderlyingBitmap();
        uploadFile(createImageTempFile(bitmap));
      }
    }
  }else{
    uploadFile(new File(uri.getPath()));
  }
}
项目:fresco    文件:BaseBitmapDataSubscriber.java   
@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);
  }
}
项目:GitHub    文件:BaseFrescoStethoPlugin.java   
private void storeEntries(
    List<CountingMemoryCacheInspector.DumpInfoEntry<CacheKey,CloseableImage>>
        entries,int i,PrintStream writer,File directory) throws IOException {
  String filename;
  for (CountingMemoryCacheInspector.DumpInfoEntry<CacheKey,CloseableImage>
      entry : entries) {
      CloseableImage closeableImage = entry.value.get();
      if (closeableImage instanceof CloseableBitmap) {
        CloseableBitmap closeableBitmap = (CloseableBitmap) closeableImage;
        filename = "tmp" + i + ".png";
        writer.println(formatStrLocaleSafe(
            "Storing image %d as %s. Key: %s",i,filename,entry.key));
        storeImage(
            closeableBitmap.getUnderlyingBitmap(),new File(directory,filename),Bitmap.CompressFormat.PNG,100);
      } else {
        writer.println(formatStrLocaleSafe(
            "Image %d has unrecognized type %s. Key: %s",closeableImage,entry.key));
      }
    i++;
    }
}
项目:RNLearn_Project1    文件:PipelineRequestHelper.java   
/**
 * Returns an unsafe bitmap reference. Do not assign the result of this method to anything other
 * than a local variable,or it will no longer work with the reference count goes to zero.
 */
/* package */ @Nullable Bitmap getBitmap() {
  if (mImageRef == null) {
    return null;
  }

  CloseableImage closeableImage = mImageRef.get();
  if (!(closeableImage instanceof CloseableBitmap)) {
    mImageRef.close();
    mImageRef = null;
    return null;
  }

  return ((CloseableBitmap) closeableImage).getUnderlyingBitmap();
}
项目:fresco    文件:BaseFrescoStethoPlugin.java   
private void storeEntries(
    List<CountingMemoryCacheInspector.DumpInfoEntry<CacheKey,entry.key));
      }
    i++;
    }
}
项目:S1-Go    文件:ImageLoader.java   
@Override
public void onFinalimageset(String id,ImageInfo imageInfo,Animatable animatable) {
    super.onFinalimageset(id,imageInfo,animatable);
    if (mloadingListener != null && mImageView != null) {
        ImageView imageView = mImageView.get();
        if (imageInfo != null) {
            if (imageInfo instanceof CloseableBitmap) {
                mloadingListener.onLoadingComplete(mImageUri,imageView,((CloseableBitmap) imageInfo).getUnderlyingBitmap());
                return;
            }
        }
        mloadingListener.onLoadingComplete(mImageUri,null);
    }
}
项目:GitHub    文件:FrescoFrameCache.java   
private static int getBitmapSizeBytes(@Nullable CloseableImage image) {
  if (!(image instanceof CloseableBitmap)) {
    return 0;
  }
  return BitmapUtil.getSizeInBytes(((CloseableBitmap) image).getUnderlyingBitmap());
}
项目:CustomListView    文件:BaseBitmapDataSubscriber.java   
@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);
        }*/
    }
项目:RNLearn_Project1    文件:PipelineRequestHelper.java   
@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();
  }
}
项目:CanPhotos    文件:CanViewPagerActivity.java   
private void handleBitmap(CloseableBitmap closeableBitmap,int position) {
    Bitmap bitmap = closeableBitmap.getUnderlyingBitmap();
    map.put(position,bitmap);

}
项目:SneezeReader    文件:ShareActivity.java   
/**
 * 从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,bitmap.getWidth(),bitmap.getHeight());

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

    return null;
}
项目:fresco    文件:FrescoFrameCache.java   
private static int getBitmapSizeBytes(@Nullable CloseableImage image) {
  if (!(image instanceof CloseableBitmap)) {
    return 0;
  }
  return BitmapUtil.getSizeInBytes(((CloseableBitmap) image).getUnderlyingBitmap());
}

com.facebook.imagepipeline.image.CloseableStaticBitmap的实例源码

com.facebook.imagepipeline.image.CloseableStaticBitmap的实例源码

项目:GitHub    文件:BoxingFrescoLoader.java   
private Drawable createDrawableFromFetchedResult(Context context,CloseableImage image) {
    if (image instanceof CloseableStaticBitmap) {
        CloseableStaticBitmap closeableStaticBitmap = (CloseableStaticBitmap) image;
        BitmapDrawable bitmapDrawable = createBitmapDrawable(context,closeableStaticBitmap.getUnderlyingBitmap());
        return (closeableStaticBitmap.getRotationAngle() != 0 && closeableStaticBitmap.getRotationAngle() != -1 ? new OrientedDrawable(bitmapDrawable,closeableStaticBitmap.getRotationAngle()) : bitmapDrawable);
    } else if (image instanceof CloseableAnimatedImage) {
        AnimatedDrawableFactory animatedDrawableFactory = Fresco.getimagePipelineFactory().getAnimatedFactory().getAnimatedDrawableFactory(context);
        if (animatedDrawableFactory != null) {
            AnimatedDrawable animatedDrawable = (AnimatedDrawable) animatedDrawableFactory.create(image);
            if (animatedDrawable != null) {
                return animatedDrawable;
            }
        }
    }
    throw new UnsupportedOperationException("Unrecognized image class: " + image);
}
项目:GitHub    文件:PipelineDraweeController.java   
@Override
public Drawable createDrawable(CloseableImage closeableImage) {
  if (closeableImage instanceof CloseableStaticBitmap) {
    CloseableStaticBitmap closeableStaticBitmap = (CloseableStaticBitmap) closeableImage;
    Drawable bitmapDrawable =
        new BitmapDrawable(mResources,closeableStaticBitmap.getUnderlyingBitmap());
    if (!hasTransformableRotationAngle(closeableStaticBitmap)
        && !hasTransformableExifOrientation(closeableStaticBitmap)) {
      // Return the bitmap drawable directly as there's nothing to transform in it
      return bitmapDrawable;
    } else {
      return new OrientedDrawable(
          bitmapDrawable,closeableStaticBitmap.getRotationAngle(),closeableStaticBitmap.getExifOrientation());
    }
  } else if (mAnimatedDrawableFactory != null
      && mAnimatedDrawableFactory.supportsImageType(closeableImage)) {
    return mAnimatedDrawableFactory.createDrawable(closeableImage);
  }
  return null;
}
项目:GitHub    文件:FrescoFrameCache.java   
/**
 * Converts the given image reference to a bitmap reference
 * and closes the original image reference.
 *
 * @param closeableImage the image to convert. It will be closed afterwards and will be invalid
 * @return the closeable bitmap reference to be used
 */
@VisibleForTesting
@Nullable
static CloseableReference<Bitmap> convertToBitmapReferenceAndClose(
    final @Nullable CloseableReference<CloseableImage> closeableImage) {
  try {
    if (CloseableReference.isValid(closeableImage) &&
        closeableImage.get() instanceof CloseableStaticBitmap) {

      CloseableStaticBitmap closeableStaticBitmap = (CloseableStaticBitmap) closeableImage.get();
      if (closeableStaticBitmap != null) {
        // We return a clone of the underlying bitmap reference that has to be manually closed
        // and then close the passed CloseableStaticBitmap in order to preserve correct
        // cache size calculations.
        return closeableStaticBitmap.cloneUnderlyingBitmapReference();
      }
    }
    // Not a bitmap reference,so we return null
    return null;
  } finally {
    CloseableReference.closeSafely(closeableImage);
  }
}
项目:GitHub    文件:AnimatedRepeatedPostprocessorProducerTest.java   
private void verifyNewResultProcessed(int index,Bitmap destBitmap) {
  mInorder.verify(mProducerListener).onProducerStart(mRequestId,PostprocessorProducer.NAME);
  mInorder.verify(mPostprocessor).process(mSourceBitmap,mPlatformBitmapFactory);
  mInorder.verify(mProducerListener).requiresExtraMap(mRequestId);
  mInorder.verify(mProducerListener)
      .onProducerFinishWithSuccess(mRequestId,PostprocessorProducer.NAME,mExtraMap);
  mInorder.verify(mConsumer).onNewResult(any(CloseableReference.class),eq(Consumer.NO_FLAGS));
  mInorder.verifyNoMoreInteractions();

  assertEquals(index + 1,mResults.size());
  CloseableReference<CloseableImage> res0 = mResults.get(index);
  assertTrue(CloseableReference.isValid(res0));
  assertSame(destBitmap,((CloseableStaticBitmap) res0.get()).getUnderlyingBitmap());
  res0.close();
  verify(mBitmapResourceReleaser).release(destBitmap);
}
项目:GitHub    文件:Defaultimagedecoder.java   
/**
 * @param encodedImage input image (encoded bytes plus Meta data)
 * @return a CloseableStaticBitmap
 */
public CloseableStaticBitmap decodeStaticImage(
    final EncodedImage encodedImage,ImageDecodeOptions options) {
  CloseableReference<Bitmap> bitmapReference =
      mPlatformDecoder.decodeFromEncodedImage(encodedImage,options.bitmapConfig,null);
  try {
    return new CloseableStaticBitmap(
        bitmapReference,ImmutableQualityInfo.FULL_QUALITY,encodedImage.getRotationAngle(),encodedImage.getExifOrientation());
  } finally {
    bitmapReference.close();
  }
}
项目:GitHub    文件:Defaultimagedecoder.java   
/**
 * Decodes a partial jpeg.
 *
 * @param encodedImage input image (encoded bytes plus Meta data)
 * @param length amount of currently available data in bytes
 * @param qualityInfo quality info for the image
 * @return a CloseableStaticBitmap
 */
public CloseableStaticBitmap decodeJpeg(
    final EncodedImage encodedImage,int length,QualityInfo qualityInfo,ImageDecodeOptions options) {
  CloseableReference<Bitmap> bitmapReference =
      mPlatformDecoder.decodeJPEGFromEncodedImage(
          encodedImage,null,length);
  try {
    return new CloseableStaticBitmap(
        bitmapReference,qualityInfo,encodedImage.getExifOrientation());
  } finally {
    bitmapReference.close();
  }
}
项目:GitHub    文件:SingleUsePostprocessorProducerTest.java   
@Test
public void testSuccess() {
  SingleUsePostprocessorConsumer postprocessorConsumer = produceResults();
  doReturn(mDestinationCloseableBitmapRef)
      .when(mPostprocessor).process(mSourceBitmap,mPlatformBitmapFactory);
  postprocessorConsumer.onNewResult(mSourceCloseableImageRef,Consumer.IS_LAST);
  mSourceCloseableImageRef.close();
  mTestExecutorService.runUntilIdle();

  mInorder.verify(mProducerListener).onProducerStart(mRequestId,eq(Consumer.IS_LAST));
  mInorder.verifyNoMoreInteractions();

  assertEquals(1,mResults.size());
  CloseableReference<CloseableImage> res0 = mResults.get(0);
  assertTrue(CloseableReference.isValid(res0));
  assertSame(mDestinationBitmap,((CloseableStaticBitmap) res0.get()).getUnderlyingBitmap());
  res0.close();

  verify(mBitmapResourceReleaser).release(mDestinationBitmap);
  verify(mSourceCloseableStaticBitmap).close();
}
项目:GitHub    文件:RepeatedPostprocessorProducerTest.java   
private void verifyNewResultProcessed(int index,((CloseableStaticBitmap) res0.get()).getUnderlyingBitmap());
  res0.close();
  verify(mBitmapResourceReleaser).release(destBitmap);
}
项目:Boxing    文件:BoxingFrescoLoader.java   
private Drawable createDrawableFromFetchedResult(Context context,closeableStaticBitmap.getRotationAngle()) : bitmapDrawable);
    } else if (image instanceof CloseableAnimatedImage) {
        AnimatedDrawableFactory animatedDrawableFactory = Fresco.getimagePipelineFactory().getAnimatedFactory().getAnimatedDrawableFactory(context);
        if (animatedDrawableFactory != null) {
            AnimatedDrawable animatedDrawable = (AnimatedDrawable) animatedDrawableFactory.create(image);
            if (animatedDrawable != null) {
                return animatedDrawable;
            }
        }
    }
    throw new UnsupportedOperationException("Unrecognized image class: " + image);
}
项目:fresco    文件:PipelineDraweeController.java   
@Override
public Drawable createDrawable(CloseableImage closeableImage) {
  if (closeableImage instanceof CloseableStaticBitmap) {
    CloseableStaticBitmap closeableStaticBitmap = (CloseableStaticBitmap) closeableImage;
    Drawable bitmapDrawable =
        new BitmapDrawable(mResources,closeableStaticBitmap.getExifOrientation());
    }
  } else if (mAnimatedDrawableFactory != null
      && mAnimatedDrawableFactory.supportsImageType(closeableImage)) {
    return mAnimatedDrawableFactory.createDrawable(closeableImage);
  }
  return null;
}
项目:fresco    文件:FrescoFrameCache.java   
/**
 * Converts the given image reference to a bitmap reference
 * and closes the original image reference.
 *
 * @param closeableImage the image to convert. It will be closed afterwards and will be invalid
 * @return the closeable bitmap reference to be used
 */
@VisibleForTesting
@Nullable
static CloseableReference<Bitmap> convertToBitmapReferenceAndClose(
    final @Nullable CloseableReference<CloseableImage> closeableImage) {
  try {
    if (CloseableReference.isValid(closeableImage) &&
        closeableImage.get() instanceof CloseableStaticBitmap) {

      CloseableStaticBitmap closeableStaticBitmap = (CloseableStaticBitmap) closeableImage.get();
      if (closeableStaticBitmap != null) {
        // We return a clone of the underlying bitmap reference that has to be manually closed
        // and then close the passed CloseableStaticBitmap in order to preserve correct
        // cache size calculations.
        return closeableStaticBitmap.cloneUnderlyingBitmapReference();
      }
    }
    // Not a bitmap reference,so we return null
    return null;
  } finally {
    CloseableReference.closeSafely(closeableImage);
  }
}
项目:fresco    文件:AnimatedRepeatedPostprocessorProducerTest.java   
private void verifyNewResultProcessed(int index,((CloseableStaticBitmap) res0.get()).getUnderlyingBitmap());
  res0.close();
  verify(mBitmapResourceReleaser).release(destBitmap);
}
项目:fresco    文件:Defaultimagedecoder.java   
/**
 * @param encodedImage input image (encoded bytes plus Meta data)
 * @return a CloseableStaticBitmap
 */
public CloseableStaticBitmap decodeStaticImage(
    final EncodedImage encodedImage,encodedImage.getExifOrientation());
  } finally {
    bitmapReference.close();
  }
}
项目:fresco    文件:Defaultimagedecoder.java   
/**
 * Decodes a partial jpeg.
 *
 * @param encodedImage input image (encoded bytes plus Meta data)
 * @param length amount of currently available data in bytes
 * @param qualityInfo quality info for the image
 * @return a CloseableStaticBitmap
 */
public CloseableStaticBitmap decodeJpeg(
    final EncodedImage encodedImage,encodedImage.getExifOrientation());
  } finally {
    bitmapReference.close();
  }
}
项目:fresco    文件:SingleUsePostprocessorProducerTest.java   
@Test
public void testSuccess() {
  SingleUsePostprocessorConsumer postprocessorConsumer = produceResults();
  doReturn(mDestinationCloseableBitmapRef)
      .when(mPostprocessor).process(mSourceBitmap,((CloseableStaticBitmap) res0.get()).getUnderlyingBitmap());
  res0.close();

  verify(mBitmapResourceReleaser).release(mDestinationBitmap);
  verify(mSourceCloseableStaticBitmap).close();
}
项目:fresco    文件:RepeatedPostprocessorProducerTest.java   
private void verifyNewResultProcessed(int index,((CloseableStaticBitmap) res0.get()).getUnderlyingBitmap());
  res0.close();
  verify(mBitmapResourceReleaser).release(destBitmap);
}
项目:GitHub    文件:FrescoFrameCache.java   
@Nullable
private static CloseableReference<CloseableImage> createImageReference(
    CloseableReference<Bitmap> bitmapReference) {
  // The given CloseableStaticBitmap will be cached and then released by the resource releaser
  // of the closeable reference
  CloseableImage closeableImage =
      new CloseableStaticBitmap(bitmapReference,0);
  return CloseableReference.of(closeableImage);
}
项目:GitHub    文件:AnimatedImageFactoryImpl.java   
private CloseableImage getCloseableImage(
    ImageDecodeOptions options,AnimatedImage image,Bitmap.Config bitmapConfig) {
  List<CloseableReference<Bitmap>> decodedFrames = null;
  CloseableReference<Bitmap> previewBitmap = null;
  try {
    final int frameForPreview = options.useLastFrameForPreview ? image.getFrameCount() - 1 : 0;
    if (options.forceStaticImage) {
      return new CloseableStaticBitmap(
          createPreviewBitmap(image,bitmapConfig,frameForPreview),0);
    }

    if (options.decodeAllFrames) {
      decodedFrames = decodeAllFrames(image,bitmapConfig);
      previewBitmap = CloseableReference.cloneOrNull(decodedFrames.get(frameForPreview));
    }

    if (options.decodePreviewFrame && previewBitmap == null) {
      previewBitmap = createPreviewBitmap(image,frameForPreview);
    }
    AnimatedImageResult animatedImageResult = AnimatedImageResult.newBuilder(image)
        .setPreviewBitmap(previewBitmap)
        .setFrameForPreview(frameForPreview)
        .setDecodedFrames(decodedFrames)
        .build();
    return new CloseableAnimatedImage(animatedImageResult);
  } finally {
    CloseableReference.closeSafely(previewBitmap);
    CloseableReference.closeSafely(decodedFrames);
  }
}
项目:GitHub    文件:AnimatedSingleUsePostprocessorProducerTest.java   
@Before
public void setUp() {
  MockitoAnnotations.initMocks(this);
  mTestExecutorService = new TestExecutorService(new FakeClock());
  mPostprocessorProducer =
      new PostprocessorProducer(
          mInputProducer,mPlatformBitmapFactory,mTestExecutorService);

  when(mImageRequest.getPostprocessor()).thenReturn(mPostprocessor);
  when(mProducerContext.getId()).thenReturn(mRequestId);
  when(mProducerContext.getListener()).thenReturn(mProducerListener);
  when(mProducerContext.getimageRequest()).thenReturn(mImageRequest);

  mResults = new ArrayList<>();
  when(mPostprocessor.getName()).thenReturn(POSTPROCESSOR_NAME);
  when(mProducerListener.requiresExtraMap(mRequestId)).thenReturn(true);
  doAnswer(
      new Answer<Object>() {
        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
          mResults.add(
              ((CloseableReference<CloseableImage>) invocation.getArguments()[0]).clone());
          return null;
        }
      }
  ).when(mConsumer).onNewResult(any(CloseableReference.class),anyInt());
  mInorder = inorder(mPostprocessor,mProducerListener,mConsumer);

  mSourceBitmap = mock(Bitmap.class);
  mSourceCloseableStaticBitmap = mock(CloseableStaticBitmap.class);
  when(mSourceCloseableStaticBitmap.getUnderlyingBitmap()).thenReturn(mSourceBitmap);
  mSourceCloseableImageRef =
      CloseableReference.<CloseableImage>of(mSourceCloseableStaticBitmap);
  mDestinationBitmap = mock(Bitmap.class);
  mDestinationCloseableBitmapRef =
      CloseableReference.of(mDestinationBitmap,mBitmapResourceReleaser);
}
项目:GitHub    文件:AnimatedRepeatedPostprocessorProducerTest.java   
private void setupNewSourceImage() {
  mSourceBitmap = mock(Bitmap.class);
  mSourceCloseableStaticBitmap = mock(CloseableStaticBitmap.class);
  when(mSourceCloseableStaticBitmap.getUnderlyingBitmap()).thenReturn(mSourceBitmap);
  mSourceCloseableImageRef =
      CloseableReference.<CloseableImage>of(mSourceCloseableStaticBitmap);
}
项目:GitHub    文件:PostprocessorProducer.java   
private CloseableReference<CloseableImage> postprocessInternal(CloseableImage sourceImage) {
  CloseableStaticBitmap staticBitmap = (CloseableStaticBitmap) sourceImage;
  Bitmap sourceBitmap = staticBitmap.getUnderlyingBitmap();
  CloseableReference<Bitmap> bitmapRef = mPostprocessor.process(sourceBitmap,mBitmapFactory);
  int rotationAngle = staticBitmap.getRotationAngle();
  int exifOrientation = staticBitmap.getExifOrientation();
  try {
    return CloseableReference.<CloseableImage>of(
        new CloseableStaticBitmap(
            bitmapRef,sourceImage.getQualityInfo(),rotationAngle,exifOrientation));
  } finally {
    CloseableReference.closeSafely(bitmapRef);
  }
}
项目:GitHub    文件:BitmapPrepareProducer.java   
private void internalPrepareBitmap(CloseableReference<CloseableImage> newResult) {
  if (newResult == null || !newResult.isValid()) {
    return;
  }

  final CloseableImage closeableImage = newResult.get();
  if (closeableImage == null || closeableImage.isClosed()) {
    return;
  }

  if (closeableImage instanceof CloseableStaticBitmap) {
    final CloseableStaticBitmap staticBitmap = (CloseableStaticBitmap) closeableImage;
    final Bitmap bitmap = staticBitmap.getUnderlyingBitmap();
    if (bitmap == null) {
      return;
    }

    final int bitmapByteCount = bitmap.getRowBytes() * bitmap.getHeight();
    if (bitmapByteCount < mMinBitmapSizeBytes) {
      return;
    }
    if (bitmapByteCount > mMaxBitmapSizeBytes) {
      return;
    }

    bitmap.preparetoDraw();
  }
}
项目:GitHub    文件:SingleUsePostprocessorProducerTest.java   
@Before
public void setUp() {
  MockitoAnnotations.initMocks(this);
  mTestExecutorService = new TestExecutorService(new FakeClock());
  mPostprocessorProducer =
      new PostprocessorProducer(
          mInputProducer,mBitmapResourceReleaser);
}
项目:GitHub    文件:RepeatedPostprocessorProducerTest.java   
private void setupNewSourceImage() {
  mSourceBitmap = mock(Bitmap.class);
  mSourceCloseableStaticBitmap = mock(CloseableStaticBitmap.class);
  when(mSourceCloseableStaticBitmap.getUnderlyingBitmap()).thenReturn(mSourceBitmap);
  mSourceCloseableImageRef =
      CloseableReference.<CloseableImage>of(mSourceCloseableStaticBitmap);
}
项目:galleryFinal-master    文件:FrescoImageLoader.java   
/**
 * 加载远程图片
 *
 * @param url
 * @param imageSize
 */
private void displayImage(Uri url,ResizeOptions imageSize,final ImageView imageView,final DraweeHolder<GenericDraweeHierarchy> draweeHolder) {
    ImageRequest imageRequest = ImageRequestBuilder
            .newBuilderWithSource(url)
            .setResizeOptions(imageSize)//图片目标大小
            .build();
    ImagePipeline imagePipeline = Fresco.getimagePipeline();

    final DataSource<CloseableReference<CloseableImage>> dataSource = imagePipeline.fetchDecodedImage(imageRequest,this);
    DraweeController controller = Fresco.newDraweeControllerBuilder()
            .setoldController(draweeHolder.getController())
            .setimageRequest(imageRequest)
            .setControllerListener(new BaseControllerListener<ImageInfo>() {
                @Override
                public void onFinalimageset(String s,ImageInfo imageInfo,Animatable animatable) {
                    CloseableReference<CloseableImage> imageReference = null;
                    try {
                        imageReference = dataSource.getResult();
                        if (imageReference != null) {
                            CloseableImage image = imageReference.get();
                            if (image != null && image instanceof CloseableStaticBitmap) {
                                CloseableStaticBitmap closeableStaticBitmap = (CloseableStaticBitmap) image;
                                Bitmap bitmap = closeableStaticBitmap.getUnderlyingBitmap();
                                if (bitmap != null && imageView != null) {
                                    imageView.setimageBitmap(bitmap);
                                }
                            }
                        }
                    } finally {
                        dataSource.close();
                        CloseableReference.closeSafely(imageReference);
                    }
                }
            })
            .setTapToRetryEnabled(true)
            .build();
    draweeHolder.setController(controller);
}
项目:react-native-amap    文件:AMapMarker.java   
@Override
public void onFinalimageset(
        String id,@Nullable final ImageInfo imageInfo,@Nullable Animatable animatable) {
    CloseableReference<CloseableImage> imageReference = null;
    try {
        imageReference = dataSource.getResult();
        if (imageReference != null) {
            CloseableImage image = imageReference.get();
            if (image != null && image instanceof CloseableStaticBitmap) {
                CloseableStaticBitmap closeableStaticBitmap = (CloseableStaticBitmap) image;
                Bitmap bitmap = closeableStaticBitmap.getUnderlyingBitmap();
                if (bitmap != null) {
                    bitmap = bitmap.copy(Bitmap.Config.ARGB_8888,true);
                    iconBitmap = bitmap;
                    iconBitmapDescriptor = BitmapDescriptorFactory.fromBitmap(bitmap);
                }
            }
        }
    } finally {
        dataSource.close();
        if (imageReference != null) {
            CloseableReference.closeSafely(imageReference);
        }
    }
    update();
}
项目:Li-MVPArms    文件:PhotoView.java   
public void setimageUri(String url) {
    ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(Uri.parse(url)).build();
    ImagePipeline imagePipeline = Fresco.getimagePipeline();
    final DataSource<CloseableReference<CloseableImage>> dataSource = imagePipeline.fetchDecodedImage(imageRequest,this);
    DraweeController controller = Fresco.newDraweeControllerBuilder()
            .setoldController(mDraweeHolder.getController())
            .setimageRequest(imageRequest)
            .setControllerListener(new BaseControllerListener<ImageInfo>() {
                @Override
                public void onFinalimageset(String s,@Nullable ImageInfo imageInfo,@Nullable Animatable animatable) {
                    try {
                        imageReference = dataSource.getResult();
                        if (imageReference != null) {
                            CloseableImage image = imageReference.get();
                            // do something with the image
                            if (image != null && image instanceof CloseableStaticBitmap) {
                                CloseableStaticBitmap closeableStaticBitmap = (CloseableStaticBitmap) image;
                                Bitmap bitmap = closeableStaticBitmap.getUnderlyingBitmap();
                                if (bitmap != null) {
                                    setimageBitmap(bitmap);
                                }
                            }
                        }
                    } finally {
                        dataSource.close();
                        CloseableReference.closeSafely(imageReference);
                    }
                }
            })
            .setTapToRetryEnabled(true)
            .build();
    mDraweeHolder.setController(controller);
}
项目:Li-MVPArms    文件:PhotoView.java   
public void setimageUri(String uri,int width,int height) {
    ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(Uri.parse(uri))
            .setAutoRotateEnabled(true)
            .setResizeOptions(new ResizeOptions(width,height))
            .build();
    ImagePipeline imagePipeline = Fresco.getimagePipeline();
    final DataSource<CloseableReference<CloseableImage>> dataSource = imagePipeline.fetchDecodedImage(imageRequest,@Nullable Animatable animatable) {
                    try {
                        imageReference = dataSource.getResult();
                        if (imageReference != null) {
                            CloseableImage image = imageReference.get();
                            if (image != null && image instanceof CloseableStaticBitmap) {
                                CloseableStaticBitmap closeableStaticBitmap = (CloseableStaticBitmap) image;
                                Bitmap bitmap = closeableStaticBitmap.getUnderlyingBitmap();
                                if (bitmap != null) {
                                    setimageBitmap(bitmap);
                                }
                            }
                        }
                    } finally {
                        dataSource.close();
                        CloseableReference.closeSafely(imageReference);
                    }
                }
            })
            .setTapToRetryEnabled(true)
            .build();
    mDraweeHolder.setController(controller);
}
项目:wechat-gallery    文件:FrescoImageLoader.java   
/**
 * 加载远程图片
 *
 * @param url
 * @param imageSize
 */
private void displayImage(Uri url,Animatable animatable) {
                    CloseableReference<CloseableImage> imageReference = null;
                    try {
                        imageReference = dataSource.getResult();
                        if (imageReference != null) {
                            CloseableImage image = imageReference.get();
                            if (image != null && image instanceof CloseableStaticBitmap) {
                                CloseableStaticBitmap closeableStaticBitmap = (CloseableStaticBitmap) image;
                                Bitmap bitmap = closeableStaticBitmap.getUnderlyingBitmap();
                                if (bitmap != null && imageView != null) {
                                    imageView.setimageBitmap(bitmap);
                                }
                            }
                        }
                    } finally {
                        dataSource.close();
                        CloseableReference.closeSafely(imageReference);
                    }
                }
            })
            .setTapToRetryEnabled(true)
            .build();
    draweeHolder.setController(controller);
}
项目:HaoCommon    文件:PhotoView.java   
public void setimageUri(String url) {
    ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(Uri.parse(url)).build();
    ImagePipeline imagePipeline = Fresco.getimagePipeline();
    final DataSource<CloseableReference<CloseableImage>> dataSource = imagePipeline.fetchDecodedImage(imageRequest,@Nullable Animatable animatable) {
                    try {
                        imageReference = dataSource.getResult();
                        if (imageReference != null) {
                            CloseableImage image = imageReference.get();
                            // do something with the image
                            if (image != null && image instanceof CloseableStaticBitmap) {
                                CloseableStaticBitmap closeableStaticBitmap = (CloseableStaticBitmap) image;
                                Bitmap bitmap = closeableStaticBitmap.getUnderlyingBitmap();
                                if (bitmap != null) {
                                    setimageBitmap(bitmap);
                                }
                            }
                        }
                    } finally {
                        dataSource.close();
                        CloseableReference.closeSafely(imageReference);
                    }
                }
            })
            .setTapToRetryEnabled(true)
            .build();
    mDraweeHolder.setController(controller);
}
项目:HaoCommon    文件:PhotoView.java   
public void setimageUri(String uri,@Nullable Animatable animatable) {
                    try {
                        imageReference = dataSource.getResult();
                        if (imageReference != null) {
                            CloseableImage image = imageReference.get();
                            if (image != null && image instanceof CloseableStaticBitmap) {
                                CloseableStaticBitmap closeableStaticBitmap = (CloseableStaticBitmap) image;
                                Bitmap bitmap = closeableStaticBitmap.getUnderlyingBitmap();
                                if (bitmap != null) {
                                    setimageBitmap(bitmap);
                                }
                            }
                        }
                    } finally {
                        dataSource.close();
                        CloseableReference.closeSafely(imageReference);
                    }
                }
            })
            .setTapToRetryEnabled(true)
            .build();
    mDraweeHolder.setController(controller);
}
项目:fresco    文件:FrescoFrameCache.java   
@Nullable
private static CloseableReference<CloseableImage> createImageReference(
    CloseableReference<Bitmap> bitmapReference) {
  // The given CloseableStaticBitmap will be cached and then released by the resource releaser
  // of the closeable reference
  CloseableImage closeableImage =
      new CloseableStaticBitmap(bitmapReference,0);
  return CloseableReference.of(closeableImage);
}
项目:fresco    文件:AnimatedImageFactoryImpl.java   
private CloseableImage getCloseableImage(
    ImageDecodeOptions options,frameForPreview);
    }
    AnimatedImageResult animatedImageResult = AnimatedImageResult.newBuilder(image)
        .setPreviewBitmap(previewBitmap)
        .setFrameForPreview(frameForPreview)
        .setDecodedFrames(decodedFrames)
        .build();
    return new CloseableAnimatedImage(animatedImageResult);
  } finally {
    CloseableReference.closeSafely(previewBitmap);
    CloseableReference.closeSafely(decodedFrames);
  }
}
项目:fresco    文件:AnimatedSingleUsePostprocessorProducerTest.java   
@Before
public void setUp() {
  MockitoAnnotations.initMocks(this);
  mTestExecutorService = new TestExecutorService(new FakeClock());
  mPostprocessorProducer =
      new PostprocessorProducer(
          mInputProducer,mBitmapResourceReleaser);
}
项目:fresco    文件:AnimatedRepeatedPostprocessorProducerTest.java   
private void setupNewSourceImage() {
  mSourceBitmap = mock(Bitmap.class);
  mSourceCloseableStaticBitmap = mock(CloseableStaticBitmap.class);
  when(mSourceCloseableStaticBitmap.getUnderlyingBitmap()).thenReturn(mSourceBitmap);
  mSourceCloseableImageRef =
      CloseableReference.<CloseableImage>of(mSourceCloseableStaticBitmap);
}
项目:fresco    文件:PostprocessorProducer.java   
private CloseableReference<CloseableImage> postprocessInternal(CloseableImage sourceImage) {
  CloseableStaticBitmap staticBitmap = (CloseableStaticBitmap) sourceImage;
  Bitmap sourceBitmap = staticBitmap.getUnderlyingBitmap();
  CloseableReference<Bitmap> bitmapRef = mPostprocessor.process(sourceBitmap,exifOrientation));
  } finally {
    CloseableReference.closeSafely(bitmapRef);
  }
}
项目:fresco    文件:BitmapPrepareProducer.java   
private void internalPrepareBitmap(CloseableReference<CloseableImage> newResult) {
  if (newResult == null || !newResult.isValid()) {
    return;
  }

  final CloseableImage closeableImage = newResult.get();
  if (closeableImage == null || closeableImage.isClosed()) {
    return;
  }

  if (closeableImage instanceof CloseableStaticBitmap) {
    final CloseableStaticBitmap staticBitmap = (CloseableStaticBitmap) closeableImage;
    final Bitmap bitmap = staticBitmap.getUnderlyingBitmap();
    if (bitmap == null) {
      return;
    }

    final int bitmapByteCount = bitmap.getRowBytes() * bitmap.getHeight();
    if (bitmapByteCount < mMinBitmapSizeBytes) {
      return;
    }
    if (bitmapByteCount > mMaxBitmapSizeBytes) {
      return;
    }

    bitmap.preparetoDraw();
  }
}
项目:fresco    文件:SingleUsePostprocessorProducerTest.java   
@Before
public void setUp() {
  MockitoAnnotations.initMocks(this);
  mTestExecutorService = new TestExecutorService(new FakeClock());
  mPostprocessorProducer =
      new PostprocessorProducer(
          mInputProducer,mBitmapResourceReleaser);
}
项目:fresco    文件:RepeatedPostprocessorProducerTest.java   
private void setupNewSourceImage() {
  mSourceBitmap = mock(Bitmap.class);
  mSourceCloseableStaticBitmap = mock(CloseableStaticBitmap.class);
  when(mSourceCloseableStaticBitmap.getUnderlyingBitmap()).thenReturn(mSourceBitmap);
  mSourceCloseableImageRef =
      CloseableReference.<CloseableImage>of(mSourceCloseableStaticBitmap);
}
项目:GitHub    文件:PipelineDraweeController.java   
private static boolean hasTransformableRotationAngle(
    CloseableStaticBitmap closeableStaticBitmap) {
  return closeableStaticBitmap.getRotationAngle() != 0
      && closeableStaticBitmap.getRotationAngle() != EncodedImage.UNKNowN_ROTATION_ANGLE;
}

今天的关于com.facebook.react.uimanager.CatalystStylesDiffMap的实例源码react useeffect 源码的分享已经结束,谢谢您的关注,如果想了解更多关于com.facebook.imagepipeline.cache.ImageCacheStatsTracker的实例源码、com.facebook.imagepipeline.image.CloseableAnimatedImage的实例源码、com.facebook.imagepipeline.image.CloseableBitmap的实例源码、com.facebook.imagepipeline.image.CloseableStaticBitmap的实例源码的相关知识,请在本站进行查询。

本文标签: