Conversation
MVVM 패턴을 이용한 게시판입니다.
yunjaena
left a comment
There was a problem hiding this comment.
수고하셨습니다!! comment 추가한 부분 수정해주세요 :)
|
|
||
| override fun onResume() { | ||
| super.onResume() | ||
| mBinding.itemRcy.layoutManager = LinearLayoutManager(this,LinearLayoutManager.VERTICAL,false) |
There was a problem hiding this comment.
onCreate에서 초기화 하셔도 좋을 것 같습니다.
|
|
||
| override fun onCreate(savedInstanceState: Bundle?) { | ||
| super.onCreate(savedInstanceState) | ||
| mBinding=DataBindingUtil.setContentView(this,R.layout.activity_main) |
There was a problem hiding this comment.
이전에는 멤버 변수로 m을 붙였었지만 요즘 트랜드로는 m을 붙이지 않습니다. 그 이유로는 getter setter 를 사용하기 위해서입니다.
| import java.text.SimpleDateFormat | ||
| import java.util.* | ||
|
|
||
| class write_board : AppCompatActivity() { |
There was a problem hiding this comment.
Class 이름은 첫번째는 대문자 나머지는 camel case 입니다. => WriteBoard
Kotlin naming conventions
컨벤션은 다른 사람들과의 약속과 같으므로 지키는게 좋습니다 :)
| val time = dateFormat.format(date) | ||
|
|
||
| val item = Items(title,name,time) | ||
| model.finishButtonOnclick(item) |
There was a problem hiding this comment.
finishButtonOnClick 보다는 updateItem이 더 좋아보이네요 ~!
| } | ||
|
|
||
| fun setItems(view:RecyclerView){ | ||
| val items = ItemModel.getItemList() |
There was a problem hiding this comment.
AAC ViewModel에서는 View 관련된 것을 알면 안됩니다. 왜냐하면 화면을 회전에서 View가 Destroy가 되도 View 가 유지가 되기 때문인데요 지금과 같은 메서드 같은 경우는 다행히 model에서 유지하지 않아서 메모리 누수는 없겠지만 View 관련해서 업데이트가 필요할 경우는 LiveData와 같이 해당 상태를 구독을 해서 View단에서 업데이트를 해보세요 :) SingleLiveEvent 또는 Event 관련해서 검색해보시는 것도 좋아요
MVVM 패턴을 이용한 게시판입니다.