android - Recyclerview, otifyItemChanged() and image loaded by Picasso -


i have problem picasso cache (i think so). created recyclerview , recyclerview.adapter. single item on list contain imageview. imageview load image using picasso library this:

 public void onbindviewholder(pageviewholder holder, int position) {     final int positionadp = holder.getadapterposition();      (new picasso.builder(mcontext).addrequesthandler(new pagethumbrequesthandler(mpagescontainer.get()))             .build())             .load(pagethumbrequesthandler.request_scheme + "://" + mpages.get(positionadp).mtag)             .memorypolicy(memorypolicy.no_cache, memorypolicy.no_store)             .networkpolicy(networkpolicy.no_cache)             .into(holder.mthumbview);      holder.mthumbview.settag(mpages.get(positionadp).mtag);     holder.mthumbview.setonclicklistener(new view.onclicklistener() {         @override         public void onclick(view v) {             string tag = (string) v.gettag();             mpagelistener.onpageselected(tag);         }     });     holder.mlp.settext(integer.tostring(mpages.get(positionadp).mlp)); } 

when update item call notifyitemchanged method. on screen see updated item flicking, item invalidate correctly. new thumb not display - first loaded bitmap imageview.

you should not use holder.getadapterposition() this, recyclerview javadoc states:

[...] should use position parameter while acquiring related data item inside method , should not keep copy of it. if need position of item later on (e.g. in click listener), use getadapterposition() have updated adapter position.

so, not use getadapterposition() unless sure executed asynchronously unknown factors, such user interaction (ie. inside click or touch listener).

for first load of view holder, use position argument onbindviewholder(viewholder holder, int position) method, position of data in recycler's adapter.


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -