Merge pull request #847 from TomHennen/fix_npes

Fix NullPointerExceptions
This commit is contained in:
Tom Hennen 2015-06-01 17:56:40 -04:00
commit 01de68003a
2 changed files with 8 additions and 5 deletions

View File

@ -120,7 +120,8 @@ public class FeedInfoActivity extends ActionBarActivity {
}); });
txtvTitle.setText(feed.getTitle()); txtvTitle.setText(feed.getTitle());
txtvDescription.setText(feed.getDescription().trim()); String description = feed.getDescription();
txtvDescription.setText((description != null) ? description.trim() : "");
if (feed.getAuthor() != null) { if (feed.getAuthor() != null) {
txtvAuthor.setText(feed.getAuthor()); txtvAuthor.setText(feed.getAuthor());
} }

View File

@ -365,10 +365,12 @@ public class MainActivity extends ActionBarActivity implements NavDrawerActivity
return -1; return -1;
} else { // last fragment was not a list, but a feed } else { // last fragment was not a list, but a feed
long feedId = Long.parseLong(lastFragment); long feedId = Long.parseLong(lastFragment);
List<Feed> feeds = navDrawerData.feeds; if (navDrawerData != null) {
for (int i = 0; i < feeds.size(); i++) { List<Feed> feeds = navDrawerData.feeds;
if (feeds.get(i).getId() == feedId) { for (int i = 0; i < feeds.size(); i++) {
return i + navAdapter.getSubscriptionOffset(); if (feeds.get(i).getId() == feedId) {
return i + navAdapter.getSubscriptionOffset();
}
} }
} }
return -1; return -1;