OutOfMemoryError with GenericDraweeHierarchy
See original GitHub issuejava.lang.OutOfMemoryError:
android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:594)
android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:429)
android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:840)
android.content.res.Resources.loadDrawable(Resources.java:2174)
android.content.res.Resources.getDrawable(Resources.java:716)
com.facebook.drawee.generic.GenericDraweeHierarchyInflater.getDrawable(GenericDraweeHierarchyInflater.java:227)
com.facebook.drawee.generic.GenericDraweeHierarchyInflater.updateBuilder(GenericDraweeHierarchyInflater.java:116)
com.facebook.drawee.generic.GenericDraweeHierarchyInflater.inflateBuilder(GenericDraweeHierarchyInflater.java:77)
com.facebook.drawee.view.GenericDraweeView.inflateHierarchy(GenericDraweeView.java:58)
com.facebook.drawee.view.GenericDraweeView.<init>(GenericDraweeView.java:43)
com.facebook.drawee.view.SimpleDraweeView.<init>(SimpleDraweeView.java:62)
I use GenericDraweeHierarchy to change PlaceholderImage with different color
/**
* 为SimpleDraweeView设置Controller
*
* @param simpleDraweeView 加载图片的simpleDraweeView
* @param gifView 表示图片是否是gif的imageview
* @param infos 图片数据
* @param position 选中图片的位置
* @param context Context
*/
private void setController(SimpleDraweeView simpleDraweeView, ImageView gifView, final List<AttachesEntity> infos, final int position, final Context context) {
String filepath = "" + infos.get(position).getUrl();
GenericDraweeHierarchy hierarchy = simpleDraweeView.getHierarchy();
if (random == null) {
random = new Random();
}
Drawable drawable = StaticUtil.ChangeColorsDrawable[random.nextInt(7)];
hierarchy.setPlaceholderImage(drawable);
hierarchy.setFailureImage(drawable);
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(getUriWithPath(filepath))
.setResizeOptions(new ResizeOptions(500, 500))
.build();
PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder()
.setOldController(simpleDraweeView.getController())
.setImageRequest(request)
.build();
simpleDraweeView.setController(controller);
simpleDraweeView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startViewpagerActivity(infos, position, context);
}
});
}
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Fresco : Display Wrong Image in listitems - android
I am using fersco library for loading local image. Initially i am displaying placeholder image in each item.Once the image is downloaded then...
Read more >GenericDraweeHierarchy - Fresco API
A SettableDraweeHierarchy that displays placeholder image until the actual image is set. If provided, failure image will be used in case of failure...
Read more >My Experience using Fresco - Medium
Massive improvement in OutOfMemory in Android 4.x and below ... You will have to create a GenericDraweeHierarchy to set things like placeholder.
Read more >Android – Images not loading in Fresco – iTecNote
GenericDraweeHierarchy@a0fa544 12-22 15:52:47.435 32462 32462 V ... Android – Strange OutOfMemory issue while loading an image to a Bitmap object.
Read more >Files.java example - Javatips.net
GenericDraweeHierarchy.java · GenericDraweeHierarchyBuilder.java ... MAX_VALUE) { throw new OutOfMemoryError("file is too large to fit in a byte array: " + ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Looks like largeHeap fixed this issue.
i also think so