무한 스크롤(프리 로딩) 에러 해결#5
Open
ch-Yoon wants to merge 1 commit into
Open
Conversation
When the movie information was received using the search button, I solved preloading error by clearing the adapter list.
sabgilhun
reviewed
Jan 20, 2019
| // 마지막 페이지가 아니고 로딩중 아닌 경우 getMovieList 호출 | ||
| if(!isLoading.get() && !isEndOfPage) { | ||
| getMovieList(); | ||
| } else if(isRefresh) { |
There was a problem hiding this comment.
loadItems() 메서드에서 isLoading.get() == true이면 아이템 클리어 동작도 안하게 하는 방법은 어떨까요?
Author
There was a problem hiding this comment.
저는 error를 해결하기 위해 getMovieList() 함수 내부를 수정하였습니다.
다만, 해당 부분만 수정하여도 정상작동되기에 추가적인 처리를 해주지 않았습니다.
말씀해주신 내용을 반영하는 것도 좋을 것으로 판단됩니다. 감사합니다.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
개요
에러 내용
무한 스크롤 기능이 특정 시나리오에서 오류가 발생되는 것을 확인했습니다.
위의 시나리오대로 진행을 하면, 검색 버튼을 눌러서 요청한 새로운 영화 정보가
리스트의 가장 상단에 노출되어야 할 것이라고 생각했습니다.
하지만 새로운 영화 정보가 아닌 ,스크롤에 요청된 추가 영화 정보가 리스트의 가장 상단에
위치하는 것으로 확인했습니다.
GIF 파일을 첨부하였습니다. 스크롤을 한 뒤 빠르게 검색 버튼을 누르면,
처음과는 다른 영화가 리스트 가장 상단에 노출되는 것을 확인하실 수 있습니다.
에러 원인
다음과 같은 이유로 인해 상위에서 설명한 에러가 발생됩니다.
(Adapter에서 20개 item 보유)(초기화 작업으로 인해 Adpater에서 0개 item 보유)(Adapter에서 20개 item 보유)지금까지 설명한 시나리오로 진행되면, 검색 버튼을 눌렀지만 API 서버에 존재하는 1 ~ 20의 영화 정보가 아닌 21 ~ 40의 영화 정보가 list의 가장 상단에 노출됩니다.
해결 방안
검색 버튼 클릭 후 repository로부터 item을 수신합니다.
이때, 요청했었던 start 값이 만약 1이라면, adapter의 list size를 확인합니다.
만약 list size가 0이 아니라면 list를 clear하는 방법으로 error를 해결했습니다.