Make FeedItemUtil.getLinkWithFallback(item) tolerates null item.

This commit is contained in:
orionlee 2018-04-30 15:49:18 -07:00
parent 345fcc17d0
commit ab0f413185
2 changed files with 10 additions and 7 deletions

View File

@ -81,13 +81,16 @@ public class FeedItemUtil {
* use the feed's link if the named feed item has no link.
*/
public static String getLinkWithFallback(FeedItem item) {
String link = item.getLink();
if (link == null) {
Feed feed = item.getFeed();
if (feed != null) {
link = feed.getLink();
String link = null;
if (item != null) {
link = item.getLink();
if (link == null) {
Feed feed = item.getFeed();
if (feed != null) {
link = feed.getLink();
}
}
}
} // else null item, can only return null
return link;
}
}

View File

@ -51,7 +51,7 @@ public class ShareUtils {
}
public static boolean hasLinkToShare(FeedItem item) {
return ( item != null && FeedItemUtil.getLinkWithFallback(item) != null );
return FeedItemUtil.getLinkWithFallback(item) != null;
}
public static void shareFeedItemLink(Context context, FeedItem item, boolean withPosition) {