use of com.facebook.drawee.drawable.ScalingUtils.ScaleType in project fresco by facebook.
the class DraweeRoundedCornersFragment method onViewCreated.
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
findDrawees(view);
initColors();
final ImageUriProvider imageUriProvider = sampleUris();
mDraweeRound.setImageURI(imageUriProvider.createSampleUri(ImageSize.L));
mDraweeRadius.setImageURI(imageUriProvider.createSampleUri(ImageSize.L));
mDraweeSome.setImageURI(imageUriProvider.createSampleUri(ImageSize.L));
mDraweeSomeRtl.setImageURI(imageUriProvider.createSampleUri(ImageSize.L));
mDraweeFancy.setImageURI(imageUriProvider.createSampleUri(ImageSize.L));
final Spinner scaleType = view.findViewById(R.id.scaleType);
final SimpleScaleTypeAdapter scaleTypeAdapter = SimpleScaleTypeAdapter.createForAllScaleTypes();
scaleType.setAdapter(scaleTypeAdapter);
scaleType.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
final SimpleScaleTypeAdapter.Entry spinnerEntry = (SimpleScaleTypeAdapter.Entry) scaleTypeAdapter.getItem(position);
final ScaleType scaleType = spinnerEntry.scaleType;
changeDraweeViewScaleType(mDraweeRound, scaleType, spinnerEntry.focusPoint);
changeDraweeViewScaleType(mDraweeRadius, scaleType, spinnerEntry.focusPoint);
changeDraweeViewScaleType(mDraweeSome, scaleType, spinnerEntry.focusPoint);
changeDraweeViewScaleType(mDraweeSomeRtl, scaleType, spinnerEntry.focusPoint);
changeDraweeViewScaleType(mDraweeFancy, scaleType, spinnerEntry.focusPoint);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
mShowBordersCheck = view.findViewById(R.id.borders);
mShowBordersCheck.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
updateRounding();
}
});
mScaleInsideBordersCheck = view.findViewById(R.id.scaleInside);
mScaleInsideBordersCheck.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
updateRounding();
}
});
mColorOverlayCheck = view.findViewById(R.id.color_overlay);
mColorOverlayCheck.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
updateRounding();
}
});
mFixRepeatedEdgesCheck = view.findViewById(R.id.fix_repeated_edges);
mFixRepeatedEdgesCheck.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
updateRounding();
}
});
final Resources res = getResources();
final RoundingParams fancyRoundingParams = RoundingParams.fromCornersRadii(res.getDimensionPixelSize(R.dimen.drawee_rounded_corners_fancy_top_left), res.getDimensionPixelSize(R.dimen.drawee_rounded_corners_fancy_top_right), res.getDimensionPixelSize(R.dimen.drawee_rounded_corners_fancy_bottom_right), res.getDimensionPixelSize(R.dimen.drawee_rounded_corners_fancy_bottom_left));
mDraweeFancy.getHierarchy().setRoundingParams(fancyRoundingParams);
}
use of com.facebook.drawee.drawable.ScalingUtils.ScaleType in project fresco by facebook.
the class GenericDraweeHierarchyTest method testSetActualImageScaleType.
@Test
public void testSetActualImageScaleType() {
GenericDraweeHierarchy dh = mBuilder.setPlaceholderImage(mPlaceholderImage).build();
// actual image index in DH tree
final int imageIndex = 2;
FadeDrawable fadeDrawable = (FadeDrawable) dh.getTopLevelDrawable().getCurrent();
ScaleTypeDrawable scaleTypeDrawable = (ScaleTypeDrawable) fadeDrawable.getDrawable(imageIndex);
ScaleType scaleType1 = ScaleType.FOCUS_CROP;
dh.setActualImageScaleType(scaleType1);
assertEquals(scaleType1, scaleTypeDrawable.getScaleType());
ScaleType scaleType2 = ScaleType.CENTER;
dh.setActualImageScaleType(scaleType2);
assertEquals(scaleType2, scaleTypeDrawable.getScaleType());
}
use of com.facebook.drawee.drawable.ScalingUtils.ScaleType in project fresco by facebook.
the class PipelineDraweeController method updateDebugOverlay.
/**
* 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();
}
}
Aggregations