유틸 추가 및 화면 목록 정렬 기능 추가#19
Conversation
boostcampth#2 NetworkUtil 을 생성 및 BroadcastReceiver 를 이용한 Network 상태 Observe boostcampth#3 Strategy Pattern 을 이용한 현재 목록 정렬 ( OS Version 에 따라 다른 로직 수행 ) boostcampth#4 BasePresenter 에 Detached Method 추가
| // 연결 상태 반환 | ||
| return currentNetworkStatus != null && currentNetworkStatus.isConnected(); | ||
| } | ||
| } |
There was a problem hiding this comment.
저같은 경우엔 잘못된 입력이나 변경을 막으려고 final 로 선언하여 사용하고 있습니다.
| } | ||
| } | ||
| }; | ||
|
|
There was a problem hiding this comment.
Broadcast Receiver 를 이용해 실시간으로 인터넷 연결 상태를 확인합니다.
변경이 된 경우 Util 을 통해 연결 상태를 가져오고 이를 Presenter 의 멤버 변수에 대입합니다
| binding.recyclerMovie.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL)); | ||
|
|
||
| // 최하단 스크롤 감지 | ||
| binding.recyclerMovie.setOnScrollListener(new RecyclerView.OnScrollListener(){ |
There was a problem hiding this comment.
Deprecated 된 Listener 를 변경하였습니다.
|
|
||
| private MovieListAdapter adapter; | ||
|
|
||
| private BroadcastReceiver mNetworkStatusReceiver = new BroadcastReceiver() { |
There was a problem hiding this comment.
모든 액티비티에서 Broadcast Receiver의 기능이 필요하다면 정적 리시버 사용은 어떠신가요??
There was a problem hiding this comment.
화면이 현재는 하나밖에 없어서 동적 리시버를 이용하였습니다.
추가로 정적 리시버의 경우에 등록/삭제를 직접하지 못하고 OS 버전이 올라가면서 많은 기능들이 제한되었다고 합니당.. 확장성을 고려해서 Receiver 를 상속받는 class 작성을 하도록 하겠습니다 감사합니다 ^_^
| public static final int HIGHEST_RATING_ORDER = 3; | ||
| public static final int LOWEST_RATING_ORDER = 4; | ||
|
|
||
| List<Movie> sort(List<Movie> list); |
There was a problem hiding this comment.
Interface에 상수를 정의하는 방법은 Anti-Pattern이라고 불리는 방법으로 알고 있습니다.
public static final int example = 1, enum , IntDef 와 같은 상수 정의 방법이 아닌
Interface 상수를 선택한 이유가 있을까요?
There was a problem hiding this comment.
현재 StrategyInterface 에 있는 상수는 Factory 에서만 사용하고 있어 상수가 다른 Class 의 네임스페이스를 오염시키지 않는다고 생각되어 사용했습니다. 다시 생각해보니 Factory 에 넣어두는게 더 적절했다고 생각됩니다. 좋은 지적 감사합니다 ! 그리고 IntDef 는 한번도 사용해보지 못했는데 이번에 이용해서 수정하도록 하겠습니다 !
( 24 버전 이상부터는 Stream API 를 이용, 이외에는 Collection.Sort 사용)