Fix RecyclerView Inconsistency Crash in NovelReviewListActivity#169
Fix RecyclerView Inconsistency Crash in NovelReviewListActivity#169
Conversation
…lerView inconsistency. - Refactor `Wenku8Parser.parseReviewList` to return a new `ReviewList` instead of modifying the argument, ensuring thread safety. - Update `NovelReviewListActivity.AsyncReviewListLoader` to perform parsing in `doInBackground` and update the UI (and backing list) in `onPostExecute`. - Properly use `notifyDataSetChanged` for reload and `notifyItemRangeInserted` for loading more items, preventing `Inconsistency detected` crashes. - Improve UX by not clearing the list immediately on reload, preventing flickering. Co-authored-by: MewX <[email protected]>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Co-authored-by: MewX <[email protected]>
Fixed
IndexOutOfBoundsException: Inconsistency detectedcrash inNovelReviewListActivity.The crash was caused by
Wenku8Parser.parseReviewListmodifying theReviewList(which backs theRecyclerViewadapter) on a background thread while theRecyclerViewwas layouting/scrolling on the main thread.Additionally, the adapter was notified incorrectly using
notifyItemRangeChangedeven when items were added.Changes:
Wenku8Parser.parseReviewListto be a pure function that returns a newReviewListobject instead of modifying the passed instance.AsyncReviewListLoaderinNovelReviewListActivity:doInBackgroundto return the parsedReviewList.onPostExecuteto update the mainreviewListand notify the adapter on the main thread.notifyDataSetChangedfor full reloads andnotifyItemRangeInsertedfor appending items.isReloadflag to handle logic for pull-to-refresh vs load-more correctly.reloadAllReviewsto use the new loader logic without clearing the list prematurely.PR created automatically by Jules for task 9747062809248964075 started by @MewX