Search in sources :

Example 1 with ProgressBarDrawable

use of com.facebook.drawee.drawable.ProgressBarDrawable in project fresco by facebook.

the class MainActivity method findAndPrepare.

private SimpleDraweeView findAndPrepare(@IdRes int viewId) {
    SimpleDraweeView view = (SimpleDraweeView) findViewById(viewId);
    view.getHierarchy().setProgressBarImage(new ProgressBarDrawable());
    return view;
}
Also used : SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) ProgressBarDrawable(com.facebook.drawee.drawable.ProgressBarDrawable)

Example 2 with ProgressBarDrawable

use of com.facebook.drawee.drawable.ProgressBarDrawable 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 3 with ProgressBarDrawable

use of com.facebook.drawee.drawable.ProgressBarDrawable in project fresco by facebook.

the class FrescoAdapter method onCreateViewHolder.

@Override
public FrescoHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    GenericDraweeHierarchy gdh = new GenericDraweeHierarchyBuilder(getContext().getResources()).setPlaceholderImage(Drawables.sPlaceholderDrawable).setFailureImage(Drawables.sErrorDrawable).setProgressBarImage(new ProgressBarDrawable()).setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER).build();
    final InstrumentedDraweeView instrView = new InstrumentedDraweeView(getContext(), gdh);
    return new FrescoHolder(getContext(), parent, instrView, getPerfListener());
}
Also used : ProgressBarDrawable(com.facebook.drawee.drawable.ProgressBarDrawable) FrescoHolder(com.facebook.samples.comparison.holders.FrescoHolder) GenericDraweeHierarchy(com.facebook.drawee.generic.GenericDraweeHierarchy) GenericDraweeHierarchyBuilder(com.facebook.drawee.generic.GenericDraweeHierarchyBuilder) InstrumentedDraweeView(com.facebook.samples.comparison.instrumentation.InstrumentedDraweeView)

Example 4 with ProgressBarDrawable

use of com.facebook.drawee.drawable.ProgressBarDrawable in project Rocket.Chat.Android by RocketChat.

the class FrescoHelper method setupDrawee.

public static void setupDrawee(SimpleDraweeView draweeView) {
    final GenericDraweeHierarchy hierarchy = draweeView.getHierarchy();
    hierarchy.setPlaceholderImage(VectorDrawableCompat.create(draweeView.getResources(), R.drawable.image_dummy, null));
    hierarchy.setFailureImage(VectorDrawableCompat.create(draweeView.getResources(), R.drawable.image_error, null));
    hierarchy.setProgressBarImage(new ProgressBarDrawable());
}
Also used : ProgressBarDrawable(com.facebook.drawee.drawable.ProgressBarDrawable) GenericDraweeHierarchy(com.facebook.drawee.generic.GenericDraweeHierarchy)

Example 5 with ProgressBarDrawable

use of com.facebook.drawee.drawable.ProgressBarDrawable in project fresco by facebook.

the class ImageFormatProgressiveJpegFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    mSpinnerEntries = new Entry[] { new Entry(R.string.format_pjpeg_label_small, sampleUris().createSampleUri(ImageUriProvider.ImageSize.L)), new Entry(R.string.format_pjpeg_label_medium, sampleUris().createSampleUri(ImageUriProvider.ImageSize.M)), new Entry(R.string.format_pjpeg_label_large, sampleUris().createSampleUri(ImageUriProvider.ImageSize.S)), new Entry(R.string.format_pjpeg_label_slow, sampleUris().createPJPEGSlow()) };
    ProgressBarDrawable progressBarDrawable = new ProgressBarDrawable();
    progressBarDrawable.setColor(getResources().getColor(R.color.progress_bar_color));
    progressBarDrawable.setBackgroundColor(getResources().getColor(R.color.progress_bar_background));
    mSimpleDraweeView = (SimpleDraweeView) view.findViewById(R.id.drawee_view);
    mSimpleDraweeView.getHierarchy().setProgressBarImage(progressBarDrawable);
    mDebugOutput = (TextView) view.findViewById(R.id.debug_output);
    mDebugOutputScrollView = (ScrollView) view.findViewById(R.id.debug_output_scroll_view);
    final SwitchCompat switchProgressiveRenderingEnabled = (SwitchCompat) view.findViewById(R.id.switch_progressive_enabled);
    switchProgressiveRenderingEnabled.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            mProgressiveRenderingEnabled = isChecked;
        }
    });
    mProgressiveRenderingEnabled = switchProgressiveRenderingEnabled.isChecked();
    final Spinner spinner = (Spinner) view.findViewById(R.id.spinner);
    spinner.setAdapter(new SimpleUriListAdapter());
    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            final Entry spinnerEntry = mSpinnerEntries[spinner.getSelectedItemPosition()];
            setImageUri(spinnerEntry.uri);
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
    spinner.setSelection(0);
}
Also used : ProgressBarDrawable(com.facebook.drawee.drawable.ProgressBarDrawable) Spinner(android.widget.Spinner) SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView) AdapterView(android.widget.AdapterView) CompoundButton(android.widget.CompoundButton) SwitchCompat(androidx.appcompat.widget.SwitchCompat)

Aggregations

ProgressBarDrawable (com.facebook.drawee.drawable.ProgressBarDrawable)7 GenericDraweeHierarchy (com.facebook.drawee.generic.GenericDraweeHierarchy)4 Drawable (android.graphics.drawable.Drawable)3 Uri (android.net.Uri)3 GenericDraweeHierarchyBuilder (com.facebook.drawee.generic.GenericDraweeHierarchyBuilder)3 SimpleDraweeView (com.facebook.drawee.view.SimpleDraweeView)3 Canvas (android.graphics.Canvas)2 View (android.view.View)2 CompoundButton (android.widget.CompoundButton)2 SwitchCompat (androidx.appcompat.widget.SwitchCompat)2 DraweeController (com.facebook.drawee.interfaces.DraweeController)2 ResizeOptions (com.facebook.imagepipeline.common.ResizeOptions)2 ImageRequest (com.facebook.imagepipeline.request.ImageRequest)2 Resources (android.content.res.Resources)1 AdapterView (android.widget.AdapterView)1 ScrollView (android.widget.ScrollView)1 Spinner (android.widget.Spinner)1 TextView (android.widget.TextView)1 GFImageView (cn.finalteam.galleryfinal.widget.GFImageView)1 RoundingParams (com.facebook.drawee.generic.RoundingParams)1