This repository has been archived by the owner on Feb 9, 2023. It is now read-only.
Fix NPE resulting from HoverViewState's callback after it already lost control #3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#1 이 PR에서 NPE fix 만 분리했습니다.
changeState()
), the NPE can occur because mHoverView has been set to null.mHasControl
) in each of the callbacks.기존 마스터 상태에서 샘플을 빌드해서 쓸때, State( = HoverViewStateClosed, HoverViewStateCollapsed, HoverViewStateExpanded 중 하나) 들을 빠르게 변경하면 (ex. Expanded 상태로 변하는 중에 백버튼 눌러서 Collapsed 로 만들기) 바로 NPE 가 발생하는 등 불안정한 상태였습니다.
원인을 분석해 보니 State 가 다른 State 로 전환될 때 이전 State 에서의 HoverView 에 대한 레퍼런스를 null 처리로 끊어버리는데, 몇가지 콜백들이 다른 State 로 전환된 이후에 발생할 수 있어서 모든 콜백에 대해 현재 컨트롤을 가지고 있는지 (기존에 정의되어 있던 변수, mHasControl) 를 확인하는 식으로 NPE 를 방지했습니다.