Skip to content

Commit

Permalink
Merge pull request #32 from APP-Android2/30-feature-자유게시판구현
Browse files Browse the repository at this point in the history
[#30] 자유게시판 기능 구현 베이스 코드
  • Loading branch information
ayz1070 authored Apr 9, 2024
2 parents a759968 + b321e96 commit 5e4fe0d
Show file tree
Hide file tree
Showing 28 changed files with 457 additions and 111 deletions.
4 changes: 0 additions & 4 deletions MungNolZa/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@
<activity
android:name=".ui.TestActivity"
android:exported="true" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

</activity>
<activity
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package kr.co.lion.mungnolza.model

data class BoardModel(
var boardIdx:Int,
var boardTitle:String,
var boardType:Int,
var boardImageList:MutableList<String?>,
var boardWriterIdx:Int,
var boardWriteDate:String,
var boardState:Int
){
constructor():this(0, "", 0, mutableListOf(), 0, "", 0)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package kr.co.lion.mungnolza.model

// 채팅에 대한 데이터 클래스는 어떻게 구성해야할까....?
data class ChatModel(
var chatUserNameMe:String,
var chatUserNameYou:String,
var chatContent:String,
var chatDate:String,
)


Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package kr.co.lion.mungnolza.model

class CommentModel {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package kr.co.lion.mungnolza.model

data class UserModel(
var userIdx:Int,
var userId:String,
var userPw:String,
var userNickName:String,
var userState:Int
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package kr.co.lion.mungnolza.ui

import android.content.Intent
import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import kr.co.lion.mungnolza.R
import kr.co.lion.mungnolza.databinding.ActivityTestBinding
import kr.co.lion.mungnolza.ui.chat.ChatActivity
import kr.co.lion.mungnolza.ui.freeboard.BoardActivity

class TestActivity : AppCompatActivity() {

lateinit var binding:ActivityTestBinding

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

binding = ActivityTestBinding.inflate(layoutInflater)

binding.button.setOnClickListener {
val intent = Intent(this,BoardActivity::class.java)
startActivity(intent)
}
binding.button2.setOnClickListener {
val intent = Intent(this, ChatActivity::class.java)
startActivity(intent)
}

setContentView(binding.root)

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,16 @@ import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView

import androidx.recyclerview.widget.RecyclerView.ViewHolder
import com.google.android.material.divider.MaterialDividerItemDecoration
import kr.co.lion.mungnolza.R
import kr.co.lion.mungnolza.databinding.FragmentDetailChatBinding
import kr.co.lion.mungnolza.databinding.RowDetailChatBinding
import kr.co.lion.mungnolza.databinding.RowDetailChatYouBinding
import kr.co.lion.mungnolza.databinding.RowFreeBoardBinding
import kr.co.lion.mungnolza.model.ChatModel

import kr.co.lion.mungnolza.ui.chat.ChatActivity
import kr.co.lion.mungnolza.ui.chat.viewmodel.DetailChatViewModel
import kr.co.lion.mungnolza.util.ChatFragmentName
Expand All @@ -20,6 +27,10 @@ class DetailChatFragment : Fragment() {
lateinit var binding: FragmentDetailChatBinding
lateinit var detailChatViewModel: DetailChatViewModel

lateinit var chatList:MutableList<ChatModel>

lateinit var testChat1:ChatModel
lateinit var testChat2:ChatModel

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
Expand All @@ -33,16 +44,31 @@ class DetailChatFragment : Fragment() {

chatActivity = activity as ChatActivity

initData()
testData()

setToolbar()
setRecyclerViewDetailChat()

return binding.root
}

fun initData(){
chatList = mutableListOf()
}

fun testData(){
testChat1 = ChatModel("정찬호","박지성","수원의 아들은 나야나","5분전")
testChat2 = ChatModel("박지성","정찬호","룰루랄라~","6분전")

chatList.add(testChat1)
chatList.add(testChat2)
}

fun setToolbar(){
binding.apply{
toolbarDetailChat.apply{
title = "수원 손흥민 정찬호"
title = "정찬호"
setNavigationIcon(R.drawable.ic_arrow_back_24px)

// 백버튼 이벤트
Expand All @@ -65,34 +91,52 @@ class DetailChatFragment : Fragment() {
}
}

inner class RecyclerViewAdapterDetailChat : RecyclerView.Adapter<RecyclerViewAdapterDetailChat.ViewHolderDetailChat>(){
inner class RecyclerViewAdapterDetailChat : RecyclerView.Adapter<ViewHolder>(){


override fun onCreateViewHolder(parent: ViewGroup, viewType: Int):ViewHolder {
val rowDetailChatBinding = RowDetailChatBinding.inflate(layoutInflater)
// val rowDetailChatYouBinding = RowDetailChatYouBinding.inflate(layoutInflater)

val mainViewHolder = ViewHolderDetailChat(rowDetailChatBinding)
return mainViewHolder
}

override fun getItemCount(): Int {
return chatList.size
}

override fun onBindViewHolder(holder: ViewHolder, position: Int) {
(holder as ViewHolderDetailChat).rowDetailChatBinding.editTextChatRowDetailChat.setText(testChat1.chatContent)
(holder as ViewHolderDetailChat).rowDetailChatBinding.textViewDateRowDetailChat.text = testChat1.chatDate

}

inner class ViewHolderDetailChat(rowDetailChatBinding: RowDetailChatBinding) : RecyclerView.ViewHolder(rowDetailChatBinding.root){
val rowDetailChatBinding: RowDetailChatBinding

init {
this.rowDetailChatBinding = rowDetailChatBinding


this.rowDetailChatBinding.root.layoutParams = ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT
)
}
}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolderDetailChat {
val rowDetailChatBinding = RowDetailChatBinding.inflate(layoutInflater)
val mainViewHolder = ViewHolderDetailChat(rowDetailChatBinding)
return mainViewHolder
}
inner class ViewHolderDetailChatYou(rowDetailChatYouBinding: RowDetailChatYouBinding) : RecyclerView.ViewHolder(rowDetailChatYouBinding.root){
val rowDetailChatYouBinding :RowDetailChatYouBinding

override fun getItemCount(): Int {
return 100
}
init {
this.rowDetailChatYouBinding = rowDetailChatYouBinding

override fun onBindViewHolder(holder: ViewHolderDetailChat, position: Int) {
holder.rowDetailChatBinding.editTextChatRowDetailChat.setText("박지성... 너 축구 잘해?")
holder.rowDetailChatBinding.textViewDateRowDetailChat.text = "오전 10:40"
this.rowDetailChatYouBinding.root.layoutParams = ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT
)
}
}
}

}
Loading

0 comments on commit 5e4fe0d

Please sign in to comment.