本文整理汇总了Java中com.facebook.drawee.view.DraweeHolder.setController方法的典型用法代码示例。如果您正苦于以下问题:Java DraweeHolder.setController方法的具体用法?Java DraweeHolder.setController怎么用?Java DraweeHolder.setController使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.facebook.drawee.view.DraweeHolder
的用法示例。
在下文中一共展示了DraweeHolder.setController方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setImageSpan
import com.facebook.drawee.view.DraweeHolder; //导入方法依赖的package包/类
public void setImageSpan(
Context context,
DraweeHierarchy draweeHierarchy,
DraweeController draweeController,
int startIndex,
int endIndex,
final int drawableWidthPx,
final int drawableHeightPx,
boolean enableResizing,
@BetterImageSpan.BetterImageSpanAlignment int verticalAlignment) {
DraweeHolder draweeHolder = DraweeHolder.create(draweeHierarchy, context);
draweeHolder.setController(draweeController);
setImageSpan(
draweeHolder,
startIndex,
endIndex,
drawableWidthPx,
drawableHeightPx,
enableResizing,
verticalAlignment);
}
示例2: setIconSource
import com.facebook.drawee.view.DraweeHolder; //导入方法依赖的package包/类
private void setIconSource(ReadableMap source, IconControllerListener controllerListener,
DraweeHolder holder) {
String uri = source != null ? source.getString("uri") : null;
if (uri == null) {
controllerListener.setIconImageInfo(null);
controllerListener.setDrawable(null);
} else if (uri.startsWith("http://") || uri.startsWith("https://") ||
uri.startsWith("file://")) {
controllerListener.setIconImageInfo(getIconImageInfo(source));
DraweeController controller = Fresco.newDraweeControllerBuilder()
.setUri(Uri.parse(uri))
.setControllerListener(controllerListener)
.setOldController(holder.getController())
.build();
holder.setController(controller);
holder.getTopLevelDrawable().setVisible(true, true);
} else {
controllerListener.setDrawable(getDrawableByName(uri));
}
}
示例3: setIconSource
import com.facebook.drawee.view.DraweeHolder; //导入方法依赖的package包/类
/**
* Sets an icon for a specific icon source. If the uri indicates an icon
* to be somewhere remote (http/https) or on the local filesystem, it uses fresco to load it.
* Otherwise it loads the Drawable from the Resources and directly returns it via a callback
*/
private void setIconSource(ReadableMap source, IconControllerListener controllerListener, DraweeHolder holder) {
String uri = source != null ? source.getString(PROP_ICON_URI) : null;
if (uri == null) {
controllerListener.setIconImageInfo(null);
controllerListener.setDrawable(null);
} else if (uri.startsWith("http://") || uri.startsWith("https://") || uri.startsWith("file://")) {
controllerListener.setIconImageInfo(getIconImageInfo(source));
DraweeController controller = Fresco.newDraweeControllerBuilder()
.setUri(Uri.parse(uri))
.setControllerListener(controllerListener)
.setOldController(holder.getController())
.build();
holder.setController(controller);
holder.getTopLevelDrawable().setVisible(true, true);
} else {
controllerListener.setDrawable(getDrawableByName(uri));
}
}
示例4: setIconSource
import com.facebook.drawee.view.DraweeHolder; //导入方法依赖的package包/类
/**
* Sets an icon for a specific icon source. If the uri indicates an icon
* to be somewhere remote (http/https) or on the local filesystem, it uses fresco to load it.
* Otherwise it loads the Drawable from the Resources and directly returns it via a callback
*/
private void setIconSource(ReadableMap source, IconControllerListener controllerListener, DraweeHolder holder) {
String uri = source != null ? source.getString(PROP_ICON_URI) : null;
if (uri == null) {
controllerListener.setIconImageInfo(null);
controllerListener.setDrawable(null);
} else if (uri.startsWith("http://") || uri.startsWith("https://") || uri.startsWith("file://")) {
controllerListener.setIconImageInfo(getIconImageInfo(source));
DraweeController controller = Fresco.newDraweeControllerBuilder()
.setUri(Uri.parse(uri))
.setControllerListener(controllerListener)
.setOldController(holder.getController())
.build();
holder.setController(controller);
} else {
controllerListener.setDrawable(getDrawableByName(uri));
}
}
示例5: setIconSource
import com.facebook.drawee.view.DraweeHolder; //导入方法依赖的package包/类
/**
* Sets an icon for a specific icon source. If the uri indicates an icon
* to be somewhere remote (http/https) or on the local filesystem, it uses fresco to load it.
* Otherwise it loads the Drawable from the Resources and directly returns it via a callback
*/
private void setIconSource(ReadableMap source, IconControllerListener controllerListener, DraweeHolder holder) {
String uri = source != null ? source.getString(PROP_ICON_URI) : null;
if (uri == null) {
controllerListener.setIconImageInfo(null);
controllerListener.setDrawable(null);
} else if (uri.startsWith("http://") || uri.startsWith("https://") || uri.startsWith("file://")) {
controllerListener.setIconImageInfo(getIconImageInfo(source));
DraweeController controller = Fresco.newDraweeControllerBuilder()
.setUri(Uri.parse(uri))
.setControllerListener(controllerListener)
.setOldController(holder.getController())
.build();
holder.setController(controller);
holder.getTopLevelDrawable().setVisible(true, true);
} else {
controllerListener.setDrawable(getDrawableByName(uri));
}
}
示例6: setIconSource
import com.facebook.drawee.view.DraweeHolder; //导入方法依赖的package包/类
/**
* Sets an icon for a specific icon source. If the uri indicates an icon
* to be somewhere remote (http/https) or on the local filesystem, it uses fresco to load it.
* Otherwise it loads the Drawable from the Resources and directly returns it via a callback
*/
private void setIconSource(ReadableMap source, IconControllerListener controllerListener, DraweeHolder holder) {
String uri = source != null ? source.getString(PROP_ICON_URI) : null;
if (uri == null) {
controllerListener.setIconImageInfo(null);
controllerListener.setDrawable(null);
} else if (uri.startsWith("http://") || uri.startsWith("https://") || uri.startsWith("file://")) {
controllerListener.setIconImageInfo(getIconImageInfo(source));
DraweeController controller = Fresco.newDraweeControllerBuilder()
.setUri(Uri.parse(uri))
.setControllerListener(controllerListener)
.setOldController(holder.getController())
.build();
holder.setController(controller);
holder.getTopLevelDrawable().setVisible(true, true);
} else {
controllerListener.setDrawable(getDrawableByName(uri));
}
}
示例7: displayImage
import com.facebook.drawee.view.DraweeHolder; //导入方法依赖的package包/类
/**
* 加载远程图片
*
* @param url
* @param imageSize
*/
private void displayImage(Uri url, ResizeOptions imageSize, final ImageView imageView, final DraweeHolder<GenericDraweeHierarchy> draweeHolder) {
ImageRequest imageRequest = ImageRequestBuilder
.newBuilderWithSource(url)
.setResizeOptions(imageSize)//图片目标大小
.build();
ImagePipeline imagePipeline = Fresco.getImagePipeline();
final DataSource<CloseableReference<CloseableImage>> dataSource = imagePipeline.fetchDecodedImage(imageRequest, this);
DraweeController controller = Fresco.newDraweeControllerBuilder()
.setOldController(draweeHolder.getController())
.setImageRequest(imageRequest)
.setControllerListener(new BaseControllerListener<ImageInfo>() {
@Override
public void onFinalImageSet(String s, ImageInfo imageInfo, Animatable animatable) {
CloseableReference<CloseableImage> imageReference = null;
try {
imageReference = dataSource.getResult();
if (imageReference != null) {
CloseableImage image = imageReference.get();
if (image != null && image instanceof CloseableStaticBitmap) {
CloseableStaticBitmap closeableStaticBitmap = (CloseableStaticBitmap) image;
Bitmap bitmap = closeableStaticBitmap.getUnderlyingBitmap();
if (bitmap != null && imageView != null) {
imageView.setImageBitmap(bitmap);
}
}
}
} finally {
dataSource.close();
CloseableReference.closeSafely(imageReference);
}
}
})
.setTapToRetryEnabled(true)
.build();
draweeHolder.setController(controller);
}
示例8: displayImage
import com.facebook.drawee.view.DraweeHolder; //导入方法依赖的package包/类
@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);
}