Skip to content

12주차 실습과제입니다.#4

Open
Ssunghyn wants to merge 1 commit intomainfrom
Assignment8
Open

12주차 실습과제입니다.#4
Ssunghyn wants to merge 1 commit intomainfrom
Assignment8

Conversation

@Ssunghyn
Copy link
Owner

MVP 패턴을 이용하여 만든 게시판입니다.

MVP 패턴을 이용하여 만든 게시판입니다.
@Ssunghyn Ssunghyn requested review from ksu9080 and yunjaena July 11, 2021 05:59
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.

수고하셨습니다 !! MVP 패턴을 왜 사용하는지를 좀 더 염두 하시고 짜시면 더 좋은 코드가 나올 것 같습니다.

@@ -0,0 +1,5 @@
package com.example.myapplication

interface BasePresenter<T> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

BasePresenter는 말대로 Presenter들의 Base가 되는 interface입니다. 고로 Presenter에 필요한 View interface를 세팅을 해주는 역할과 같은 기초적인 메서드만 있어야 합니다.

itemView.setOnClickListener {
val curPos : Int = adapterPosition
val item : Items = itemList.get(curPos)
Toast.makeText(parent.context,"제목:${item.title}\n작성자:${item.name}",Toast.LENGTH_SHORT).show()
Copy link
Collaborator

Choose a reason for hiding this comment

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

해당 String 값을 String resource에 선언해보세요 :)

@@ -0,0 +1,5 @@
package com.example.myapplication

class Items(val title: String, val name: String, val time: String) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

안에 내용이 없으면 괄호를 없애도 좋습니다. 또한 모델을 선언할꺼면 data class로 선언하면 좋습니다. 일반 class 와 data class의 차이를 찾아보세요 :)

binding = DataBindingUtil.setContentView(this,R.layout.activity_main)

binding.addButton.setOnClickListener {
preseter.nextActivity(this)
Copy link
Collaborator

Choose a reason for hiding this comment

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

presenter의 역할을 잘 이해를 못하는 것 같습니다. presenter에서는 Model에 있는 데이터를 가져와 달라고 요청을 하는 것인데 Activity이동은 Activity에서 처리 하면 될 것 같습니다.


override fun onResume() {
super.onResume()
preseter.setData()
Copy link
Collaborator

Choose a reason for hiding this comment

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

setData 가 정확히 어떤 역할을 하는 메서드인지 모르겠습니다.

}

override fun showInfo(itemList: ArrayList<Items>) {
binding.itemRcy.layoutManager = LinearLayoutManager(MainActivity(),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.

MainActivity()보다는 this 로 하는것이 좋아 보입니다


interface Presenter : BasePresenter<View>{
fun setData()
fun saveData(item:Items,context: Context)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Presenter에서는 View 관련된 것을 알면 좋지 않습니다. ex) Context

Comment on lines +26 to +27
val intent = Intent(context,MainActivity::class.java)
startActivity(context,intent,null)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
val intent = Intent(context,MainActivity::class.java)
startActivity(context,intent,null)
view.finishUpdateItem()
// Activity
override fun finishUpdateItem(){
        val intent = Intent(context,MainActivity::class.java)
        startActivity(context,intent,null)
}

class write_board : AppCompatActivity() {

private lateinit var binding : ActivityWriteBoardBinding
val preseter : MainContract.Presenter = MainPresenter()
Copy link
Collaborator

Choose a reason for hiding this comment

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

private 으로 선언해도 좋을 것 같습니다.

super.onCreate(savedInstanceState)
setContentView(R.layout.activity_write_board)

val long_now = System.currentTimeMillis()
Copy link
Collaborator

Choose a reason for hiding this comment

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

변수명은 _ 로 선언하지 않습니다. => val longNow
변수 명도 다른 사람들이 알아 볼 수 있도록 짜면 좋을 것 같습니다. val currentTime = System.currentTimeMills()

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