bitmap - Android load image into imageview efficiently -


i have next problem: avoid outofmemoryerror i'm loading big images imageviews using picasso in such way:

public static requestcreator picasso(final context context, final int resourceid) {     return picasso.with(context)             .load(resourceid)             .fit()             .centercrop()             .nofade(); } 

and in activity or fragment, i'm loading image imageview

final imageview backgroundimage = (imageview) root.findviewbyid(r.id.background_image); util.picasso(getactivity(),r.drawable.background_soulmap)             .into(backgroundimage); 

however, have 2 problems:

  1. image loads delay (but need load immideatly)
  2. centercrop() not need in cases.

    how can implement topcrop() or bottomcrop()? i've tried https://github.com/cesards/cropimageview library, i'm getting nullpointerexception in setframe() method (getdrawable() returns null), because image did not load yet. in advance!

image loads delay (but need load immideatly)

you have choose: (a) memory efficient delay or (b) instant probable oom. , said experience, app have on play store have little delay while picasso processing it. it's how works.

centercrop() not need in cases.

then should load image into() target. target receive drawable in ui thread, there can set inside imageview (using setscaletype) or background anyway want. maybe using insetdrawable adjust position.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -