Skip to content

Commit

Permalink
Ensure to verify that blog.url is not null before using it. While it …
Browse files Browse the repository at this point in the history
…should never occur that the URL is null, it's better to err on the side of caution.
  • Loading branch information
daniloercoli committed Feb 7, 2024
1 parent fc1ffd8 commit 56d0d8c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ class SubFilterViewModel @Inject constructor(
}.sortedWith(Comparator { blog1, blog2 ->
// sort followed blogs by name/domain to match display
val blogOneName = getBlogNameForComparison(blog1)
val blogNameTwo = getBlogNameForComparison(blog2)
blogOneName.compareTo(blogNameTwo, true)
val blogTwoName = getBlogNameForComparison(blog2)
blogOneName.compareTo(blogTwoName, true)
})

filterList.addAll(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ sealed class SubfilterListItem(val type: ItemType, val isTrackedItem: Boolean =
override val label: UiString = if (blog.name.isNotEmpty()) {
UiStringText(blog.name)
} else {
UiStringText(if (blog.url.isNotEmpty()) UrlUtils.getHost(blog.url) else "")
if (blog.url.isNotEmpty()) UiStringText(UrlUtils.getHost(blog.url))
else UiStringRes(R.string.reader_untitled_post)
}
val showUnseenCount: Boolean = blog.numUnseenPosts > 0
val unseenCount: Int = blog.numUnseenPosts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,11 @@ private void showBlogInfo(ReaderBlog blogInfo, String source) {
if (blogInfo.hasName()) {
txtBlogName.setText(blogInfo.getName());
} else {
txtBlogName.setText(UrlUtils.getHost(blogInfo.getUrl()));
if (blogInfo.getUrl() != null) {
txtBlogName.setText(UrlUtils.getHost(blogInfo.getUrl()));
} else {
txtBlogName.setText(R.string.reader_untitled_post);
}
}

if (blogInfo.hasUrl()) {
Expand Down

0 comments on commit 56d0d8c

Please sign in to comment.