You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refactor: Optimize News Adapter and Fix Build Failures
Refactor: Optimize News Adapter Performance
- Created `NewsItem` data class to act as a presentation model for the news feed.
- Implemented `NewsItemMapper` to map `RealmNews` objects to `NewsItem` objects, moving JSON parsing and other expensive operations to a background coroutine.
- Refactored `AdapterNews` to use `NewsItem`, removing all JSON parsing from `onBindViewHolder`.
- Updated `NewsFragment`, `ReplyActivity`, and `DiscussionListFragment` to use the new `NewsItemMapper` and `NewsItem` data class.
Fix: Address build failure and regressions in news adapter refactor
This commit fixes several issues introduced in the initial refactoring of the news adapter:
- **Fixes Build Failure:** Resolves a Kotlin compiler internal error by updating the `setData` and `showReply` method signatures in `BaseNewsFragment` and `BaseTeamFragment` to match the new `NewsItem` data model, correcting the inheritance mismatch.
- **Fixes Functional Regression:** Re-implements the image download logic in `NewsFragment` that was accidentally removed, ensuring that images associated with news items are downloaded and displayed correctly.
- **Fixes UI Thread Blocking:** Replaces a synchronous `executeTransaction` call in `AdapterNews` with a non-blocking, lifecycle-aware coroutine to prevent blocking the UI thread when fetching data for labels.
- **Fixes Compilation Error:** Corrects a type mismatch in the `deletePost` call within the `AdapterNews` click listener.
This change addresses a performance bottleneck in the news feed, improving scrolling performance and overall user experience, while also ensuring the stability and functionality of the application.
0 commit comments