use of com.facebook.drawee.view.SimpleDraweeView 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);
}
use of com.facebook.drawee.view.SimpleDraweeView in project fresco by facebook.
the class ImagePipelinePrefetchFragment method onViewCreated.
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mUris = new Uri[] { sampleUris().createSampleUri(ImageSize.L, Orientation.LANDSCAPE), sampleUris().createSampleUri(ImageSize.L, Orientation.PORTRAIT) };
final Button clearCacheButton = (Button) view.findViewById(R.id.clear_cache);
clearCacheButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
for (Uri uri : mUris) {
Fresco.getImagePipeline().evictFromCache(uri);
}
}
});
mPrefetchStatus = (TextView) view.findViewById(R.id.prefetch_status);
mPrefetchDiskButton = (Button) view.findViewById(R.id.prefetch_disk_now);
mPrefetchDiskButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mPrefetchDiskButton.setEnabled(false);
final PrefetchSubscriber subscriber = new PrefetchSubscriber();
for (Uri uri : mUris) {
final DataSource<Void> ds = Fresco.getImagePipeline().prefetchToDiskCache(ImageRequest.fromUri(uri), null);
ds.subscribe(subscriber, UiThreadImmediateExecutorService.getInstance());
}
}
});
mPrefetchEncodedButton = (Button) view.findViewById(R.id.prefetch_encoded_now);
mPrefetchEncodedButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mPrefetchEncodedButton.setEnabled(false);
final PrefetchSubscriber subscriber = new PrefetchSubscriber();
for (Uri uri : mUris) {
final DataSource<Void> ds = Fresco.getImagePipeline().prefetchToEncodedCache(ImageRequest.fromUri(uri), null);
ds.subscribe(subscriber, UiThreadImmediateExecutorService.getInstance());
}
}
});
mPrefetchBitmapButton = (Button) view.findViewById(R.id.prefetch_bitmap_now);
mPrefetchBitmapButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mPrefetchBitmapButton.setEnabled(false);
final PrefetchSubscriber subscriber = new PrefetchSubscriber();
for (Uri uri : mUris) {
final DataSource<Void> ds = Fresco.getImagePipeline().prefetchToBitmapCache(ImageRequest.fromUri(uri), null);
ds.subscribe(subscriber, UiThreadImmediateExecutorService.getInstance());
}
}
});
mDraweesHolder = (ViewGroup) view.findViewById(R.id.drawees);
Button toggleImages = (Button) view.findViewById(R.id.toggle_images);
toggleImages.setOnClickListener(new View.OnClickListener() {
private boolean mShowing = false;
@Override
public void onClick(View v) {
if (!mShowing) {
for (int i = 0; i < mDraweesHolder.getChildCount(); i++) {
SimpleDraweeView draweeView = (SimpleDraweeView) mDraweesHolder.getChildAt(i);
draweeView.setController(Fresco.newDraweeControllerBuilder().setOldController(draweeView.getController()).setImageOriginListener(mImageOriginListener).setUri(mUris[i]).build());
}
} else {
for (int i = 0; i < mDraweesHolder.getChildCount(); i++) {
((SimpleDraweeView) mDraweesHolder.getChildAt(i)).setController(null);
}
}
mShowing = !mShowing;
}
});
}
use of com.facebook.drawee.view.SimpleDraweeView in project fresco by facebook.
the class PartialRequestFragment method onViewCreated.
@Override
public void onViewCreated(final View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
final SimpleDraweeView partialDrawee = (SimpleDraweeView) view.findViewById(R.id.drawee_partial_img);
final SimpleDraweeView fullDrawee = (SimpleDraweeView) view.findViewById(R.id.drawee_full_img);
final Button clearCacheButton = (Button) view.findViewById(R.id.clear_cache);
clearCacheButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
partialDrawee.setController(null);
fullDrawee.setController(null);
Fresco.getImagePipeline().clearDiskCaches();
Fresco.getImagePipeline().clearMemoryCaches();
}
});
final Button prefetchButton = (Button) view.findViewById(R.id.prefetch_now);
prefetchButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
loadImageIntoDrawee(partialDrawee, BytesRange.toMax(30000));
}
});
Button loadFull = (Button) view.findViewById(R.id.load_full);
loadFull.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
loadImageIntoDrawee(fullDrawee, null);
}
});
}
Aggregations