-
Notifications
You must be signed in to change notification settings - Fork 3
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
9 changed files
with
180 additions
and
1 deletion.
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
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
5 changes: 5 additions & 0 deletions
5
android/app/src/main/java/com/created/team201/presentation/setting/SettingClickListener.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,5 @@ | ||
package com.created.team201.presentation.setting | ||
|
||
interface SettingClickListener { | ||
fun onClick(itemId: Long) | ||
} |
42 changes: 42 additions & 0 deletions
42
android/app/src/main/java/com/created/team201/presentation/setting/adapter/SettingAdapter.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,42 @@ | ||
package com.created.team201.presentation.setting.adapter | ||
|
||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.DiffUtil | ||
import androidx.recyclerview.widget.ListAdapter | ||
import com.created.team201.presentation.setting.SettingClickListener | ||
import com.created.team201.presentation.setting.model.SettingUiModel | ||
|
||
class SettingAdapter( | ||
private val settingClickListener: SettingClickListener | ||
) : ListAdapter<SettingUiModel, SettingViewHolder>(SettingDiffUtil) { | ||
|
||
init { | ||
setHasStableIds(true) | ||
} | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SettingViewHolder { | ||
return SettingViewHolder(parent, settingClickListener) | ||
} | ||
|
||
override fun onBindViewHolder(holder: SettingViewHolder, position: Int) { | ||
holder.bind(getItem(position)) | ||
} | ||
|
||
override fun getItemId(position: Int): Long = getItem(position).id | ||
|
||
companion object { | ||
private val SettingDiffUtil = object : DiffUtil.ItemCallback<SettingUiModel>() { | ||
override fun areItemsTheSame( | ||
oldItem: SettingUiModel, | ||
newItem: SettingUiModel, | ||
): Boolean = | ||
oldItem.id == newItem.id | ||
|
||
override fun areContentsTheSame( | ||
oldItem: SettingUiModel, | ||
newItem: SettingUiModel, | ||
): Boolean = | ||
oldItem == newItem | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...d/app/src/main/java/com/created/team201/presentation/setting/adapter/SettingViewHolder.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,26 @@ | ||
package com.created.team201.presentation.setting.adapter | ||
|
||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.created.team201.R | ||
import com.created.team201.databinding.ItemSettingBinding | ||
import com.created.team201.presentation.setting.SettingClickListener | ||
import com.created.team201.presentation.setting.model.SettingUiModel | ||
|
||
class SettingViewHolder( | ||
parent: ViewGroup, | ||
settingClickListener: SettingClickListener | ||
) : RecyclerView.ViewHolder( | ||
LayoutInflater.from(parent.context).inflate(R.layout.item_setting, parent, false) | ||
) { | ||
private val binding = ItemSettingBinding.bind(itemView) | ||
|
||
init { | ||
itemView.setOnClickListener { settingClickListener.onClick(itemId) } | ||
} | ||
|
||
fun bind(setting: SettingUiModel) { | ||
binding.tvSettingTitle.text = setting.title | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
android/app/src/main/java/com/created/team201/presentation/setting/model/SettingType.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,19 @@ | ||
package com.created.team201.presentation.setting.model | ||
|
||
enum class SettingType(val itemId: Long) { | ||
NOTIFICATION(0L), | ||
ACCOUNT(1L), | ||
POLICY(2L), | ||
LOGOUT(3L); | ||
|
||
companion object { | ||
fun valueOf(itemId: Long): SettingType = | ||
when (itemId) { | ||
0L -> NOTIFICATION | ||
1L -> ACCOUNT | ||
2L -> POLICY | ||
3L -> LOGOUT | ||
else -> throw IllegalArgumentException() | ||
} | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
android/app/src/main/java/com/created/team201/presentation/setting/model/SettingUiModel.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.created.team201.presentation.setting.model | ||
|
||
data class SettingUiModel( | ||
val id: Long, | ||
val title: String | ||
) |
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
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