use of com.facebook.drawee.view.SimpleDraweeView in project fresco by facebook.
the class DraweeHierarchyFragment method onViewCreated.
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
final Uri uriSuccess = sampleUris().createSampleUri(ImageUriProvider.ImageSize.XL, ImageUriProvider.Orientation.ANY, ImageUriProvider.UriModification.CACHE_BREAKER);
final Uri uriFailure = sampleUris().getNonExistingUri();
final SimpleDraweeView draweeView = view.findViewById(R.id.drawee);
final SwitchCompat retrySwitch = view.findViewById(R.id.retry_enabled);
// noinspection deprecation
final Drawable failureDrawable = getResources().getDrawable(R.drawable.ic_error_black_96dp);
DrawableCompat.setTint(failureDrawable, Color.RED);
final ProgressBarDrawable progressBarDrawable = new ProgressBarDrawable();
progressBarDrawable.setColor(getResources().getColor(R.color.accent));
progressBarDrawable.setBackgroundColor(getResources().getColor(R.color.primary));
progressBarDrawable.setRadius(getResources().getDimensionPixelSize(R.dimen.drawee_hierarchy_progress_radius));
draweeView.getHierarchy().setProgressBarImage(progressBarDrawable);
draweeView.getHierarchy().setFailureImage(failureDrawable, ScaleType.CENTER_INSIDE);
view.findViewById(R.id.load_success).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
setUri(draweeView, uriSuccess, retrySwitch.isChecked());
}
});
view.findViewById(R.id.load_fail).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
setUri(draweeView, uriFailure, retrySwitch.isChecked());
}
});
view.findViewById(R.id.clear).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
draweeView.setController(null);
Fresco.getImagePipeline().evictFromCache(uriSuccess);
}
});
final SwitchCompat roundCorners = view.findViewById(R.id.switch_rounded);
roundCorners.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
RoundingParams roundingParams = new RoundingParams().setCornersRadius(isChecked ? buttonView.getResources().getDimensionPixelSize(R.dimen.drawee_hierarchy_corner_radius) : 0);
draweeView.getHierarchy().setRoundingParams(roundingParams);
}
});
final SwitchCompat useNinePatch = view.findViewById(R.id.switch_ninepatch);
useNinePatch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
draweeView.getHierarchy().setPlaceholderImage(isChecked ? R.drawable.ninepatch : R.drawable.logo, isChecked ? ScaleType.FIT_XY : ScaleType.CENTER_INSIDE);
}
});
}
use of com.facebook.drawee.view.SimpleDraweeView in project fresco by facebook.
the class ImageFormatOverrideExample method onViewCreated.
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
SimpleDraweeView simpleDraweeView = (SimpleDraweeView) view.findViewById(R.id.drawee_view);
ImageDecodeOptions imageDecodeOptionsWithCustomDecoder = new ImageDecodeOptionsBuilder().setCustomImageDecoder(CUSTOM_COLOR_DECODER).build();
AbstractDraweeController controller = Fresco.newDraweeControllerBuilder().setImageRequest(ImageRequestBuilder.newBuilderWithResourceId(R.raw.custom_color1).setImageDecodeOptions(imageDecodeOptionsWithCustomDecoder).build()).build();
simpleDraweeView.setController(controller);
}
use of com.facebook.drawee.view.SimpleDraweeView in project fresco by facebook.
the class DraweeTransitionFragment method onViewCreated.
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
final Uri imageUri = sampleUris().createSampleUri(ImageUriProvider.ImageSize.M);
final SimpleDraweeView simpleDraweeView = (SimpleDraweeView) view.findViewById(R.id.drawee_view);
// You have to enable legacy visibility handling for the start view in order for this to work
simpleDraweeView.setLegacyVisibilityHandlingEnabled(true);
simpleDraweeView.setImageURI(imageUri);
simpleDraweeView.getHierarchy().setActualImageScaleType(ScalingUtils.ScaleType.FOCUS_CROP);
simpleDraweeView.getHierarchy().setActualImageFocusPoint(FOCUS_POINT);
simpleDraweeView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startTransition(v, imageUri);
}
});
}
use of com.facebook.drawee.view.SimpleDraweeView in project fresco by facebook.
the class ImageFormatDataUriFragment method onViewCreated.
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
final SimpleDraweeView simpleDraweeView = view.findViewById(R.id.drawee_view);
simpleDraweeView.setImageURI(dataUri, null);
final TextView uriContentTextView = view.findViewById(R.id.datauri_content_textview);
uriContentTextView.setText(dataUri);
}
use of com.facebook.drawee.view.SimpleDraweeView in project fresco by facebook.
the class WelcomeFragment method onViewCreated.
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
final SimpleDraweeView draweeView = (SimpleDraweeView) view.findViewById(R.id.drawee_view);
draweeView.setActualImageResource(R.drawable.logo);
draweeView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final RotateAnimation rotateAnimation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
rotateAnimation.setDuration(1000);
rotateAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
draweeView.startAnimation(rotateAnimation);
}
});
final Button buttonGitHub = (Button) view.findViewById(R.id.button_github);
setUriIntent(buttonGitHub, URL_GITHUB);
final Button buttonDocumentation = (Button) view.findViewById(R.id.button_documentation);
setUriIntent(buttonDocumentation, URL_DOCUMENTATION);
}
Aggregations