Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ dependencies {
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

}
7 changes: 7 additions & 0 deletions app/src/main/java/com/umc/project/mbtree/data/Chat.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.umc.project.mbtree.data

data class Chat(
var content:String,
var time:String,
var viewType:Int //1:왼쪽 2:오른쪽 3:센터
)
3 changes: 2 additions & 1 deletion app/src/main/java/com/umc/project/mbtree/data/User.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ package com.umc.project.mbtree.data
data class User(
val id:Int,
var name: String,
var userToken: String
var userToken: String,
var mbti: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import com.umc.project.mbtree.data.Chat
import com.umc.project.mbtree.data.User
import com.umc.project.mbtree.databinding.FragmentChattingBinding
import com.umc.project.mbtree.view.chat.ChatListRVAdapter

class ChattingFragment: Fragment() {

Expand All @@ -18,7 +22,18 @@ class ChattingFragment: Fragment() {
): View? {
binding = FragmentChattingBinding.inflate(inflater, container, false)

//로직 작성
//dummy data
var datas = ArrayList<User>()
datas.apply {
add(User(1, "user1", "123", "ISFP"))
add(User(2, "user2", "234", "ISFJ"))
add(User(3, "user3", "345", "ESFP"))
}

//채팅리스트 어댑터 붙이기
val adaper = ChatListRVAdapter(datas)
binding.rvChatList.adapter = adaper
binding.rvChatList.layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false)

return binding.root
}
Expand Down
16 changes: 15 additions & 1 deletion app/src/main/java/com/umc/project/mbtree/view/FriendFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import com.umc.project.mbtree.data.User
import com.umc.project.mbtree.databinding.FragmentFriendBinding
import com.umc.project.mbtree.view.friend.FriendRVAdapter

class FriendFragment: Fragment() {

Expand All @@ -18,7 +21,18 @@ class FriendFragment: Fragment() {
): View? {
binding = FragmentFriendBinding.inflate(inflater, container,false)

//로직 작성
//dummy data
var datas = ArrayList<User>()
datas.apply {
add(User(1, "user1", "123", "ISFP"))
add(User(2, "user2", "234", "ISFJ"))
add(User(3, "user3", "345", "ESFP"))
}

//채팅리스트 어댑터 붙이기
val fAdaper = FriendRVAdapter(datas)
binding.rvFriendList.adapter = fAdaper
binding.rvFriendList.layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false)

return binding.root
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.umc.project.mbtree.view.chat

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.umc.project.mbtree.databinding.ActivityAnswerBinding

class AnswerActivity: AppCompatActivity() {

lateinit var binding: ActivityAnswerBinding

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityAnswerBinding.inflate(layoutInflater)
setContentView(binding.root)


}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.umc.project.mbtree.view.chat

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.umc.project.mbtree.data.User
import com.umc.project.mbtree.databinding.ItemListBinding

class ChatListRVAdapter(private val chatList:ArrayList<User>):RecyclerView.Adapter<ChatListRVAdapter.ViewHolder>() {

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val binding:ItemListBinding = ItemListBinding.inflate(LayoutInflater.from(parent.context), parent, false)
return ViewHolder(binding)
}

override fun onBindViewHolder(holder: ViewHolder, position: Int) {
holder.bind(chatList[position])
}

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

inner class ViewHolder(val binding: ItemListBinding):RecyclerView.ViewHolder(binding.root){
fun bind(u: User){
//binding.ivListProfile
binding.tvListName.text = u.name
binding.tvListMbti.text = u.mbti
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package com.umc.project.mbtree.view.chat

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.umc.project.mbtree.R
import com.umc.project.mbtree.data.Chat
import com.umc.project.mbtree.databinding.ItemChatMeBinding

class ChatRVAdapter(private val context: Context,
private val chatList:ArrayList<Chat>): RecyclerView.Adapter<RecyclerView.ViewHolder>() {
var chatList2 = mutableListOf<Chat>()

//처음에 화면에 보일 아이템뷰 생성
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
val view: View?
return when(viewType){
1 -> {
view = LayoutInflater.from(parent.context).inflate(
R.layout.item_chat_you, parent, false
)
LeftViewHolder(view)
}
2 -> {
view = LayoutInflater.from(parent.context).inflate(
R.layout.item_chat_me, parent, false
)
RightViewHolder(view)
}
else -> {
view = LayoutInflater.from(parent.context).inflate(
R.layout.item_chat_you, parent, false
)
CenterViewHolder(view)
}
}
}

//뷰홀더에 데이터를 바인딩할때마다 호출되는 함수
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
when(chatList[position].viewType){
1 -> {
(holder as LeftViewHolder).bind(chatList[position])
holder.setIsRecyclable(false)
}
2 -> {
(holder as RightViewHolder).bind(chatList[position])
holder.setIsRecyclable(false)
}
else -> {
(holder as CenterViewHolder).bind(chatList[position])
holder.setIsRecyclable(false)
}
}
}

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

//xml을 여러개 사용하려면 오버라이딩 해줘야 함
override fun getItemViewType(position: Int): Int {
return chatList[position].viewType
}

inner class LeftViewHolder(view: View): RecyclerView.ViewHolder(view){
private val content: TextView = view.findViewById(R.id.tv_chat_content)

fun bind(chat: Chat){
content.text = chat.content
}
}

inner class RightViewHolder(view: View): RecyclerView.ViewHolder(view){
private val content: TextView = view.findViewById(R.id.tv_chat_content)

fun bind(chat: Chat){
content.text = chat.content
}
}

inner class CenterViewHolder(view: View): RecyclerView.ViewHolder(view){
private val content: TextView = view.findViewById(R.id.tv_chat_content)

fun bind(chat: Chat){
content.text = chat.content
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.umc.project.mbtree.view.chat

import android.os.Bundle
import android.view.LayoutInflater
import androidx.appcompat.app.AppCompatActivity
import com.umc.project.mbtree.data.Chat
import com.umc.project.mbtree.databinding.ActivityChattingBinding

class ChattingActivity: AppCompatActivity() {
lateinit var binding: ActivityChattingBinding
lateinit var multiAdapter: ChatRVAdapter
val chatList = mutableListOf<Chat>()

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityChattingBinding.inflate(layoutInflater)
setContentView(binding.root)

//dummy data
var chatDatas = ArrayList<Chat>()
chatDatas.apply{
add(Chat("안녕하세요", "12:00", 1))
add(Chat("네 안녕하세요", "12:00", 2))
add(Chat("지금 뭐하세요?", "12:00", 1))
add(Chat("저 코딩하는데요", "12:00", 2))
add(Chat("시간어택", "12:00", 3))
}

multiAdapter = ChatRVAdapter(this, chatDatas)
binding.rvChatList.adapter = multiAdapter
multiAdapter.chatList2 = chatDatas
multiAdapter.notifyDataSetChanged()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.umc.project.mbtree.view.friend

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.umc.project.mbtree.data.User
import com.umc.project.mbtree.databinding.ItemListBinding
import com.umc.project.mbtree.view.chat.ChatListRVAdapter

class FriendRVAdapter (private val chatList:ArrayList<User>): RecyclerView.Adapter<FriendRVAdapter.ViewHolder>() {

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val binding: ItemListBinding = ItemListBinding.inflate(LayoutInflater.from(parent.context), parent, false)
return ViewHolder(binding)
}

override fun onBindViewHolder(holder: ViewHolder, position: Int) {
holder.bind(chatList[position])
}

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

inner class ViewHolder(val binding: ItemListBinding): RecyclerView.ViewHolder(binding.root){
fun bind(u: User){
//binding.ivListProfile
binding.tvListName.text = u.name
binding.tvListMbti.text = u.mbti
}
}

}
Binary file added app/src/main/res/drawable-v24/ic_chat_send.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions app/src/main/res/drawable/bg_chat_list.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:padding = "10dp"
android:shape="rectangle">

<solid android:color="@color/white"/>
<corners
android:radius="16dp"/>
<stroke
android:width="1dp"
android:color="@color/white"/>
</shape>
12 changes: 12 additions & 0 deletions app/src/main/res/drawable/bg_gradient.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">

<gradient
android:angle="90"
android:centerColor="#8ED58E"
android:endColor="#31BA82"
android:startColor="#FFF59C"
android:type="linear"/>

</shape>
8 changes: 4 additions & 4 deletions app/src/main/res/drawable/bg_tab_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

<solid android:color="@color/white"/>
<corners
android:bottomLeftRadius="25dp"
android:bottomRightRadius="25dp"
android:topLeftRadius="25dp"
android:topRightRadius="25dp"/>
android:bottomLeftRadius="40dp"
android:bottomRightRadius="40dp"
android:topLeftRadius="40dp"
android:topRightRadius="40dp"/>
<stroke
android:width="1dp"
android:color="@color/white"/>
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/ic_search.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#535353"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M15.5,14h-0.79l-0.28,-0.27C15.41,12.59 16,11.11 16,9.5 16,5.91 13.09,3 9.5,3S3,5.91 3,9.5 5.91,16 9.5,16c1.61,0 3.09,-0.59 4.23,-1.57l0.27,0.28v0.79l5,4.99L20.49,19l-4.99,-5zM9.5,14C7.01,14 5,11.99 5,9.5S7.01,5 9.5,5 14,7.01 14,9.5 11.99,14 9.5,14z"/>
</vector>
16 changes: 16 additions & 0 deletions app/src/main/res/drawable/tv_chat_me.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:padding = "10dp"
android:shape="rectangle">

<solid android:color="@color/white"/>
<corners
android:bottomLeftRadius="70dp"
android:bottomRightRadius="70dp"
android:topLeftRadius="70dp"
android:topRightRadius="0dp"/>
<stroke
android:width="1dp"
android:color="@color/white"/>
</shape>
Loading