android - Fatal Exception during scrolling a ListView -


the app runs fine until scroll few times in listview.

this error got logcat. code custom baseadapter used below it.

07-31 10:08:43.550: e/androidruntime(32570): fatal exception: main 07-31 10:08:43.550: e/androidruntime(32570): java.lang.nullpointerexception 07-31 10:08:43.550: e/androidruntime(32570):    @ com.duobility.leathr.homescreen$timelineadapter.getview(homescreen.java:485) 07-31 10:08:43.550: e/androidruntime(32570):    @ com.haarman.listviewanimations.baseadapterdecorator.getview(baseadapterdecorator.java:87) 07-31 10:08:43.550: e/androidruntime(32570):    @ com.haarman.listviewanimations.swinginadapters.animationadapter.getview(animationadapter.java:94) 07-31 10:08:43.550: e/androidruntime(32570):    @ android.widget.abslistview.obtainview(abslistview.java:2452) 07-31 10:08:43.550: e/androidruntime(32570):    @ android.widget.listview.makeandaddview(listview.java:1775) 07-31 10:08:43.550: e/androidruntime(32570):    @ android.widget.listview.filldown(listview.java:678) 07-31 10:08:43.550: e/androidruntime(32570):    @ android.widget.listview.fillgap(listview.java:642) 07-31 10:08:43.550: e/androidruntime(32570):    @ android.widget.abslistview.trackmotionscroll(abslistview.java:5709) 07-31 10:08:43.550: e/androidruntime(32570):    @ android.widget.abslistview.scrollifneeded(abslistview.java:3420) 07-31 10:08:43.550: e/androidruntime(32570):    @ android.widget.abslistview.ontouchevent(abslistview.java:4085) 07-31 10:08:43.550: e/androidruntime(32570):    @ android.view.view.dispatchtouchevent(view.java:7341) 07-31 10:08:43.550: e/androidruntime(32570):    @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2460) 07-31 10:08:43.550: e/androidruntime(32570):    @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:2195) 07-31 10:08:43.550: e/androidruntime(32570):    @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2466) 07-31 10:08:43.550: e/androidruntime(32570):    @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:2209) 07-31 10:08:43.550: e/androidruntime(32570):    @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2466) 07-31 10:08:43.550: e/androidruntime(32570):    @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:2209) 07-31 10:08:43.550: e/androidruntime(32570):    @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2466) 07-31 10:08:43.550: e/androidruntime(32570):    @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:2209) 07-31 10:08:43.550: e/androidruntime(32570):    @ android.view.viewgroup.dispatchtransformedtouchevent(viewgroup.java:2466) 07-31 10:08:43.550: e/androidruntime(32570):    @ android.view.viewgroup.dispatchtouchevent(viewgroup.java:2209) 07-31 10:08:43.550: e/androidruntime(32570):    @ com.android.internal.policy.impl.phonewindow$decorview.superdispatchtouchevent(phonewindow.java:2115) 07-31 10:08:43.550: e/androidruntime(32570):    @ com.android.internal.policy.impl.phonewindow.superdispatchtouchevent(phonewindow.java:1468) 07-31 10:08:43.550: e/androidruntime(32570):    @ android.app.activity.dispatchtouchevent(activity.java:2487) 07-31 10:08:43.550: e/androidruntime(32570):    @ com.android.internal.policy.impl.phonewindow$decorview.dispatchtouchevent(phonewindow.java:2063) 07-31 10:08:43.550: e/androidruntime(32570):    @ android.view.view.dispatchpointerevent(view.java:7526) 07-31 10:08:43.550: e/androidruntime(32570):    @ android.view.viewrootimpl.deliverpointerevent(viewrootimpl.java:3505) 07-31 10:08:43.550: e/androidruntime(32570):    @ android.view.viewrootimpl.deliverinputevent(viewrootimpl.java:3437) 07-31 10:08:43.550: e/androidruntime(32570):    @ android.view.viewrootimpl.doprocessinputevents(viewrootimpl.java:4541) 07-31 10:08:43.550: e/androidruntime(32570):    @ android.view.viewrootimpl.enqueueinputevent(viewrootimpl.java:4519) 07-31 10:08:43.550: e/androidruntime(32570):    @ android.view.viewrootimpl$windowinputeventreceiver.oninputevent(viewrootimpl.java:4623) 07-31 10:08:43.550: e/androidruntime(32570):    @ android.view.inputeventreceiver.dispatchinputevent(inputeventreceiver.java:171) 07-31 10:08:43.550: e/androidruntime(32570):    @ android.view.inputeventreceiver.nativeconsumebatchedinputevents(native method) 07-31 10:08:43.550: e/androidruntime(32570):    @ android.view.inputeventreceiver.consumebatchedinputevents(inputeventreceiver.java:163) 07-31 10:08:43.550: e/androidruntime(32570):    @ android.view.viewrootimpl.doconsumebatchedinput(viewrootimpl.java:4591) 07-31 10:08:43.550: e/androidruntime(32570):    @ android.view.viewrootimpl$consumebatchedinputrunnable.run(viewrootimpl.java:4642) 07-31 10:08:43.550: e/androidruntime(32570):    @ android.view.choreographer$callbackrecord.run(choreographer.java:725) 07-31 10:08:43.550: e/androidruntime(32570):    @ android.view.choreographer.docallbacks(choreographer.java:555) 07-31 10:08:43.550: e/androidruntime(32570):    @ android.view.choreographer.doframe(choreographer.java:523) 07-31 10:08:43.550: e/androidruntime(32570):    @ android.view.choreographer$framedisplayeventreceiver.run(choreographer.java:711) 07-31 10:08:43.550: e/androidruntime(32570):    @ android.os.handler.handlecallback(handler.java:615) 07-31 10:08:43.550: e/androidruntime(32570):    @ android.os.handler.dispatchmessage(handler.java:92) 07-31 10:08:43.550: e/androidruntime(32570):    @ android.os.looper.loop(looper.java:137) 07-31 10:08:43.550: e/androidruntime(32570):    @ android.app.activitythread.main(activitythread.java:4898) 07-31 10:08:43.550: e/androidruntime(32570):    @ java.lang.reflect.method.invokenative(native method) 07-31 10:08:43.550: e/androidruntime(32570):    @ java.lang.reflect.method.invoke(method.java:511) 07-31 10:08:43.550: e/androidruntime(32570):    @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1008) 07-31 10:08:43.550: e/androidruntime(32570):    @ com.android.internal.os.zygoteinit.main(zygoteinit.java:775) 07-31 10:08:43.550: e/androidruntime(32570):    @ dalvik.system.nativestart.main(native method) 

this custom baseadatper

private class timelineadapter extends baseadapter {

timestamphandler timestamphandler = new timestamphandler(); imageoptions iconimageoptions, photoimageoptions = new imageoptions();  long currentunixtime = (system.currenttimemillis())/1000; string currentmonthyear = timestamphandler.get_mmyyyy(currentunixtime); arraylist<timelineobject> montharray = getmonthentry(currentmonthyear);  @override public int getcount() {     return montharray.size(); }  @override public object getitem(int position) {     return montharray.get(position); }  @override public long getitemid(int position) {     return position; }  @override public view getview(int position, view convertview, viewgroup parent) {      timelineviewholder holder;     photoimageoptions.round = 5;     photoimageoptions.filecache = true;     photoimageoptions.memcache = true;      if (convertview == null) {         holder = new timelineviewholder();         // find type of card entry /////         if ( (montharray.get(position).type).equals(appconstants.type_picture) ) {              log.d(appconstants.home_screen, "thumbnailarraysize: " + montharray.get(position).photothumbnailarraylist.size());              if (montharray.get(position).photothumbnailarraylist.size() == 1) {                 convertview = getlayoutinflater().inflate(r.layout.photo_card_1, parent, false);                 holder.photo1 = (imageview) convertview.findviewbyid(r.id.photo1);              } else if (montharray.get(position).photothumbnailarraylist.size() == 2) {                 convertview = getlayoutinflater().inflate(r.layout.photo_card_2, parent, false);                 holder.photo1 = (imageview) convertview.findviewbyid(r.id.photo1);                 holder.photo2 = (imageview) convertview.findviewbyid(r.id.photo2);              } else if (montharray.get(position).photothumbnailarraylist.size() == 3) {                 convertview = getlayoutinflater().inflate(r.layout.photo_card_3, parent, false);                 holder.photo1 = (imageview) convertview.findviewbyid(r.id.photo1);                 holder.photo2 = (imageview) convertview.findviewbyid(r.id.photo2);                 holder.photo3 = (imageview) convertview.findviewbyid(r.id.photo3);                 holder.phototext = (textview) convertview.findviewbyid(r.id.phototext);              }              holder.photodate = (textview) convertview.findviewbyid(r.id.photodate);             convertview.settag(holder);          } else if ( (montharray.get(position).type).equals(appconstants.type_text) ) {              convertview = getlayoutinflater().inflate(r.layout.message_card, parent, false);             holder.iconimageview = (imageview) convertview.findviewbyid(r.id.iconimageview);             holder.messagecontent = (textview) convertview.findviewbyid(r.id.messagecontent);             holder.messagedate = (textview) convertview.findviewbyid(r.id.messagedate);             convertview.settag(holder);          } else if ( (montharray.get(position).type).equals(appconstants.type_link) ) {              convertview = getlayoutinflater().inflate(r.layout.link_card, parent, false);             holder.iconimageview = (imageview) convertview.findviewbyid(r.id.iconimageview);             holder.linkcontent = (textview) convertview.findviewbyid(r.id.linkcontent);             holder.linkdate = (textview) convertview.findviewbyid(r.id.linkdate);             convertview.settag(holder);          } else if ( (montharray.get(position).type).equals(appconstants.type_location) ) {              convertview = getlayoutinflater().inflate(r.layout.location_card, parent, false);             holder.iconimageview = (imageview) convertview.findviewbyid(r.id.iconimageview);             holder.locationcontent = (textview) convertview.findviewbyid(r.id.locationcontent);             holder.locationdate = (textview) convertview.findviewbyid(r.id.locationdate);             convertview.settag(holder);          }         // end of card type ////////////////////////     } else {         holder = (timelineviewholder) convertview.gettag();     }      if ( (montharray.get(position).type.equals(appconstants.type_picture)) ) {          // todo deal photo albums         long unixtime = long.parselong( montharray.get(position).unixtime );         int cardwidth = (displaymetrics.widthpixels)-32;          if (montharray.get(position).photothumbnailarraylist.size() == 1) {             string photourl = montharray.get(position).thumbnail.replace("s144/", "w" + cardwidth + "/");             aquery.id(holder.photo1).image(photourl, photoimageoptions);          } else if (montharray.get(position).photothumbnailarraylist.size() == 2) {             string photourl1 = montharray.get(position).photothumbnailarraylist.get(0).replace("s144/", "w" + (cardwidth/2) + "/");             string photourl2 = montharray.get(position).photothumbnailarraylist.get(1).replace("s144/", "w" + (cardwidth/2) + "/");             aquery.id(holder.photo1).image(photourl1, photoimageoptions);             aquery.id(holder.photo2).image(photourl2, photoimageoptions);          } else if (montharray.get(position).photothumbnailarraylist.size() == 3) {             string photourl1 = montharray.get(position).photothumbnailarraylist.get(0).replace("s144/", "w" + (cardwidth/3) + "/");             string photourl2 = montharray.get(position).photothumbnailarraylist.get(1).replace("s144/", "w" + (cardwidth/3) + "/");             string photourl3 = montharray.get(position).photothumbnailarraylist.get(2).replace("s144/", "w" + (cardwidth/3) + "/");             aquery.id(holder.photo1).image(photourl1, photoimageoptions);             aquery.id(holder.photo2).image(photourl2, photoimageoptions);             aquery.id(holder.photo3).image(photourl3, photoimageoptions);             holder.phototext.settext(timestamphandler.get_dayfulllenght(unixtime));          }         holder.photodate.settext(timestamphandler.get_dd_mmm(unixtime));         log.d(appconstants.home_screen, "photo card created");      } else if ( (montharray.get(position).type.equals(appconstants.type_text)) ) {          long unixtime = long.parselong( montharray.get(position).unixtime );         holder.messagedate.settext(timestamphandler.get_dd_mmm(unixtime));         holder.messagecontent.settext(montharray.get(position).content);         log.d(appconstants.home_screen, "text card created");      } else if ( (montharray.get(position).type.equals(appconstants.type_link)) ) {          long unixtime = long.parselong( montharray.get(position).unixtime );         holder.linkdate.settext(timestamphandler.get_dd_mmm(unixtime));         holder.linkcontent.settext(montharray.get(position).content);         log.d(appconstants.home_screen, "link card created");      } else if ( (montharray.get(position).type.equals(appconstants.type_location)) ) {          long unixtime = long.parselong( montharray.get(position).unixtime );         holder.locationdate.settext(timestamphandler.get_dd_mmm(unixtime));         holder.locationcontent.settext(montharray.get(position).content);         log.d(appconstants.home_screen, "location card created");      }      return convertview; } 

}

edit: line 485 below

holder.phototext.settext(timestamphandler.get_dayfulllenght(unixtime)); 

the exception means phototext == null. either because:

  • montharray.get(position).photothumbnailarraylist.size() != 3
  • or r.layout.photo_card_3 doesn't have textview id @+id/phototext

check both case!


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -