Search in sources :

Example 1 with PipelineDraweeController

use of com.facebook.drawee.backends.pipeline.PipelineDraweeController in project actor-platform by actorapp.

the class PhotoHolder method bindImage.

public void bindImage(Uri uri) {
    ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri).setResizeOptions(new ResizeOptions(previewView.getLayoutParams().width, previewView.getLayoutParams().height)).build();
    PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder().setOldController(previewView.getController()).setImageRequest(request).setControllerListener(animationController).build();
    previewView.setController(controller);
}
Also used : PipelineDraweeController(com.facebook.drawee.backends.pipeline.PipelineDraweeController) ResizeOptions(com.facebook.imagepipeline.common.ResizeOptions) ImageRequest(com.facebook.imagepipeline.request.ImageRequest)

Example 2 with PipelineDraweeController

use of com.facebook.drawee.backends.pipeline.PipelineDraweeController 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 3 with PipelineDraweeController

use of com.facebook.drawee.backends.pipeline.PipelineDraweeController 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 4 with PipelineDraweeController

use of com.facebook.drawee.backends.pipeline.PipelineDraweeController 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 5 with PipelineDraweeController

use of com.facebook.drawee.backends.pipeline.PipelineDraweeController in project actor-platform by actorapp.

the class StickerView method bind.

public void bind(FileReference fileReference, int size) {
    if (this.fileReference != null && this.fileReference.equals(fileReference)) {
        return;
    }
    if (bindedFile != null) {
        bindedFile.detach();
        bindedFile = null;
    }
    setImageURI(null);
    this.fileReference = fileReference;
    bindedFile = messenger().bindFile(fileReference, true, new FileVMCallback() {

        private boolean isFastThumbLoaded = false;

        private void checkFastThumb() {
            if (!isFastThumbLoaded) {
                isFastThumbLoaded = true;
            // if (sticker.getThumb() != null) {
            // fastThumbLoader.request(sticker.getThumb());
            // }
            }
        }

        @Override
        public void onNotDownloaded() {
            checkFastThumb();
        }

        @Override
        public void onDownloading(float progress) {
            checkFastThumb();
        }

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

Aggregations

PipelineDraweeController (com.facebook.drawee.backends.pipeline.PipelineDraweeController)7 ImageRequest (com.facebook.imagepipeline.request.ImageRequest)7 File (java.io.File)6 ResizeOptions (com.facebook.imagepipeline.common.ResizeOptions)5 FileVMCallback (im.actor.core.viewmodel.FileVMCallback)3 FileSystemReference (im.actor.runtime.files.FileSystemReference)3 Uri (android.net.Uri)1 BaseActivity (im.actor.sdk.controllers.activity.BaseActivity)1 FastThumbLoader (im.actor.sdk.controllers.conversation.view.FastThumbLoader)1