com.facebook.drawee.drawable.ScalingUtils Java Examples

The following examples show how to use com.facebook.drawee.drawable.ScalingUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ImagePageViewAdapter.java    From imsdk-android with MIT License 6 votes vote down vote up
@Override
    public Object instantiateItem(ViewGroup container,int position)
    {
        IBrowsingConversationImageView.PreImage data = datas.get(position);
        ZoomableDraweeView mImageView = new ZoomableDraweeView(context);
        final DraweeController ctrl = Fresco.newDraweeControllerBuilder()
                .setImageRequest(ImageRequest.fromUri(data.originUrl))
                .setLowResImageRequest(ImageRequest.fromUri(data.smallUrl))
                .setTapToRetryEnabled(false).setAutoPlayAnimations(true).build();

        GenericDraweeHierarchyBuilder hierarchyBuilder = new GenericDraweeHierarchyBuilder(
                context.getResources())
                .setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER)
                .setProgressBarImage(new ProgressBarDrawable());

        mImageView.setHierarchy(hierarchyBuilder.build());
        mImageView.setController(ctrl);
        mImageView.setOnCreateContextMenuListener(listener);
//        mImageView.setOnClickListener(onClickListener);
        mImageView.setOnTouchListener(onTouchListener);
        viewSparseArray.append(position,mImageView);
        container.addView(mImageView);
        return mImageView;
    }
 
Example #2
Source File: Attacher.java    From CanPhotos with Apache License 2.0 6 votes vote down vote up
public Attacher(DraweeView<GenericDraweeHierarchy> draweeView) {
    mDraweeView = new WeakReference<>(draweeView);
    draweeView.getHierarchy().setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER);
    draweeView.setOnTouchListener(this);
    mScaleDragDetector = new ScaleDragDetector(draweeView.getContext(), this);
    mGestureDetector = new GestureDetectorCompat(draweeView.getContext(),
            new GestureDetector.SimpleOnGestureListener() {
                @Override public void onLongPress(MotionEvent e) {
                    super.onLongPress(e);
                    if (null != mLongClickListener) {
                        mLongClickListener.onLongClick(getDraweeView());
                    }
                }
            });
    mGestureDetector.setOnDoubleTapListener(new DefaultOnDoubleTapListener(this));
}
 
Example #3
Source File: Attacher.java    From PicKing with Apache License 2.0 6 votes vote down vote up
public Attacher(DraweeView<GenericDraweeHierarchy> draweeView) {
    mDraweeView = new WeakReference<>(draweeView);
    draweeView.getHierarchy().setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER);
    draweeView.setOnTouchListener(this);
    mScaleDragDetector = new ScaleDragDetector(draweeView.getContext(), this);
    mGestureDetector = new GestureDetectorCompat(draweeView.getContext(),
            new GestureDetector.SimpleOnGestureListener() {
                @Override public void onLongPress(MotionEvent e) {
                    super.onLongPress(e);
                    if (null != mLongClickListener) {
                        mLongClickListener.onLongClick(getDraweeView());
                    }
                }
            });
    mGestureDetector.setOnDoubleTapListener(new DefaultOnDoubleTapListener(this));
}
 
Example #4
Source File: ShapedDraweeView.java    From AndroidPlayground with MIT License 6 votes vote down vote up
private void setup(Context context, AttributeSet attrs, int defStyle) {
    if (getScaleType() == ScaleType.FIT_CENTER) {
        setScaleType(ScaleType.CENTER_CROP);
    }

    Drawable placeholder = null;
    if (attrs != null) {
        TypedArray typedArray =
                context.obtainStyledAttributes(attrs, R.styleable.ShapedDrawee, defStyle, 0);
        shape = typedArray.getDrawable(R.styleable.ShapedDrawee_maskShape);
        placeholder = typedArray.getDrawable(R.styleable.ShapedDrawee_placeholder);
        typedArray.recycle();
    }
    if (shape == null) {
        throw new IllegalArgumentException("maskShape must be specified in layout!");
    }

    GenericDraweeHierarchy hierarchy =
            new GenericDraweeHierarchyBuilder(getResources()).setPlaceholderImage(placeholder)
                    .setPlaceholderImageScaleType(ScalingUtils.ScaleType.CENTER_CROP)
                    .setActualImageScaleType(ScalingUtils.ScaleType.CENTER_CROP)
                    .build();
    mDraweeHolder = DraweeHolder.create(hierarchy, getContext());
}
 
Example #5
Source File: ViewPagerActivity.java    From ZoomableDraweeView-sample with Apache License 2.0 6 votes vote down vote up
@Override
public Object instantiateItem(ViewGroup container, int position) {
    ZoomableDraweeView view = new ZoomableDraweeView(container.getContext());
    view.setController(
            Fresco.newDraweeControllerBuilder()
                    .setUri(Uri.parse(items[position]))
                    .build());

    GenericDraweeHierarchy hierarchy =
            new GenericDraweeHierarchyBuilder(container.getResources())
                    .setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER)
                    .setProgressBarImage(new ProgressBarDrawable())
                    .build();

    view.setHierarchy(hierarchy);

    container.addView(view,
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

    return view;
}
 
Example #6
Source File: ImageResizeModeTest.java    From react-native-GPay with MIT License 6 votes vote down vote up
@Test
public void testImageResizeMode() {
  assertThat(ImageResizeMode.toScaleType(null))
      .isEqualTo(ScalingUtils.ScaleType.CENTER_CROP);

  assertThat(ImageResizeMode.toScaleType("contain"))
      .isEqualTo(ScalingUtils.ScaleType.FIT_CENTER);

  assertThat(ImageResizeMode.toScaleType("cover"))
      .isEqualTo(ScalingUtils.ScaleType.CENTER_CROP);

  assertThat(ImageResizeMode.toScaleType("stretch"))
      .isEqualTo(ScalingUtils.ScaleType.FIT_XY);

  assertThat(ImageResizeMode.toScaleType("center"))
      .isEqualTo(ScalingUtils.ScaleType.CENTER_INSIDE);

  // No resizeMode set
  assertThat(ImageResizeMode.defaultValue())
      .isEqualTo(ScalingUtils.ScaleType.CENTER_CROP);
}
 
Example #7
Source File: CoverAvatarView.java    From actor-platform with GNU Affero General Public License v3.0 6 votes vote down vote up
private void init() {

        if (isInEditMode()) {
            return;
        }

        GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(getResources());

        builder.setActualImageScaleType(ScalingUtils.ScaleType.CENTER_CROP);
        builder.setOverlay(new CoverOverlayDrawable(getContext()));

        if (ActorSDK.sharedActor().style.getAvatarBackgroundResourse() != 0) {
            builder.setPlaceholderImage(getResources()
                    .getDrawable(ActorSDK.sharedActor().style.getAvatarBackgroundResourse()), ScalingUtils.ScaleType.CENTER_CROP);
        } else {
            builder.setPlaceholderImage(new ColorDrawable(
                    ActorSDK.sharedActor().style.getAvatarBackgroundColor()));
        }

        builder.setFadeDuration(0);

        setHierarchy(builder.build());
    }
 
Example #8
Source File: BigImageLoader.java    From ImageLoader with Apache License 2.0 6 votes vote down vote up
@Override
public View showThumbnail(BigImageView parent, Uri thumbnail, int scaleType) {
    SimpleDraweeView thumbnailView = (SimpleDraweeView) LayoutInflater.from(parent.getContext())
            .inflate(R.layout.ui_fresco_thumbnail, parent, false);
    DraweeController controller = Fresco.newDraweeControllerBuilder()
            .setUri(thumbnail)
            .build();
    switch (scaleType) {
        case BigImageView.INIT_SCALE_TYPE_CENTER_CROP:
            thumbnailView.getHierarchy()
                    .setActualImageScaleType(ScalingUtils.ScaleType.CENTER_CROP);
            break;
        case BigImageView.INIT_SCALE_TYPE_CENTER_INSIDE:
            thumbnailView.getHierarchy()
                    .setActualImageScaleType(ScalingUtils.ScaleType.CENTER_INSIDE);
        default:
            break;
    }
    thumbnailView.setController(controller);
    return thumbnailView;
}
 
Example #9
Source File: HierarcherImplTest.java    From fresco with MIT License 6 votes vote down vote up
@Test
public void testBuildErrorDrawable_whenScaleTypeSet_thenReturnScaleTypeDrawable() {
  PointF focusPoint = new PointF(100, 234);
  ImageOptions options =
      ImageOptions.create()
          .errorRes(RES_ID)
          .errorScaleType(ScalingUtils.ScaleType.FOCUS_CROP)
          .errorFocusPoint(focusPoint)
          .build();

  Drawable errorDrawable = mHierarcher.buildErrorDrawable(mResources, options);

  assertThat(errorDrawable).isNotNull();
  assertThat(errorDrawable).isInstanceOf(ScaleTypeDrawable.class);

  ScaleTypeDrawable scaleTypeDrawable = (ScaleTypeDrawable) errorDrawable;
  assertThat(scaleTypeDrawable.getScaleType()).isEqualTo(ScalingUtils.ScaleType.FOCUS_CROP);
  assertThat(scaleTypeDrawable.getFocusPoint()).isEqualTo(focusPoint);
  assertThat(scaleTypeDrawable.getCurrent()).isEqualTo(mDrawable);
}
 
Example #10
Source File: FrescoUtil.java    From ImageLoader with Apache License 2.0 5 votes vote down vote up
public static ScalingUtils.ScaleType getActualScaleType(int scaleMode){
    switch (scaleMode){
        case ScaleMode.CENTER_CROP:
            return ScalingUtils.ScaleType.CENTER_CROP;

        case ScaleMode.CENTER_INSIDE:
            return ScalingUtils.ScaleType.CENTER_INSIDE;

        case ScaleMode.FIT_CENTER:
            return ScalingUtils.ScaleType.FIT_CENTER;

        case ScaleMode.FIT_XY:
            return ScalingUtils.ScaleType.FIT_XY;

        case ScaleMode.FIT_END:
            return ScalingUtils.ScaleType.FIT_END;

        case ScaleMode.FOCUS_CROP:
            return ScalingUtils.ScaleType.FOCUS_CROP;

        case ScaleMode.CENTER:
            return ScalingUtils.ScaleType.CENTER;

        case ScaleMode.FIT_START:
            return ScalingUtils.ScaleType.FIT_START;

        default:
            return ScalingUtils.ScaleType.CENTER_CROP;

    }
}
 
Example #11
Source File: FrescoController.java    From base-module with Apache License 2.0 5 votes vote down vote up
public ImageConfigStep allScaleType(ScalingUtils.ScaleType scaleType) {
    mImageConfig.actualScaleType = scaleType;
    mImageConfig.placeholderScaleType = scaleType;
    mImageConfig.retryScaleType = scaleType;
    mImageConfig.failureScaleType = scaleType;
    mImageConfig.progressBarScaleType = scaleType;
    return this;
}
 
Example #12
Source File: ZoomableDraweeView.java    From fresco with MIT License 5 votes vote down vote up
protected void inflateHierarchy(Context context, @Nullable AttributeSet attrs) {
  Resources resources = context.getResources();
  GenericDraweeHierarchyBuilder builder =
      new GenericDraweeHierarchyBuilder(resources)
          .setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER);
  GenericDraweeHierarchyInflater.updateBuilder(builder, context, attrs);
  setAspectRatio(builder.getDesiredAspectRatio());
  setHierarchy(builder.build());
}
 
Example #13
Source File: ImageDetailsActivity.java    From fresco with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_drawee_transition_detail);

  ActionBar actionBar = getSupportActionBar();
  if (actionBar != null) {
    actionBar.setDisplayHomeAsUpEnabled(true);
  }

  SimpleDraweeView simpleDraweeView = (SimpleDraweeView) findViewById(R.id.image);
  simpleDraweeView.setImageURI(getIntent().getData());

  ScalingUtils.ScaleType toScaleType = ScalingUtils.ScaleType.FOCUS_CROP;
  PointF toFocusPoint = new PointF(0.5f, 0);

  simpleDraweeView.getHierarchy().setActualImageScaleType(toScaleType);
  simpleDraweeView.getHierarchy().setActualImageFocusPoint(toFocusPoint);

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    ScalingUtils.ScaleType fromScaleType = ScalingUtils.ScaleType.FOCUS_CROP;
    PointF fromFocusPoint = DraweeTransitionFragment.FOCUS_POINT;

    getWindow()
        .setSharedElementEnterTransition(
            DraweeTransition.createTransitionSet(
                fromScaleType, toScaleType, fromFocusPoint, toFocusPoint));
    getWindow()
        .setSharedElementReturnTransition(
            DraweeTransition.createTransitionSet(
                toScaleType, fromScaleType, toFocusPoint, fromFocusPoint));
  }
}
 
Example #14
Source File: ShareLocationActivity.java    From imsdk-android with MIT License 5 votes vote down vote up
private SimpleDraweeView createDraweeView() {
    SimpleDraweeView view = new SimpleDraweeView(this);
    RoundingParams params = RoundingParams.asCircle();
    view.setLayoutParams(new ViewGroup.LayoutParams(Utils.dpToPx(this, 48), Utils.dpToPx(this, 48)));
    GenericDraweeHierarchy hierarchy = GenericDraweeHierarchyBuilder.newInstance(getResources())
            .setPlaceholderImage(getResources().getDrawable(R.drawable.atom_ui_default_gravatar), ScalingUtils.ScaleType.CENTER_CROP)
            .setRoundingParams(params)
            .build();
    view.setHierarchy(hierarchy);
    return view;
}
 
Example #15
Source File: ImageLoaderManager.java    From AdPlayBanner with Apache License 2.0 5 votes vote down vote up
/**
 * Fresco设置ScaleType
 * @param context     上下文
 * @param mFrescoView 图片
 */
private void frescoViewSetScaleType(Context context, SimpleDraweeView mFrescoView){
    if (context == null || mFrescoView == null) {
        return;
    }
    GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(context.getResources());
    GenericDraweeHierarchy hierarchy = builder.build();
    mFrescoView.setHierarchy(hierarchy);
    switch (mScaleType) {
        default:
        case FIT_XY:
            hierarchy.setActualImageScaleType(ScalingUtils.ScaleType.FIT_XY);
            break;
        case FIT_START:
            hierarchy.setActualImageScaleType(ScalingUtils.ScaleType.FIT_START);
            break;
        case FIT_CENTER:
            hierarchy.setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER);
            break;
        case FIT_END:
            hierarchy.setActualImageScaleType(ScalingUtils.ScaleType.FIT_END);
            break;
        case CENTER:
            hierarchy.setActualImageScaleType(ScalingUtils.ScaleType.CENTER);
            break;
        case CENTER_CROP:
            hierarchy.setActualImageScaleType(ScalingUtils.ScaleType.CENTER_CROP);
            break;
        case CENTER_INSIDE:
            hierarchy.setActualImageScaleType(ScalingUtils.ScaleType.CENTER_INSIDE);
            break;
    }
}
 
Example #16
Source File: GenericDraweeHierarchy.java    From fresco with MIT License 5 votes vote down vote up
/** Applies scale type and rounding (both if specified). */
@Nullable
private Drawable buildBranch(
    @Nullable Drawable drawable, @Nullable ScalingUtils.ScaleType scaleType) {
  drawable = WrappingUtils.maybeApplyLeafRounding(drawable, mRoundingParams, mResources);
  drawable = WrappingUtils.maybeWrapWithScaleType(drawable, scaleType);
  return drawable;
}
 
Example #17
Source File: DebugControllerOverlayDrawableTestHelper.java    From fresco with MIT License 5 votes vote down vote up
public void assertOverlayColorAlmostOk(
    int imageWidth,
    int imageHeight,
    int drawableWidth,
    int drawableHeight,
    ScalingUtils.ScaleType scaleType) {
  mOverlayDrawable.setBounds(0, 0, drawableWidth, drawableHeight);
  assertEquals(
      DebugControllerOverlayDrawable.TEXT_COLOR_IMAGE_ALMOST_OK,
      mOverlayDrawable.determineSizeHintColor(imageWidth, imageHeight, scaleType));
}
 
Example #18
Source File: GenericDraweeHierarchy.java    From fresco with MIT License 5 votes vote down vote up
@Nullable
private Drawable buildActualImageBranch(
    Drawable drawable,
    @Nullable ScalingUtils.ScaleType scaleType,
    @Nullable PointF focusPoint,
    @Nullable ColorFilter colorFilter) {
  drawable.setColorFilter(colorFilter);
  drawable = WrappingUtils.maybeWrapWithScaleType(drawable, scaleType, focusPoint);
  return drawable;
}
 
Example #19
Source File: ImagePreFragment.java    From SprintNBA with Apache License 2.0 5 votes vote down vote up
private void initImage() {
    PipelineDraweeControllerBuilder controller = FrescoUtils.getPreController(url, pdvImage);
    controller.setControllerListener(listener);
    final GenericDraweeHierarchy hierarchy = new GenericDraweeHierarchyBuilder(getResources())
            .setProgressBarImage(new ImageLoadProgressBar(new ImageLoadProgressBar.OnLevelChangeListener() {
                @Override
                public void onChange(int level) {
                    if (level >= 100) {
                        hideLoadingDialog();
                    }
                }
            }, Color.parseColor("#90CCCCCC"))).build();
    hierarchy.setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER);
    pdvImage.setHierarchy(hierarchy);
    pdvImage.setController(controller.build());
    pdvImage.setOnPhotoTapListener(new OnPhotoTapListener() {
        @Override
        public void onPhotoTap(View view, float x, float y) {
            if (mActivity != null)
                mActivity.finish();
        }
    });
    pdvImage.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {

            return true;
        }
    });
}
 
Example #20
Source File: DebugControllerOverlayDrawableTestHelper.java    From fresco with MIT License 5 votes vote down vote up
public void assertOverlayColorNotOk(
    int imageWidth,
    int imageHeight,
    int drawableWidth,
    int drawableHeight,
    ScalingUtils.ScaleType scaleType) {
  mOverlayDrawable.setBounds(0, 0, drawableWidth, drawableHeight);
  assertEquals(
      DebugControllerOverlayDrawable.TEXT_COLOR_IMAGE_NOT_OK,
      mOverlayDrawable.determineSizeHintColor(imageWidth, imageHeight, scaleType));
}
 
Example #21
Source File: FrescoAdapter.java    From ImageLoadPK with Apache License 2.0 5 votes vote down vote up
@Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        GenericDraweeHierarchy genericDraweeHierarchy = new GenericDraweeHierarchyBuilder(getContext().getResources())
                .setPlaceholderImage(Drawables.sPlaceholderDrawable)
                .setFailureImage(Drawables.sErrorDrawable)
//                .setProgressBarImage(new ProgressBarDrawable())
                .setActualImageScaleType(ScalingUtils.ScaleType.CENTER_CROP)
                .build();
        WatchDraweeImage watchDraweeImage = new WatchDraweeImage(getContext(), genericDraweeHierarchy);
        return new FrescoHolder(watchDraweeImage, getWatchListener(), parent, getContext());
    }
 
Example #22
Source File: DraweeTransition.java    From fresco with MIT License 5 votes vote down vote up
public DraweeTransition(
    ScalingUtils.ScaleType fromScale,
    ScalingUtils.ScaleType toScale,
    @Nullable PointF fromFocusPoint,
    @Nullable PointF toFocusPoint) {
  mFromScale = fromScale;
  mToScale = toScale;
  mFromFocusPoint = fromFocusPoint;
  mToFocusPoint = toFocusPoint;
}
 
Example #23
Source File: DownsamplingView.java    From mirror with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onFinishInflate() {
    super.onFinishInflate();

    int gridSpanCount = getResources().getInteger(R.integer.grid_span_count);
    float width = DisplayUtils.getScreenWidth(getContext()) / gridSpanCount;
    float height = width / W_H_RATIO;
    mDownsamplingViewWidth = (int) width;
    mDownsamplingViewHeight = (int) height;

    getHierarchy().setActualImageScaleType(ScalingUtils.ScaleType.FOCUS_CROP);
    getHierarchy().setActualImageFocusPoint(new PointF(0.5F, 0.0F)); // top center
    getHierarchy().setFadeDuration(FADE_DURATION);
}
 
Example #24
Source File: FrescoUtils.java    From droidddle with Apache License 2.0 5 votes vote down vote up
public static final void setShotHierarchy(Context context, DraweeView view, ScalingUtils.ScaleType type) {
    final Resources res = context.getResources();
    final int color = ThemeUtil.getThemeColor(context, R.attr.colorAccent);
    final ProgressBarDrawable progress = new ProgressBarDrawable();
    progress.setBackgroundColor(Color.parseColor("#33000000"));
    progress.setColor(color);
    GenericDraweeHierarchy gdh = new GenericDraweeHierarchyBuilder(res)
            .setPlaceholderImage(res.getDrawable(R.drawable.placeholder))
            .setProgressBarImage(progress)
            .setActualImageScaleType(type)
            .build();
    view.setHierarchy(gdh);
}
 
Example #25
Source File: StickerView.java    From actor-platform with GNU Affero General Public License v3.0 5 votes vote down vote up
private void init() {
    builder = new GenericDraweeHierarchyBuilder(getResources());

    GenericDraweeHierarchy hierarchy = builder
            .setFadeDuration(200)
            .setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER)
            .build();
    setHierarchy(hierarchy);

    fastThumbLoader = new FastThumbLoader(this);

}
 
Example #26
Source File: ImageFragment.java    From TLint with Apache License 2.0 5 votes vote down vote up
@Override
public void initData() {
    showContent(true);
    ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(url))
            .setProgressiveRenderingEnabled(true)
            .build();

    GenericDraweeHierarchy hierarchy =
            new GenericDraweeHierarchyBuilder(getResources()).setProgressBarImage(
                    new ImageLoadProgressBar(new ImageLoadProgressBar.OnLevelChangeListener() {
                        @Override
                        public void onChange(int level) {
                            if (level > 100 && progress.getVisibility() == View.VISIBLE) {
                                progress.setVisibility(View.GONE);
                            }
                        }
                    }, ResourceUtil.getThemeColor(getActivity()))).build();
    hierarchy.setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER);

    PipelineDraweeControllerBuilder controller = Fresco.newDraweeControllerBuilder();
    controller.setControllerListener(listener);
    controller.setImageRequest(request);
    controller.setOldController(image.getController());
    controller.setAutoPlayAnimations(true);
    image.setHierarchy(hierarchy);
    image.setController(controller.build());
}
 
Example #27
Source File: PipelineDraweeController.java    From fresco with MIT License 5 votes vote down vote up
/**
 * updateDebugOverlay updates the debug overlay. Subclasses of {@link PipelineDraweeController}
 * can override this method (and call <code>super</code>) to provide additional debug information.
 */
protected void updateDebugOverlay(
    @Nullable CloseableImage image, DebugControllerOverlayDrawable debugOverlay) {
  debugOverlay.setControllerId(getId());

  final DraweeHierarchy draweeHierarchy = getHierarchy();
  ScaleType scaleType = null;
  if (draweeHierarchy != null) {
    final ScaleTypeDrawable scaleTypeDrawable =
        ScalingUtils.getActiveScaleTypeDrawable(draweeHierarchy.getTopLevelDrawable());
    scaleType = scaleTypeDrawable != null ? scaleTypeDrawable.getScaleType() : null;
  }
  debugOverlay.setScaleType(scaleType);

  // fill in image origin text and color hint
  final int origin = mDebugOverlayImageOriginListener.getImageOrigin();
  final String originText = ImageOriginUtils.toString(origin);
  final int originColor = DebugOverlayImageOriginColor.getImageOriginColor(origin);
  debugOverlay.setOrigin(originText, originColor);

  if (image != null) {
    debugOverlay.setDimensions(image.getWidth(), image.getHeight());
    debugOverlay.setImageSize(image.getSizeInBytes());
  } else {
    debugOverlay.reset();
  }
}
 
Example #28
Source File: HierarcherImplTest.java    From fresco with MIT License 5 votes vote down vote up
@Test
public void testBuildPlaceholderDrawableScale() {
  final Drawable expected = new ColorDrawable(Color.YELLOW);
  ImageOptions options =
      ImageOptions.create()
          .placeholder(expected)
          .placeholderScaleType(ScalingUtils.ScaleType.CENTER)
          .build();

  final Drawable result = mHierarcher.buildPlaceholderDrawable(mResources, options);

  assertThat(result).isExactlyInstanceOf(ScaleTypeDrawable.class);
  assertThat(result.getCurrent()).isEqualTo(expected);
}
 
Example #29
Source File: HierarcherImplTest.java    From fresco with MIT License 5 votes vote down vote up
@Test
public void testBuildProgressDrawable() {
  final Drawable drawable = new ColorDrawable(0x0);
  final ImageOptions imageOptions =
      ImageOptions.create()
          .progress(drawable)
          .progressScaleType(ScalingUtils.ScaleType.FIT_CENTER)
          .build();

  final Drawable actual = mHierarcher.buildProgressDrawable(mResources, imageOptions);
  assertThat(actual).isInstanceOf(ScaleTypeDrawable.class);
  final ScaleTypeDrawable scaleTypeActual = (ScaleTypeDrawable) actual;
  assertThat(scaleTypeActual.getScaleType()).isEqualTo(ScalingUtils.ScaleType.FIT_CENTER);
  assertThat(scaleTypeActual.getCurrent()).isEqualTo(drawable);
}
 
Example #30
Source File: HierarcherImplTest.java    From fresco with MIT License 5 votes vote down vote up
@Test
public void testBuildActualImageWrapper() {
  final PointF expectedFocusPoint = new PointF(1, 2);
  final ImageOptions imageOptions =
      ImageOptions.create()
          .scale(ScalingUtils.ScaleType.FIT_CENTER)
          .focusPoint(expectedFocusPoint)
          .build();

  final Drawable actual = mHierarcher.buildActualImageWrapper(imageOptions);
  assertThat(actual).isInstanceOf(ScaleTypeDrawable.class);
  final ScaleTypeDrawable scaleTypeActual = (ScaleTypeDrawable) actual;
  assertThat(scaleTypeActual.getScaleType()).isEqualTo(ScalingUtils.ScaleType.FIT_CENTER);
  assertThat(scaleTypeActual.getFocusPoint()).isEqualTo(expectedFocusPoint);
}