Skip to content

12주차 실습과제 (2)#5

Open
Ssunghyn wants to merge 1 commit intomainfrom
Assignment8_MVVM
Open

12주차 실습과제 (2)#5
Ssunghyn wants to merge 1 commit intomainfrom
Assignment8_MVVM

Conversation

@Ssunghyn
Copy link
Owner

MVVM 패턴을 이용한 게시판입니다.

MVVM 패턴을 이용한 게시판입니다.
@Ssunghyn Ssunghyn requested review from ksu9080 and yunjaena July 11, 2021 06:01
Copy link
Collaborator

@yunjaena yunjaena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고하셨습니다!! comment 추가한 부분 수정해주세요 :)


override fun onResume() {
super.onResume()
mBinding.itemRcy.layoutManager = LinearLayoutManager(this,LinearLayoutManager.VERTICAL,false)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onCreate에서 초기화 하셔도 좋을 것 같습니다.


override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
mBinding=DataBindingUtil.setContentView(this,R.layout.activity_main)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이전에는 멤버 변수로 m을 붙였었지만 요즘 트랜드로는 m을 붙이지 않습니다. 그 이유로는 getter setter 를 사용하기 위해서입니다.

import java.text.SimpleDateFormat
import java.util.*

class write_board : AppCompatActivity() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Class 이름은 첫번째는 대문자 나머지는 camel case 입니다. => WriteBoard
Kotlin naming conventions
컨벤션은 다른 사람들과의 약속과 같으므로 지키는게 좋습니다 :)

val time = dateFormat.format(date)

val item = Items(title,name,time)
model.finishButtonOnclick(item)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

finishButtonOnClick 보다는 updateItem이 더 좋아보이네요 ~!

}

fun setItems(view:RecyclerView){
val items = ItemModel.getItemList()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AAC ViewModel에서는 View 관련된 것을 알면 안됩니다. 왜냐하면 화면을 회전에서 View가 Destroy가 되도 View 가 유지가 되기 때문인데요 지금과 같은 메서드 같은 경우는 다행히 model에서 유지하지 않아서 메모리 누수는 없겠지만 View 관련해서 업데이트가 필요할 경우는 LiveData와 같이 해당 상태를 구독을 해서 View단에서 업데이트를 해보세요 :) SingleLiveEvent 또는 Event 관련해서 검색해보시는 것도 좋아요

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants