Search in sources :

Example 11 with ImageRequest

use of com.facebook.imagepipeline.request.ImageRequest in project actor-platform by actorapp.

the class AvatarView method bind.

public void bind(Avatar avatar, String title, int id) {
    // Same avatar
    if (avatar != null && getImage(avatar) != null && getImage(avatar).getFileReference().getFileId() == currentId) {
        return;
    }
    getHierarchy().setPlaceholderImage(new AvatarPlaceholderDrawable(title, id, placeholderTextSize, getContext()));
    if (bindedFile != null) {
        bindedFile.detach();
        bindedFile = null;
    }
    setImageURI(null);
    if (avatar == null || getImage(avatar) == null) {
        currentId = 0;
        return;
    }
    currentId = getImage(avatar).getFileReference().getFileId();
    bindedFile = messenger().bindFile(getImage(avatar).getFileReference(), true, new FileVMCallback() {

        @Override
        public void onNotDownloaded() {
        }

        @Override
        public void onDownloading(float progress) {
        }

        @Override
        public void onDownloaded(FileSystemReference reference) {
            ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.fromFile(new File(reference.getDescriptor()))).setResizeOptions(new ResizeOptions(size, size)).build();
            PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder().setOldController(getController()).setImageRequest(request).build();
            setController(controller);
        }
    });
}
Also used : FileSystemReference(im.actor.runtime.files.FileSystemReference) PipelineDraweeController(com.facebook.drawee.backends.pipeline.PipelineDraweeController) ResizeOptions(com.facebook.imagepipeline.common.ResizeOptions) ImageRequest(com.facebook.imagepipeline.request.ImageRequest) File(java.io.File) FileVMCallback(im.actor.core.viewmodel.FileVMCallback)

Example 12 with ImageRequest

use of com.facebook.imagepipeline.request.ImageRequest in project actor-platform by actorapp.

the class CallBackgroundAvatarView method bindRaw.

public void bindRaw(String fileName) {
    if (bindedFile != null) {
        bindedFile.detach();
        bindedFile = null;
    }
    currentId = 0;
    ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.fromFile(new File(fileName))).setAutoRotateEnabled(true).build();
    PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder().setOldController(getController()).setImageRequest(request).build();
    setController(controller);
}
Also used : PipelineDraweeController(com.facebook.drawee.backends.pipeline.PipelineDraweeController) ImageRequest(com.facebook.imagepipeline.request.ImageRequest) File(java.io.File)

Example 13 with ImageRequest

use of com.facebook.imagepipeline.request.ImageRequest in project actor-platform by actorapp.

the class BackgroundPreviewView method bind.

public void bind(int i) {
    if (i != BACKGROUNDS.length) {
        int bkgrnd = getBackground(i);
        Uri uri = new Uri.Builder().scheme(UriUtil.LOCAL_RESOURCE_SCHEME).path(String.valueOf(bkgrnd)).build();
        ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri).setResizeOptions(new ResizeOptions(width, height)).build();
        PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder().setOldController(getController()).setImageRequest(request).build();
        setController(controller);
    } else {
        if (BaseActorSettingsFragment.getWallpaperFile() != null) {
            File customWallpaper = new File(BaseActorSettingsFragment.getWallpaperFile());
            if (!customWallpaper.exists()) {
                return;
            }
            Uri uri = Uri.fromFile(customWallpaper);
            ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri).setResizeOptions(new ResizeOptions(width, height)).build();
            PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder().setOldController(getController()).setImageRequest(request).build();
            setController(controller);
        }
    }
}
Also used : PipelineDraweeController(com.facebook.drawee.backends.pipeline.PipelineDraweeController) ResizeOptions(com.facebook.imagepipeline.common.ResizeOptions) ImageRequest(com.facebook.imagepipeline.request.ImageRequest) Uri(android.net.Uri) File(java.io.File)

Example 14 with ImageRequest

use of com.facebook.imagepipeline.request.ImageRequest in project fresco by facebook.

the class ImagePipelineConfigTest method testImageRequestWhenChangedAndOverriden.

@Test
public void testImageRequestWhenChangedAndOverriden() {
    ImagePipelineConfig.resetDefaultRequestConfig();
    final ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(mUri).setProgressiveRenderingEnabled(true).build();
    assertTrue(imageRequest.getProgressiveRenderingEnabled());
    final ImageRequest imageRequest2 = ImageRequestBuilder.newBuilderWithSource(mUri).setProgressiveRenderingEnabled(false).build();
    assertFalse(imageRequest2.getProgressiveRenderingEnabled());
}
Also used : ImageRequest(com.facebook.imagepipeline.request.ImageRequest) Test(org.junit.Test)

Example 15 with ImageRequest

use of com.facebook.imagepipeline.request.ImageRequest in project fresco by facebook.

the class ImagePipelineConfigTest method testImageRequestDefault.

@Test
public void testImageRequestDefault() {
    ImagePipelineConfig.resetDefaultRequestConfig();
    final ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(mUri).build();
    assertFalse(imageRequest.getProgressiveRenderingEnabled());
}
Also used : ImageRequest(com.facebook.imagepipeline.request.ImageRequest) Test(org.junit.Test)

Aggregations

ImageRequest (com.facebook.imagepipeline.request.ImageRequest)62 DraweeController (com.facebook.drawee.interfaces.DraweeController)20 ResizeOptions (com.facebook.imagepipeline.common.ResizeOptions)17 CloseableReference (com.facebook.common.references.CloseableReference)14 Uri (android.net.Uri)10 File (java.io.File)10 Bitmap (android.graphics.Bitmap)9 CacheKey (com.facebook.cache.common.CacheKey)9 ImagePipeline (com.facebook.imagepipeline.core.ImagePipeline)8 BaseBitmapDataSubscriber (com.facebook.imagepipeline.datasource.BaseBitmapDataSubscriber)8 PipelineDraweeController (com.facebook.drawee.backends.pipeline.PipelineDraweeController)7 DataSource (com.facebook.datasource.DataSource)6 EncodedImage (com.facebook.imagepipeline.image.EncodedImage)5 Animatable (android.graphics.drawable.Animatable)4 Nullable (android.support.annotation.Nullable)4 BaseControllerListener (com.facebook.drawee.controller.BaseControllerListener)4 ImageInfo (com.facebook.imagepipeline.image.ImageInfo)4 QualityInfo (com.facebook.imagepipeline.image.QualityInfo)4 FileSystemReference (im.actor.runtime.files.FileSystemReference)4 Test (org.junit.Test)4