Android : "If-else" statement going down the wrong section in step debug

on Tuesday, August 12, 2014


Hopefully a simple answer but I'm a little baffled. I'm expecting the code to go down the first if section below, but it always goes to the else.


When I get to line on a breakpoint >> if (url2!=null && !url2.isEmpty()) In the expressions window:



  • url2 IS "???/wp-content/uploads/2011/01/toonieJune10_091-640x334.jpg"

  • url2!=null IS true

  • !url2.isEmpty() IS true


However when debugging it always seems to hit the else, even though both conditions are true. I'm suspecting something is out of sync with my built code somehow as the step through debugging seems to give me inconsistencies.


I've tried cleaning the code and making some changes in the class and recompiling etc.


Help is much appreciated! Thanks!





public String getImageBannerUrl()
{
if (getPhotoFile1()!=null) return getPhotoFile1().getUrl();
String url2 = getRemoteImageUrl();

if (url2!=null && !url2.isEmpty())
{
return url2;
}
else
{
//Otherwise get default image based on category
return getImageCategoryUrl();
}
}

0 comments:

Post a Comment