use of com.facebook.drawee.backends.pipeline.PipelineDraweeControllerBuilder in project actor-platform by actorapp.
the class CoverAvatarView method bind.
public void bind(final Avatar avatar) {
// Same avatar
if (avatar != null && avatar.getSmallImage() != null && avatar.getSmallImage().getFileReference().getFileId() == currentId) {
return;
}
if (fileVM != null) {
fileVM.detach();
fileVM = null;
}
if (fullFileVM != null) {
fullFileVM.detach();
fullFileVM = null;
}
isLoaded = false;
smallDescriptor = null;
if (tryToSetFast(avatar)) {
return;
}
if (avatar != null && avatar.getSmallImage() != null) {
currentId = avatar.getSmallImage().getFileReference().getFileId();
fileVM = messenger().bindFile(avatar.getSmallImage().getFileReference(), true, new FileVMCallback() {
@Override
public void onNotDownloaded() {
}
@Override
public void onDownloading(float progress) {
}
@Override
public void onDownloaded(FileSystemReference reference) {
if (!isLoaded) {
smallDescriptor = reference.getDescriptor();
setImageURI(Uri.fromFile(new File(smallDescriptor)));
}
}
});
if (avatar.getFullImage() != null) {
fullFileVM = messenger().bindFile(avatar.getFullImage().getFileReference(), true, new FileVMCallback() {
@Override
public void onNotDownloaded() {
}
@Override
public void onDownloading(float progress) {
}
@Override
public void onDownloaded(FileSystemReference reference) {
isLoaded = true;
PipelineDraweeControllerBuilder dController = Fresco.newDraweeControllerBuilder();
if (smallDescriptor != null) {
dController.setLowResImageRequest(ImageRequest.fromUri(Uri.fromFile(new File(smallDescriptor))));
}
dController.setOldController(getController());
dController.setImageRequest(ImageRequest.fromUri(Uri.fromFile(new File(reference.getDescriptor()))));
setController(dController.build());
}
});
}
}
}
use of com.facebook.drawee.backends.pipeline.PipelineDraweeControllerBuilder in project fresco by facebook.
the class DraweeViewHolder method bind.
/**
* @param uri The Uri to show into the DraweeView for this Holder
*/
public void bind(Uri uri) {
mDraweeView.initInstrumentation(uri.toString(), mPerfListener);
ImageRequestBuilder imageRequestBuilder = ImageRequestBuilder.newBuilderWithSource(uri).setResizeOptions(new ResizeOptions(mDraweeView.getLayoutParams().width, mDraweeView.getLayoutParams().height));
PipelineUtil.addOptionalFeatures(imageRequestBuilder, mConfig);
// Create the Builder
PipelineDraweeControllerBuilder builder = Fresco.newDraweeControllerBuilder().setImageRequest(imageRequestBuilder.build());
if (mConfig.reuseOldController) {
builder.setOldController(mDraweeView.getController());
}
mDraweeView.setListener(builder);
mDraweeView.setController(builder.build());
}
use of com.facebook.drawee.backends.pipeline.PipelineDraweeControllerBuilder in project fresco by facebook.
the class DraweeViewListAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
InstrumentedDraweeView draweeView;
if (convertView == null) {
final Context context = parent.getContext();
GenericDraweeHierarchy gdh = DraweeUtil.createDraweeHierarchy(context, mConfig);
draweeView = new InstrumentedDraweeView(context, gdh, mConfig);
SizeUtil.setConfiguredSize(parent, draweeView, mConfig);
draweeView.setPadding(mPaddingPx, mPaddingPx, mPaddingPx, mPaddingPx);
} else {
draweeView = (InstrumentedDraweeView) convertView;
}
final Uri uri = getItem(position);
draweeView.initInstrumentation(uri.toString(), mPerfListener);
ImageRequestBuilder imageRequestBuilder = ImageRequestBuilder.newBuilderWithSource(uri).setResizeOptions(new ResizeOptions(draweeView.getLayoutParams().width, draweeView.getLayoutParams().height));
PipelineUtil.addOptionalFeatures(imageRequestBuilder, mConfig);
// Create the Builder
PipelineDraweeControllerBuilder builder = Fresco.newDraweeControllerBuilder().setImageRequest(imageRequestBuilder.build());
if (mConfig.reuseOldController) {
builder.setOldController(draweeView.getController());
}
if (mConfig.instrumentationEnabled) {
draweeView.setListener(builder);
}
draweeView.setController(builder.build());
return draweeView;
}
Aggregations