-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
568 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
app/src/main/java/com/nbit/Idear/mypage/mbtiAdapter/MbtiAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package com.nbit.Idear.mypage.mbtiAdapter | ||
|
||
import android.content.Context | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.core.content.ContextCompat.getColor | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.nbit.Idear.R | ||
import com.nbit.Idear.databinding.ItemMoodKeywordProfileBinding | ||
import com.nbit.Idear.databinding.ItemToggleMbtiBinding | ||
import com.nbit.Idear.mypage.moodKeywordAdapter.MoodKeywordAdapter | ||
import com.nbit.Idear.mypage.moodKeywordAdapter.MoodKeywordItem | ||
|
||
// mbti 토글 어댑터 | ||
class MbtiAdapter ( | ||
private val context: Context | ||
) : | ||
RecyclerView.Adapter<MbtiAdapter.MbtiViewHolder>(){ | ||
|
||
var items = mutableListOf<MbtiItem>() | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) : | ||
MbtiAdapter.MbtiViewHolder { | ||
|
||
val view = LayoutInflater.from(context).inflate(R.layout.item_toggle_mbti, parent, false) | ||
|
||
return MbtiViewHolder(ItemToggleMbtiBinding.bind(view)) | ||
} | ||
|
||
override fun getItemCount(): Int = items.size | ||
|
||
override fun onBindViewHolder(holder: MbtiAdapter.MbtiViewHolder, position: Int) { | ||
holder.bind(items[position], position) | ||
} | ||
|
||
inner class MbtiViewHolder(private val binding: ItemToggleMbtiBinding) : | ||
RecyclerView.ViewHolder(binding.root) { | ||
|
||
fun bind(item: MbtiItem, position: Int) { | ||
binding.textMbtiTopSelect.text = item.topMbti | ||
binding.textMbtiTopUnselect.text = item.topMbti | ||
|
||
binding.textMbtiBottomSelect.text = item.bottomMbti | ||
binding.textMbtiTopUnselect.text = item.bottomMbti | ||
|
||
// mbti 선택 안 됨 | ||
if(item.unselect) { | ||
binding.textMbtiTopSelect.setBackgroundResource(R.drawable.shape_unselect_mbti) | ||
binding.textMbtiTopSelect.setTextColor(getColor(context, R.color.white)) | ||
|
||
binding.textMbtiBottomSelect.visibility = View.GONE | ||
} | ||
// 위쪽 mbti 선택됨 | ||
else if(item.isSelectTop) { | ||
binding.textMbtiTopSelect.setBackgroundResource(R.drawable.shape_select_mbti) | ||
binding.textMbtiTopSelect.setTextColor(getColor(context, R.color.white)) | ||
|
||
binding.textMbtiTopSelect.visibility = View.VISIBLE | ||
binding.textMbtiBottomSelect.visibility = View.GONE | ||
} | ||
// 아래쪽 mbti 선택됨 | ||
else { | ||
binding.textMbtiBottomSelect.setBackgroundResource(R.drawable.shape_select_mbti) | ||
binding.textMbtiBottomSelect.setTextColor(getColor(context, R.color.white)) | ||
|
||
binding.textMbtiTopSelect.visibility = View.GONE | ||
binding.textMbtiBottomSelect.visibility = View.VISIBLE | ||
} | ||
|
||
binding.textMbtiTopUnselect.setOnClickListener(View.OnClickListener { | ||
item.isSelectTop = true | ||
select(position) | ||
}) | ||
|
||
binding.textMbtiBottomUnselect.setOnClickListener(View.OnClickListener { | ||
item.isSelectTop = false | ||
select(position) | ||
}) | ||
} | ||
} | ||
|
||
fun select(position: Int) { | ||
for(i in 0..(items.size - 1)) { | ||
items[i].unselect = false | ||
} | ||
notifyDataSetChanged() | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
app/src/main/java/com/nbit/Idear/mypage/mbtiAdapter/MbtiItem.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.nbit.Idear.mypage.mbtiAdapter | ||
|
||
data class MbtiItem ( | ||
val topMbti: String, | ||
val bottomMbti: String, | ||
var isSelectTop: Boolean, | ||
var unselect: Boolean = true, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
app/src/main/java/com/nbit/Idear/mypage/moodKeywordAdapter/MoodKeywordItem.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.nbit.Idear.mypage.moodKeywordAdapter | ||
|
||
data class MoodKeywordItem ( | ||
val moodKeyword: String, | ||
var isSelected: Boolean = false, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="rectangle"> | ||
|
||
<solid android:color="@color/idear_extra_light_green"/> | ||
<corners | ||
android:radius="8dp" /> | ||
|
||
</shape> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="rectangle"> | ||
|
||
<solid | ||
android:color="@color/idear_green"/> | ||
|
||
<corners | ||
android:radius="8dp" /> | ||
|
||
</shape> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- 높임말 선택 버튼 --> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="rectangle"> | ||
|
||
<solid | ||
android:color="@color/idear_green"/> | ||
|
||
<stroke android:width="1dp" | ||
android:color="@color/idear_green"/> | ||
|
||
<corners | ||
android:radius="8dp" /> | ||
|
||
</shape> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="rectangle"> | ||
|
||
<solid | ||
android:color="@color/idear_green"/> | ||
|
||
<corners | ||
android:radius="8dp" /> | ||
|
||
</shape> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"> | ||
|
||
<solid | ||
android:color="@color/white"/> | ||
<stroke android:width="1dp" android:color="@color/idear_gray_200"/> | ||
|
||
<corners | ||
android:radius="8dp" /> | ||
|
||
</shape> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- 높임말 해제 버튼 --> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="rectangle"> | ||
|
||
<solid | ||
android:color="@color/white"/> | ||
|
||
<stroke android:width="1dp" | ||
android:color="@color/idear_gray_500"/> | ||
|
||
<corners | ||
android:radius="8dp" /> | ||
|
||
</shape> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="rectangle"> | ||
|
||
<solid | ||
android:color="@color/idear_gray_500"/> | ||
|
||
<corners | ||
android:radius="8dp" /> | ||
|
||
</shape> |
Oops, something went wrong.