Search in sources :

Example 16 with SimpleDraweeView

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);
        }
    });
}
Also used : SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) ProgressBarDrawable(com.facebook.drawee.drawable.ProgressBarDrawable) Drawable(android.graphics.drawable.Drawable) ProgressBarDrawable(com.facebook.drawee.drawable.ProgressBarDrawable) Uri(android.net.Uri) SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) View(android.view.View) CompoundButton(android.widget.CompoundButton) RoundingParams(com.facebook.drawee.generic.RoundingParams) SwitchCompat(androidx.appcompat.widget.SwitchCompat)

Example 17 with SimpleDraweeView

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);
}
Also used : SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) AbstractDraweeController(com.facebook.drawee.controller.AbstractDraweeController) ImageDecodeOptions(com.facebook.imagepipeline.common.ImageDecodeOptions) ImageDecodeOptionsBuilder(com.facebook.imagepipeline.common.ImageDecodeOptionsBuilder)

Example 18 with SimpleDraweeView

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);
        }
    });
}
Also used : SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) Uri(android.net.Uri) SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) View(android.view.View)

Example 19 with SimpleDraweeView

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);
}
Also used : SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) TextView(android.widget.TextView)

Example 20 with SimpleDraweeView

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);
}
Also used : SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) RotateAnimation(android.view.animation.RotateAnimation) Button(android.widget.Button) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) View(android.view.View)

Aggregations

SimpleDraweeView (com.facebook.drawee.view.SimpleDraweeView)58 View (android.view.View)30 TextView (android.widget.TextView)20 Uri (android.net.Uri)8 DraweeController (com.facebook.drawee.interfaces.DraweeController)8 Intent (android.content.Intent)6 ImageView (android.widget.ImageView)5 RecyclerView (android.support.v7.widget.RecyclerView)4 Button (android.widget.Button)4 TintImageView (com.bilibili.magicasakura.widgets.TintImageView)4 RoundingParams (com.facebook.drawee.generic.RoundingParams)4 Animatable (android.graphics.drawable.Animatable)3 ViewGroup (android.view.ViewGroup)3 AdapterView (android.widget.AdapterView)3 CompoundButton (android.widget.CompoundButton)3 LinearLayout (android.widget.LinearLayout)3 SwitchCompat (androidx.appcompat.widget.SwitchCompat)3 BaseControllerListener (com.facebook.drawee.controller.BaseControllerListener)3 ControllerListener (com.facebook.drawee.controller.ControllerListener)3 ProgressBarDrawable (com.facebook.drawee.drawable.ProgressBarDrawable)3