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;
}
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);
}
});
}
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());
}
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());
}
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);
}
Aggregations