From b79dac48f59e1792a030a2c81b8f74f72ebcbd57 Mon Sep 17 00:00:00 2001 From: kangyuri1114 Date: Sat, 30 Mar 2024 04:24:24 +0900 Subject: [PATCH 1/4] =?UTF-8?q?[feat]:=20=EA=B0=9C=EB=B0=9C=EC=9E=90=20?= =?UTF-8?q?=EB=A6=AC=EC=82=AC=EC=9D=B4=ED=81=B4=EB=9F=AC=EB=B7=B0=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feature/devInfo/DevInfoFragment.kt | 68 ++++++---------- .../zucchini/feature/devInfo/DeveloperInfo.kt | 10 +++ .../feature/devInfo/DeveloperInfoDummy.kt | 78 ++++++++++++++++++ .../devInfo/adapter/DeveloperInfoAdapter.kt | 60 ++++++++++++++ .../res/drawable/developer_default_image.xml | 12 +++ .../main/res/drawable/devinfo_background.xml | 9 +++ .../src/main/res/layout/fragment_dev_info.xml | 15 +++- .../src/main/res/layout/item_developer.xml | 79 +++++++++++++++++++ 8 files changed, 283 insertions(+), 48 deletions(-) create mode 100644 feature/devInfo/src/main/java/com/zucchini/feature/devInfo/DeveloperInfo.kt create mode 100644 feature/devInfo/src/main/java/com/zucchini/feature/devInfo/DeveloperInfoDummy.kt create mode 100644 feature/devInfo/src/main/java/com/zucchini/feature/devInfo/adapter/DeveloperInfoAdapter.kt create mode 100644 feature/devInfo/src/main/res/drawable/developer_default_image.xml create mode 100644 feature/devInfo/src/main/res/drawable/devinfo_background.xml create mode 100644 feature/devInfo/src/main/res/layout/item_developer.xml diff --git a/feature/devInfo/src/main/java/com/zucchini/feature/devInfo/DevInfoFragment.kt b/feature/devInfo/src/main/java/com/zucchini/feature/devInfo/DevInfoFragment.kt index 75761dd..25708ea 100644 --- a/feature/devInfo/src/main/java/com/zucchini/feature/devInfo/DevInfoFragment.kt +++ b/feature/devInfo/src/main/java/com/zucchini/feature/devInfo/DevInfoFragment.kt @@ -1,59 +1,35 @@ package com.zucchini.feature.devInfo import android.os.Bundle -import androidx.fragment.app.Fragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.fragment.app.Fragment +import androidx.recyclerview.widget.GridLayoutManager +import com.zucchini.feature.devInfo.adapter.DeveloperInfoAdapter +import com.zucchini.feature.devInfo.databinding.FragmentDevInfoBinding -// TODO: Rename parameter arguments, choose names that match -// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER -private const val ARG_PARAM1 = "param1" -private const val ARG_PARAM2 = "param2" - -/** - * A simple [Fragment] subclass. - * Use the [DevInfoFragment.newInstance] factory method to - * create an instance of this fragment. - */ class DevInfoFragment : Fragment() { - // TODO: Rename and change types of parameters - private var param1: String? = null - private var param2: String? = null - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - arguments?.let { - param1 = it.getString(ARG_PARAM1) - param2 = it.getString(ARG_PARAM2) - } - } + private var _binding: FragmentDevInfoBinding? = null + private val binding: FragmentDevInfoBinding get() = _binding!! override fun onCreateView( - inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle? - ): View? { - // Inflate the layout for this fragment - return inflater.inflate(R.layout.fragment_dev_info, container, false) + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle?, + ): View { + _binding = FragmentDevInfoBinding.inflate(inflater, container, false) + + val developerInfoAdapter = DeveloperInfoAdapter() + binding.rvDevinfo.adapter = developerInfoAdapter + binding.rvDevinfo.layoutManager = GridLayoutManager(context, 2) + developerInfoAdapter.submitList(DeveloperInfoDummy.developerInfoList) + + return binding.root } - companion object { - /** - * Use this factory method to create a new instance of - * this fragment using the provided parameters. - * - * @param param1 Parameter 1. - * @param param2 Parameter 2. - * @return A new instance of fragment DevInfoFragment. - */ - // TODO: Rename and change types and number of parameters - @JvmStatic - fun newInstance(param1: String, param2: String) = - DevInfoFragment().apply { - arguments = Bundle().apply { - putString(ARG_PARAM1, param1) - putString(ARG_PARAM2, param2) - } - } + override fun onDestroyView() { + super.onDestroyView() + _binding = null } -} \ No newline at end of file +} diff --git a/feature/devInfo/src/main/java/com/zucchini/feature/devInfo/DeveloperInfo.kt b/feature/devInfo/src/main/java/com/zucchini/feature/devInfo/DeveloperInfo.kt new file mode 100644 index 0000000..c000509 --- /dev/null +++ b/feature/devInfo/src/main/java/com/zucchini/feature/devInfo/DeveloperInfo.kt @@ -0,0 +1,10 @@ +package com.zucchini.feature.devInfo + +data class DeveloperInfo( + + val image: Int? = null, + val name: String = "", + val field: String = "", + val githubId: String = "", + val clicked: Int = 0, +) diff --git a/feature/devInfo/src/main/java/com/zucchini/feature/devInfo/DeveloperInfoDummy.kt b/feature/devInfo/src/main/java/com/zucchini/feature/devInfo/DeveloperInfoDummy.kt new file mode 100644 index 0000000..57db635 --- /dev/null +++ b/feature/devInfo/src/main/java/com/zucchini/feature/devInfo/DeveloperInfoDummy.kt @@ -0,0 +1,78 @@ +package com.zucchini.feature.devInfo + +object DeveloperInfoDummy { + val developerInfoList = listOf( + DeveloperInfo( + image = R.drawable.developer_default_image, + name = "강유리", + field = "안드로이드 개발\n빅데이터", + githubId = "sjkfjklsdf", + ), + DeveloperInfo( + image = R.drawable.developer_default_image, + name = "최숙희", + field = "서버 개발", + githubId = "234543213", + ), + DeveloperInfo( + image = R.drawable.developer_default_image, + name = "강유리", + field = "안드로이드 개발", + githubId = "sjkfjklsdf", + ), + DeveloperInfo( + image = R.drawable.developer_default_image, + name = "강유리", + field = "안드로이드 개발", + githubId = "sjkfjklsdf", + ), + DeveloperInfo( + image = R.drawable.developer_default_image, + name = "강유리", + field = "안드로이드 개발", + githubId = "sjkfjklsdf", + ), + DeveloperInfo( + image = R.drawable.developer_default_image, + name = "강유리", + field = "안드로이드 개발", + githubId = "sjkfjklsdf", + ), + DeveloperInfo( + image = R.drawable.developer_default_image, + name = "강유리", + field = "안드로이드 개발", + githubId = "sjkfjklsdf", + ), + DeveloperInfo( + image = R.drawable.developer_default_image, + name = "강유리", + field = "안드로이드 개발", + githubId = "sjkfjklsdf", + ), + DeveloperInfo( + image = R.drawable.developer_default_image, + name = "강유리", + field = "안드로이드 개발", + githubId = "sjkfjklsdf", + ), + DeveloperInfo( + image = R.drawable.developer_default_image, + name = "강유리", + field = "안드로이드 개발", + githubId = "sjkfjklsdf", + ), + DeveloperInfo( + image = R.drawable.developer_default_image, + name = "강유리", + field = "안드로이드 개발", + githubId = "sjkfjklsdf", + ), + DeveloperInfo( + image = R.drawable.developer_default_image, + name = "강유리", + field = "안드로이드 개발", + githubId = "sjkfjklsdf", + ), + ) +} diff --git a/feature/devInfo/src/main/java/com/zucchini/feature/devInfo/adapter/DeveloperInfoAdapter.kt b/feature/devInfo/src/main/java/com/zucchini/feature/devInfo/adapter/DeveloperInfoAdapter.kt new file mode 100644 index 0000000..ebae22a --- /dev/null +++ b/feature/devInfo/src/main/java/com/zucchini/feature/devInfo/adapter/DeveloperInfoAdapter.kt @@ -0,0 +1,60 @@ +package com.zucchini.feature.devInfo.adapter + +import android.view.LayoutInflater +import android.view.ViewGroup +import androidx.recyclerview.widget.DiffUtil +import androidx.recyclerview.widget.ListAdapter +import androidx.recyclerview.widget.RecyclerView +import com.zucchini.feature.devInfo.DeveloperInfo +import com.zucchini.feature.devInfo.R +import com.zucchini.feature.devInfo.databinding.ItemDeveloperBinding + +class DeveloperInfoAdapter : + ListAdapter( + ItemDiffCallback( + onItemsTheSame = { old, new -> old == new }, + onContentsTheSame = { old, new -> old == new }, + ), + ) { + + override fun onCreateViewHolder( + parent: ViewGroup, + viewType: Int, + ): DeveloperInfoViewHolder { + val inflater = LayoutInflater.from(parent.context) + val binding = ItemDeveloperBinding.inflate(inflater, parent, false) + return DeveloperInfoViewHolder(binding) + } + + override fun onBindViewHolder(holder: DeveloperInfoViewHolder, position: Int) { + holder.bind(getItem(position)) + } + + inner class DeveloperInfoViewHolder(private val binding: ItemDeveloperBinding) : + RecyclerView.ViewHolder(binding.root) { + fun bind(developerInfo: DeveloperInfo) { + binding.ivProjectProfile.setImageResource( + developerInfo.image ?: R.drawable.developer_default_image, + ) + binding.tvDeveloperName.text = developerInfo.name + binding.tvDeveloperField.text = developerInfo.field + binding.tvDeveloperGithub.text = "Github: ${developerInfo.githubId}" + binding.tvDeveloperClicked.text = "조회수 +${developerInfo.clicked}" + } + } +} + +class ItemDiffCallback( + val onItemsTheSame: (T, T) -> Boolean, + val onContentsTheSame: (T, T) -> Boolean, +) : DiffUtil.ItemCallback() { + override fun areItemsTheSame( + oldItem: T, + newItem: T, + ): Boolean = onItemsTheSame(oldItem, newItem) + + override fun areContentsTheSame( + oldItem: T, + newItem: T, + ): Boolean = onContentsTheSame(oldItem, newItem) +} diff --git a/feature/devInfo/src/main/res/drawable/developer_default_image.xml b/feature/devInfo/src/main/res/drawable/developer_default_image.xml new file mode 100644 index 0000000..6485bef --- /dev/null +++ b/feature/devInfo/src/main/res/drawable/developer_default_image.xml @@ -0,0 +1,12 @@ + + + + diff --git a/feature/devInfo/src/main/res/drawable/devinfo_background.xml b/feature/devInfo/src/main/res/drawable/devinfo_background.xml new file mode 100644 index 0000000..99e2c75 --- /dev/null +++ b/feature/devInfo/src/main/res/drawable/devinfo_background.xml @@ -0,0 +1,9 @@ + + + diff --git a/feature/devInfo/src/main/res/layout/fragment_dev_info.xml b/feature/devInfo/src/main/res/layout/fragment_dev_info.xml index 51080c3..4ec3038 100644 --- a/feature/devInfo/src/main/res/layout/fragment_dev_info.xml +++ b/feature/devInfo/src/main/res/layout/fragment_dev_info.xml @@ -1,14 +1,15 @@ @@ -29,14 +30,24 @@ app:layout_constraintTop_toTopOf="parent" /> + + diff --git a/feature/devInfo/src/main/res/layout/item_developer.xml b/feature/devInfo/src/main/res/layout/item_developer.xml new file mode 100644 index 0000000..813dba5 --- /dev/null +++ b/feature/devInfo/src/main/res/layout/item_developer.xml @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + \ No newline at end of file From 2e95ad82bc90ffc777614ff4d375c785307dbaf8 Mon Sep 17 00:00:00 2001 From: kangyuri1114 Date: Sun, 31 Mar 2024 13:57:02 +0900 Subject: [PATCH 2/4] =?UTF-8?q?[chore]:=20dataclass=20domain=20=EB=AA=A8?= =?UTF-8?q?=EB=93=88=EB=A1=9C=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/zucchini/domain/model}/DeveloperInfo.kt | 2 +- .../java/com/zucchini/feature/devInfo/DeveloperInfoDummy.kt | 2 ++ .../zucchini/feature/devInfo/adapter/DeveloperInfoAdapter.kt | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) rename {feature/devInfo/src/main/java/com/zucchini/feature/devInfo => domain/src/main/java/com/zucchini/domain/model}/DeveloperInfo.kt (82%) diff --git a/feature/devInfo/src/main/java/com/zucchini/feature/devInfo/DeveloperInfo.kt b/domain/src/main/java/com/zucchini/domain/model/DeveloperInfo.kt similarity index 82% rename from feature/devInfo/src/main/java/com/zucchini/feature/devInfo/DeveloperInfo.kt rename to domain/src/main/java/com/zucchini/domain/model/DeveloperInfo.kt index c000509..9649ddb 100644 --- a/feature/devInfo/src/main/java/com/zucchini/feature/devInfo/DeveloperInfo.kt +++ b/domain/src/main/java/com/zucchini/domain/model/DeveloperInfo.kt @@ -1,4 +1,4 @@ -package com.zucchini.feature.devInfo +package com.zucchini.domain.model data class DeveloperInfo( diff --git a/feature/devInfo/src/main/java/com/zucchini/feature/devInfo/DeveloperInfoDummy.kt b/feature/devInfo/src/main/java/com/zucchini/feature/devInfo/DeveloperInfoDummy.kt index 57db635..5fb69f4 100644 --- a/feature/devInfo/src/main/java/com/zucchini/feature/devInfo/DeveloperInfoDummy.kt +++ b/feature/devInfo/src/main/java/com/zucchini/feature/devInfo/DeveloperInfoDummy.kt @@ -1,5 +1,7 @@ package com.zucchini.feature.devInfo +import com.zucchini.domain.model.DeveloperInfo + object DeveloperInfoDummy { val developerInfoList = listOf( DeveloperInfo( diff --git a/feature/devInfo/src/main/java/com/zucchini/feature/devInfo/adapter/DeveloperInfoAdapter.kt b/feature/devInfo/src/main/java/com/zucchini/feature/devInfo/adapter/DeveloperInfoAdapter.kt index ebae22a..b7bc08e 100644 --- a/feature/devInfo/src/main/java/com/zucchini/feature/devInfo/adapter/DeveloperInfoAdapter.kt +++ b/feature/devInfo/src/main/java/com/zucchini/feature/devInfo/adapter/DeveloperInfoAdapter.kt @@ -5,7 +5,7 @@ import android.view.ViewGroup import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.RecyclerView -import com.zucchini.feature.devInfo.DeveloperInfo +import com.zucchini.domain.model.DeveloperInfo import com.zucchini.feature.devInfo.R import com.zucchini.feature.devInfo.databinding.ItemDeveloperBinding From 7b43f234e999a43a63beb9a70c6ee2ec0ca5fe0f Mon Sep 17 00:00:00 2001 From: kangyuri1114 Date: Sun, 31 Mar 2024 13:57:57 +0900 Subject: [PATCH 3/4] =?UTF-8?q?[chore]:=20=EC=BD=94=EB=93=9C=20=ED=95=A8?= =?UTF-8?q?=EC=88=98=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/zucchini/feature/devInfo/DevInfoFragment.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/feature/devInfo/src/main/java/com/zucchini/feature/devInfo/DevInfoFragment.kt b/feature/devInfo/src/main/java/com/zucchini/feature/devInfo/DevInfoFragment.kt index 25708ea..a529f71 100644 --- a/feature/devInfo/src/main/java/com/zucchini/feature/devInfo/DevInfoFragment.kt +++ b/feature/devInfo/src/main/java/com/zucchini/feature/devInfo/DevInfoFragment.kt @@ -20,12 +20,16 @@ class DevInfoFragment : Fragment() { ): View { _binding = FragmentDevInfoBinding.inflate(inflater, container, false) + initDeveloperAdapter() + + return binding.root + } + + private fun initDeveloperAdapter() { val developerInfoAdapter = DeveloperInfoAdapter() binding.rvDevinfo.adapter = developerInfoAdapter binding.rvDevinfo.layoutManager = GridLayoutManager(context, 2) developerInfoAdapter.submitList(DeveloperInfoDummy.developerInfoList) - - return binding.root } override fun onDestroyView() { From 557e4f66d35488a23a05908934b1b2af66c7dc2f Mon Sep 17 00:00:00 2001 From: kangyuri1114 Date: Sun, 31 Mar 2024 14:04:27 +0900 Subject: [PATCH 4/4] =?UTF-8?q?[chore]:=20common=20=EB=AA=A8=EB=93=88=20de?= =?UTF-8?q?pendency=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- feature/devInfo/build.gradle.kts | 1 + .../devInfo/adapter/DeveloperInfoAdapter.kt | 17 +---------------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/feature/devInfo/build.gradle.kts b/feature/devInfo/build.gradle.kts index b91d5ac..7a2a28d 100644 --- a/feature/devInfo/build.gradle.kts +++ b/feature/devInfo/build.gradle.kts @@ -39,6 +39,7 @@ android { dependencies { implementation(project(":domain")) implementation(project(":core:designsystem")) + implementation(project(":core:common")) KotlinDependencies.run { implementation(kotlin) diff --git a/feature/devInfo/src/main/java/com/zucchini/feature/devInfo/adapter/DeveloperInfoAdapter.kt b/feature/devInfo/src/main/java/com/zucchini/feature/devInfo/adapter/DeveloperInfoAdapter.kt index b7bc08e..799491c 100644 --- a/feature/devInfo/src/main/java/com/zucchini/feature/devInfo/adapter/DeveloperInfoAdapter.kt +++ b/feature/devInfo/src/main/java/com/zucchini/feature/devInfo/adapter/DeveloperInfoAdapter.kt @@ -2,12 +2,12 @@ package com.zucchini.feature.devInfo.adapter import android.view.LayoutInflater import android.view.ViewGroup -import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.RecyclerView import com.zucchini.domain.model.DeveloperInfo import com.zucchini.feature.devInfo.R import com.zucchini.feature.devInfo.databinding.ItemDeveloperBinding +import com.zucchini.view.ItemDiffCallback class DeveloperInfoAdapter : ListAdapter( @@ -43,18 +43,3 @@ class DeveloperInfoAdapter : } } } - -class ItemDiffCallback( - val onItemsTheSame: (T, T) -> Boolean, - val onContentsTheSame: (T, T) -> Boolean, -) : DiffUtil.ItemCallback() { - override fun areItemsTheSame( - oldItem: T, - newItem: T, - ): Boolean = onItemsTheSame(oldItem, newItem) - - override fun areContentsTheSame( - oldItem: T, - newItem: T, - ): Boolean = onContentsTheSame(oldItem, newItem) -}