fix: Task 6 완료 - RssHome Fragment onDestroyView 메모리 누수 및 콜백 정리
- RssHome.kt onDestroyView() 신규 구현: * infosJob?.cancel() 호출로 Realm Flow 수집 코루틴 취소 * commandHandler 및 mainHandler의 대기 중 콜백 제거(removeCallbacksAndMessages(null)) * home === this 조건으로 companion object의 정적 Fragment 참조 null 해제 - RssHome.kt loadImage(): mainHandler.postDelayed 재시도 콜백 실행 전 isAdded && view != null 검증 추가로 뷰 파괴 후 binding 접근 크래시 방지 - TODO.md: 1-1, 1-5 항목 완료 처리 - 검증: ./gradlew :app:compileDebugKotlin 빌드 성공 확인 (3s)
This commit is contained in:
@@ -1051,9 +1051,9 @@ internal class RssHome : RemoteGestureFragment() , KeyEventHandler {
|
||||
e?.printStackTrace()
|
||||
// Picasso.get().cancelRequest(imageView)
|
||||
if (retryCount > 0) {
|
||||
if (binding.layoutRssSummary.root.isVisible) {
|
||||
if (isAdded && view != null && binding.layoutRssSummary.root.isVisible) {
|
||||
mainHandler.postDelayed({
|
||||
if (binding.layoutRssSummary.root.isVisible) {
|
||||
if (isAdded && view != null && binding.layoutRssSummary.root.isVisible) {
|
||||
loadImage(imageView, url, retryCount - 1, isMain)
|
||||
}
|
||||
}, 3000L)
|
||||
@@ -1077,4 +1077,14 @@ internal class RssHome : RemoteGestureFragment() , KeyEventHandler {
|
||||
}
|
||||
fun randomOrNull() : RssData? = lasted.randomOrNull()
|
||||
|
||||
override fun onDestroyView() {
|
||||
infosJob?.cancel()
|
||||
commandHandler.removeCallbacksAndMessages(null)
|
||||
mainHandler.removeCallbacksAndMessages(null)
|
||||
if (home === this) {
|
||||
home = null
|
||||
}
|
||||
super.onDestroyView()
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user