Search in sources :

Example 61 with ResizeOptions

use of com.facebook.imagepipeline.common.ResizeOptions in project android-client by GenesisVision.

the class ProgramLogoView method setImage.

public void setImage(String imageId, String programColorHex, int width, int height) {
    if (imageId == null || imageId.isEmpty()) {
        GenericDraweeHierarchy hierarchy = image.getHierarchy();
        hierarchy.setBackgroundImage(new ColorDrawable(Color.parseColor(programColorHex)));
        image.setHierarchy(hierarchy);
        image.setImageURI("");
        return;
    }
    ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(ImageUtils.getImageUri(imageId))).setResizeOptions(new ResizeOptions(width, height)).build();
    PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder().setOldController(image.getController()).setImageRequest(request).build();
    image.setController(controller);
}
Also used : PipelineDraweeController(com.facebook.drawee.backends.pipeline.PipelineDraweeController) ColorDrawable(android.graphics.drawable.ColorDrawable) GenericDraweeHierarchy(com.facebook.drawee.generic.GenericDraweeHierarchy) ResizeOptions(com.facebook.imagepipeline.common.ResizeOptions) ImageRequest(com.facebook.imagepipeline.request.ImageRequest)

Example 62 with ResizeOptions

use of com.facebook.imagepipeline.common.ResizeOptions in project android-client by GenesisVision.

the class ProgramDetailsActivity method updateHeader.

private void updateHeader() {
    GenericDraweeHierarchy hierarchy = programLogo.getHierarchy();
    hierarchy.setBackgroundImage(new ColorDrawable(Color.parseColor(model.getProgramColor())));
    programLogo.setHierarchy(hierarchy);
    if (model.getAvatar() != null && !model.getAvatar().isEmpty()) {
        ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(ImageUtils.getImageUri(model.getAvatar()))).setResizeOptions(new ResizeOptions(300, 300)).build();
        PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder().setOldController(programLogo.getController()).setImageRequest(request).build();
        programLogo.setController(controller);
    }
    toolbarProgramLogo.setImage(model.getAvatar(), model.getProgramColor(), 50, 50);
    toolbarProgramLogo.hideLevel();
    int level = model.getLevel();
    if (level > 0) {
        this.levelGroup.setVisibility(View.VISIBLE);
        this.level.setText(String.valueOf(level));
        int[] levelColors = getResources().getIntArray(R.array.levelColors);
        if (level > levelColors.length) {
            level = levelColors.length;
        }
        levelColor.setColorFilter(levelColors[level - 1]);
        levelProgress.setProgress(model.getLevelProgress().intValue());
    } else {
        this.levelGroup.setVisibility(View.GONE);
    }
    programName.setText(model.getProgramName());
    toolbarProgramName.setText(model.getProgramName());
    setTags();
    setNotificationsButtonImage(model.isHasNotifications());
    setFavoriteButtonImage(model.isFavorite());
}
Also used : PipelineDraweeController(com.facebook.drawee.backends.pipeline.PipelineDraweeController) ColorDrawable(android.graphics.drawable.ColorDrawable) GenericDraweeHierarchy(com.facebook.drawee.generic.GenericDraweeHierarchy) ResizeOptions(com.facebook.imagepipeline.common.ResizeOptions) ImageRequest(com.facebook.imagepipeline.request.ImageRequest)

Example 63 with ResizeOptions

use of com.facebook.imagepipeline.common.ResizeOptions in project android-client by GenesisVision.

the class FundDetailsActivity method updateHeader.

private void updateHeader() {
    GenericDraweeHierarchy hierarchy = fundLogo.getHierarchy();
    hierarchy.setBackgroundImage(new ColorDrawable(Color.parseColor(model.getFundColor())));
    fundLogo.setHierarchy(hierarchy);
    if (model.getLogo() != null && !model.getLogo().isEmpty()) {
        ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(ImageUtils.getImageUri(model.getLogo()))).setResizeOptions(new ResizeOptions(300, 300)).build();
        PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder().setOldController(fundLogo.getController()).setImageRequest(request).build();
        fundLogo.setController(controller);
    }
    toolbarFundLogo.setImage(model.getLogo(), model.getFundColor(), 50, 50);
    toolbarFundLogo.hideLevel();
    fundName.setText(model.getFundName());
    toolbarFundName.setText(model.getFundName());
    setNotificationsButtonImage(model.isHasNotifications());
    setFavoriteButtonImage(model.isFavorite());
}
Also used : PipelineDraweeController(com.facebook.drawee.backends.pipeline.PipelineDraweeController) ColorDrawable(android.graphics.drawable.ColorDrawable) GenericDraweeHierarchy(com.facebook.drawee.generic.GenericDraweeHierarchy) ResizeOptions(com.facebook.imagepipeline.common.ResizeOptions) ImageRequest(com.facebook.imagepipeline.request.ImageRequest)

Aggregations

ResizeOptions (com.facebook.imagepipeline.common.ResizeOptions)63 ImageRequest (com.facebook.imagepipeline.request.ImageRequest)31 Uri (android.net.Uri)12 Test (org.junit.Test)11 DraweeController (com.facebook.drawee.interfaces.DraweeController)10 PipelineDraweeController (com.facebook.drawee.backends.pipeline.PipelineDraweeController)9 ImageRequestBuilder (com.facebook.imagepipeline.request.ImageRequestBuilder)7 GenericDraweeHierarchy (com.facebook.drawee.generic.GenericDraweeHierarchy)6 File (java.io.File)5 PipelineDraweeControllerBuilder (com.facebook.drawee.backends.pipeline.PipelineDraweeControllerBuilder)4 ColorDrawable (android.graphics.drawable.ColorDrawable)3 Drawable (android.graphics.drawable.Drawable)3 CloseableReference (com.facebook.common.references.CloseableReference)3 EncodedImage (com.facebook.imagepipeline.image.EncodedImage)3 FileSystemReference (im.actor.runtime.files.FileSystemReference)3 Context (android.content.Context)2 Canvas (android.graphics.Canvas)2 Point (android.graphics.Point)2 Animatable (android.graphics.drawable.Animatable)2 View (android.view.View)2