FredJul / Flym

Flym News Reader is a light Android feed reader (RSS/Atom)
Other
951 stars 405 forks source link

Fix crash on feeds with empty titles #717

Closed bfritz closed 4 years ago

bfritz commented 4 years ago

Fixes regression in 1ab426f where feeds with empty string titles crash with stack trace:

--------- beginning of system
10-28 21:39:33.569  1537  1564 I ActivityTaskManager: START u0 {cmp=net.frju.flym/.ui.main.MainActivity (has extras)} from uid 10131
10-28 21:39:33.579  1537  1564 W ActivityTaskManager: startActivity called from non-Activity context; forcing Intent.FLAG_ACTIVITY_NEW_TASK for: Intent { cmp=net.frju.flym/.ui.main.MainActivity (has extras) }
10-28 21:39:33.933  1537  1588 I DropBoxManagerService: add tag=system_app_strictmode isTagEnabled=true flags=0x2
--------- beginning of crash
10-28 21:39:34.383  8986  8986 E AndroidRuntime: FATAL EXCEPTION: main
10-28 21:39:34.383  8986  8986 E AndroidRuntime: Process: net.frju.flym, PID: 8986
10-28 21:39:34.383  8986  8986 E AndroidRuntime: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
10-28 21:39:34.383  8986  8986 E AndroidRuntime:    at java.util.ArrayList.get(ArrayList.java:437)
10-28 21:39:34.383  8986  8986 E AndroidRuntime:    at net.frju.flym.data.entities.Feed$Companion.getLettersForName(SourceFile:6)
10-28 21:39:34.383  8986  8986 E AndroidRuntime:    at net.frju.flym.data.entities.Feed$Companion.getLetterDrawable(SourceFile:2)
10-28 21:39:34.383  8986  8986 E AndroidRuntime:    at net.frju.flym.data.entities.Feed.getLetterDrawable(SourceFile:1)
10-28 21:39:34.383  8986  8986 E AndroidRuntime:    at net.frju.flym.ui.feeds.BaseFeedAdapter$FeedGroupViewHolder.bindItem(SourceFile:22)
10-28 21:39:34.383  8986  8986 E AndroidRuntime:    at net.frju.flym.ui.feeds.BaseFeedAdapter.onBindParentViewHolder(SourceFile:2)
10-28 21:39:34.383  8986  8986 E AndroidRuntime:    at net.frju.flym.ui.feeds.BaseFeedAdapter.onBindParentViewHolder(SourceFile:1)
10-28 21:39:34.383  8986  8986 E AndroidRuntime:    at com.bignerdranch.expandablerecyclerview.ExpandableRecyclerAdapter.onBindViewHolder(SourceFile:9)
10-28 21:39:34.383  8986  8986 E AndroidRuntime:    at androidx.recyclerview.widget.RecyclerView$Adapter.onBindViewHolder(SourceFile:1)
...

Fixes #716

bfritz commented 4 years ago

Possible solution for #716. It fixes the unit test I added to demonstrate the bug, but I did not test on device. I'm also not familiar with how Feed.getLetterDrawable() is used and it's possible there's a better return value than "".

Definitely won't be offended if it's closed without merging. Just didn't want to file an issue without a PR.

FredJul commented 4 years ago

Hi, thanks a lot for that fix! Since it may be important, I'll publish a new version soon with that bugfix.