use of com.facebook.drawee.drawable.ProgressBarDrawable in project GalleryFinal by pengjianbo.
the class FrescoImageLoader method displayImage.
@Override
public void displayImage(Activity activity, String path, final GFImageView imageView, final Drawable defaultDrawable, int width, int height) {
Resources resources = context.getResources();
GenericDraweeHierarchy hierarchy = new GenericDraweeHierarchyBuilder(resources).setFadeDuration(300).setPlaceholderImage(defaultDrawable).setFailureImage(defaultDrawable).setProgressBarImage(new ProgressBarDrawable()).build();
final DraweeHolder<GenericDraweeHierarchy> draweeHolder = DraweeHolder.create(hierarchy, context);
imageView.setOnImageViewListener(new GFImageView.OnImageViewListener() {
@Override
public void onDetach() {
draweeHolder.onDetach();
}
@Override
public void onAttach() {
draweeHolder.onAttach();
}
@Override
public boolean verifyDrawable(Drawable dr) {
if (dr == draweeHolder.getHierarchy().getTopLevelDrawable()) {
return true;
}
return false;
}
@Override
public void onDraw(Canvas canvas) {
Drawable drawable = draweeHolder.getHierarchy().getTopLevelDrawable();
if (drawable == null) {
imageView.setImageDrawable(defaultDrawable);
} else {
imageView.setImageDrawable(drawable);
}
}
});
Uri uri = new Uri.Builder().scheme(UriUtil.LOCAL_FILE_SCHEME).path(path).build();
ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(uri).setResizeOptions(// 图片目标大小
new ResizeOptions(width, height)).build();
DraweeController controller = Fresco.newDraweeControllerBuilder().setOldController(draweeHolder.getController()).setImageRequest(imageRequest).build();
draweeHolder.setController(controller);
}
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