android - Recycler view crashed while scrolling on resume of activity -


// recycleradpater code here :

public static final class viewholder extends recyclerview.viewholder {     imageview ivproperty;     imageview iveditproperty;     imageview ivdeleteproperty;     imageview ivproptranshistory;     imageview ivinspectreport;     textview tvmaintenreqcount;     textview tvpropname;     textview tvpropaddr;     textview tvpropstatus;     view view;      public viewholder(view v) {         super(v);         //initialize variables         ivproperty = (imageview) v.findviewbyid(r.id.ivproperty);         tvpropname = (textview) v.findviewbyid(r.id.tvpropname);         tvpropaddr = (textview) v.findviewbyid(r.id.tvpropaddr);         tvpropstatus = (textview) v.findviewbyid(r.id.tvpropstatus);         tvmaintenreqcount = (textview) v.findviewbyid(r.id.tvmaintenreqcount);         iveditproperty = (imageview) v.findviewbyid(r.id.iveditproperty);         ivproptranshistory = (imageview) v.findviewbyid(r.id.ivproptranshistory);         ivinspectreport = (imageview) v.findviewbyid(r.id.ivinspectreport);         ivdeleteproperty = (imageview) v.findviewbyid(r.id.ivdeleteproperty);         view = v;     } }  // recycler adpter   private final class propertyrecycleradapter extends recyclerview.adapter<propertylistactivity.viewholder> {      final context _context;     list<propertylistdto> objects;      public propertyrecycleradapter(context context, list<propertylistdto> objects) {         this._context = context;         this.objects = objects;     }      @override     public viewholder oncreateviewholder(viewgroup parent, int viewtype) {         // create new view         view view = layoutinflater.from(parent.getcontext()).inflate(r.layout.row_property_list, parent, false);         // set view's size, margins, paddings , layout parameters         viewholder v = new viewholder(view);         return v;     }      public void setfilter(list<propertylistdto> list) {         objects = new arraylist<propertylistdto>();         objects.addall(list);         notifydatasetchanged();     }      // bindview holder      @override     public void onbindviewholder(final viewholder holder, int position) {         // - element data set @ position         // - replace contents of view element         string propimgurl = "";         final propertylistdto p = objects.get(position);         // load bitmap drawable folder         try {             // set data value              holder.tvpropname.settext(p.getpropertyname());             holder.tvpropaddr.settext(p.getaddress());             if (p.getinspectionreports() != null) {                 if (p.getinspectionreports() != null && p.getpropstatus().equalsignorecase("0")) {                     holder.tvpropstatus.settext(_context.getresources().getstring(r.string.property_status_0));                     holder.ivinspectreport.setvisibility(view.gone);                 } else if (p.getinspectionreports() != null && p.getpropstatus().equalsignorecase("1")) {                     holder.tvpropstatus.settext(_context.getresources().getstring(r.string.property_status_1));                     holder.iveditproperty.setvisibility(view.visible);                     holder.ivinspectreport.setvisibility(view.gone);                 } else if (p.getinspectionreports() != null && p.getpropstatus().equalsignorecase("2")) {                     holder.tvpropstatus.settext(_context.getresources().getstring(r.string.property_status_2));                     holder.iveditproperty.setvisibility(view.gone);                     holder.ivinspectreport.setvisibility(view.gone); //holder.ivinspectreport.setvisibility(view.visible)                 } else if (p.getinspectionreports() != null && p.getpropstatus().equalsignorecase("3")) {                     holder.tvpropstatus.settext(_context.getresources().getstring(r.string.property_status_3));                     holder.iveditproperty.setvisibility(view.gone);                     holder.ivinspectreport.setvisibility(view.visible);                 } else if (p.getinspectionreports() != null && p.getpropstatus().equalsignorecase("4")) {                     holder.tvpropstatus.settext(_context.getresources().getstring(r.string.property_status_4));                     holder.iveditproperty.setvisibility(view.visible);                     holder.ivinspectreport.setvisibility(view.visible);                 } else if (p.getinspectionreports() != null && p.getpropstatus().equalsignorecase("5")) {                     holder.tvpropstatus.settext(_context.getresources().getstring(r.string.property_status_5));                     holder.iveditproperty.setvisibility(view.gone);                     holder.ivinspectreport.setvisibility(view.visible);                 } else if (p.getinspectionreports() != null && p.getpropstatus().equalsignorecase("6")) {                     holder.tvpropstatus.settext(_context.getresources().getstring(r.string.property_status_6));                     holder.iveditproperty.setvisibility(view.gone);                     holder.ivinspectreport.setvisibility(view.visible);                 } else if (p.getinspectionreports() != null && p.getpropstatus().equalsignorecase("7")) {                     holder.tvpropstatus.settext(_context.getresources().getstring(r.string.property_status_7));                     holder.iveditproperty.setvisibility(view.gone);                     holder.ivinspectreport.setvisibility(view.visible);                 } else {                     holder.tvpropstatus.settext(_context.getresources().getstring(r.string.property_status_0));                     holder.ivinspectreport.setvisibility(view.gone);                 }             } else {                  if (p.getpropstatus().equalsignorecase("0")) {                     holder.tvpropstatus.settext(_context.getresources().getstring(r.string.property_status_0));                     holder.iveditproperty.setvisibility(view.visible);                     holder.ivinspectreport.setvisibility(view.gone);                 } else if (p.getpropstatus().equalsignorecase("1")) {                     holder.tvpropstatus.settext(_context.getresources().getstring(r.string.property_status_1));                     holder.iveditproperty.setvisibility(view.visible);                     holder.ivinspectreport.setvisibility(view.gone);                 } else if (p.getpropstatus().equalsignorecase("2")) {                     holder.tvpropstatus.settext(_context.getresources().getstring(r.string.property_status_2));                     holder.iveditproperty.setvisibility(view.visible);                     holder.ivinspectreport.setvisibility(view.visible);                 } else if (p.getpropstatus().equalsignorecase("3")) {                     holder.tvpropstatus.settext(_context.getresources().getstring(r.string.property_status_3));                     holder.iveditproperty.setvisibility(view.gone);                     holder.ivinspectreport.setvisibility(view.visible);                 }                holder.tvmaintenreqcount.settext("(" + p.getmaintenance_request_count() + ")");             if (p.getgallery() != null && p.getgallery().size() > 0) {                 propimgurl = appconstants.property_images_path + p.getgallery().get(0).tostring();             }             if (!textutils.isempty(propimgurl)) {                 picasso.with(context).load(propimgurl).error(r.mipmap.home_profile).into(holder.ivproperty);             } else {              }              android.util.log.e("imageurl list =>", propimgurl.tostring());           } catch (exception e) {             e.printstacktrace();         }           // click listener  view property detail                            holder.view.setonclicklistener(new view.onclicklistener() {             @override             public void onclick(view v) {                  intent intent = new intent(context, viewpropdetailsfragment.class);                 intent.putextra("propdetails", p);                 startactivity(intent);             }         });           // edit property detail info          holder.iveditproperty.setonclicklistener(new view.onclicklistener() {             @override             public void onclick(view v) {                  intent intent = new intent(propertylistactivity.this, editpropprimdetailsactivity.class);                 intent.putextra("propertylistdto", p);                 startactivity(intent);              }         });           holder.ivproptranshistory.setonclicklistener(new view.onclicklistener() {             @override             public void onclick(view v) {                  propertytransactionfragment propertytransactionfragment = new propertytransactionfragment();                 fragmenttransaction transaction = getsupportfragmentmanager().begintransaction();                 bundle bundle = new bundle();                 bundle.putstring("property_id", p.getid().get$id());                 bundle.putstring("p_id", p.getpropertyid());                 bundle.putstring("property_name", p.getpropertyname());                 propertytransactionfragment.setarguments(bundle);                 transaction.replace(r.id.container, propertytransactionfragment);                  transaction.addtobackstack("propertytransactionfragment");                 transaction.commit();             }         });      }       @override     public int getitemcount() {         return objects.size();     } }   

// log error :

e/androidruntime: fatal exception: main process: com.excellenceit.propcare, pid: 9927 java.lang.indexoutofboundsexception: inconsistency detected. invalid item position 4(offset:4).state:9 @ android.support.v7.widget.recyclerview$recycler.getviewforposition(recyclerview.java:4957) @ android.support.v7.widget.recyclerview$recycler.getviewforposition(recyclerview.java:4913) @ android.support.v7.widget.linearlayoutmanager$layoutstate.next(linearlayoutmanager.java:2029) @ android.support.v7.widget.linearlayoutmanager.layoutchunk(linearlayoutmanager.java:1414) @ android.support.v7.widget.linearlayoutmanager.fill(linearlayoutmanager.java:1377) @ android.support.v7.widget.linearlayoutmanager.scrollby(linearlayoutmanager.java:1193) @ android.support.v7.widget.linearlayoutmanager.scrollverticallyby(linearlayoutmanager.java:1043) @ android.support.v7.widget.recyclerview.scrollbyinternal(recyclerview.java:1552) @ android.support.v7.widget.recyclerview.ontouchevent(recyclerview.java:2649) @ android.view.view.dispatchtouchevent(view.java:8968) @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2698) @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:2410) @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2709) @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:2425) @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2709) @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:2425) @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2709) @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:2425) @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2709) @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:2425) @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2709) @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:2425) @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2709) @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:2425) @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2709) @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:2425) @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2709) @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:2425) @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2709) @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:2425) @ com.android.internal.policy.impl.phonewindow$decorview.superdispatchtouchevent(phonewindow.java:2568) @ com.android.internal.policy.impl.phonewindow.superdispatchtouchevent(phonewindow.java:1776) @ android.app.activity.dispatchtouchevent(activity.java:2866) @ android.support.v7.view.windowcallbackwrapper.dispatchtouchevent(windowcallbackwrapper.java:63) @ com.android.internal.policy.impl.phonewindow$decorview.dispatchtouchevent(phonewindow.java:2529) @ android.view.view.dispatchpointerevent(view.java:9173) @ android.view.viewrootimpl$viewpostimeinputstage.processpointerevent(viewrootimpl.java:4706) @ android.view.viewrootimpl$viewpostimeinputstage.onprocess(viewrootimpl.java:4544) @ android.view.viewrootimpl$inputstage.deliver(viewrootimpl.java:4068) @ android.view.viewrootimpl$inputstage.ondelivertonext(viewrootimpl.java:4121) @ android.view.viewrootimpl$inputstage.forward(viewrootimpl.java:4087) @ android.view.viewrootimpl$asyncinputstage.forward(viewrootimpl.java:4201) @ android.view.viewrootimpl$inputstage.apply(viewrootimpl.java:4095) @ android.view.viewrootimpl$asyncinputstage.apply(viewrootimpl.java:4258) @ android.view.viewrootimpl$inputstage.deliver(viewrootimpl.java:4068) @ android.view.viewrootimpl$inputstage.ondelivertonext(viewrootimpl.java:4121) @ android.view.viewrootimpl$inputstage.forward(viewrootimpl.java:4087) @ android.view.viewrootimpl$inputstage.apply(viewrootimpl.java:4095) @ android.view.viewrootimpl$inputstage.deliver(viewrootimpl.java:4068) @ android.view.viewrootimpl

there wrong position in onbindviewholder data list or data array might not have data position.


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -