diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index f0ed0539..328609f0 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -6,7 +6,7 @@
+ itemsIndexed(uiState.managerList) { index, value ->
ManagerItem(
manager = value,
currentIndex = index,
@@ -177,7 +177,7 @@ fun NewRulesScreen(
}
fun isAddDay(
- homies: List,
+ homies: List,
homieState: HashMap
): Boolean {
var temp = false
diff --git a/app/src/main/java/com/hous/hous_aos/ui/newrules/NewRulesViewModel.kt b/app/src/main/java/com/hous/hous_aos/ui/newrules/NewRulesViewModel.kt
index e0acbe07..1189293a 100644
--- a/app/src/main/java/com/hous/hous_aos/ui/newrules/NewRulesViewModel.kt
+++ b/app/src/main/java/com/hous/hous_aos/ui/newrules/NewRulesViewModel.kt
@@ -3,9 +3,9 @@ package com.hous.hous_aos.ui.newrules
import android.util.Log
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
-import com.hous.domain.model.Category
-import com.hous.domain.model.DayData
-import com.hous.domain.model.Homie
+import com.hous.domain.model.CategoryInfo
+import com.hous.domain.model.DayDataInfo
+import com.hous.domain.model.HomieInfo
import com.hous.domain.model.Manager
import com.hous.domain.model.State
import com.hous.domain.usecase.AddNewRuleUseCase
@@ -52,7 +52,7 @@ class NewRulesViewModel @Inject constructor(
private fun isDayCheck(): Boolean {
var isDay = true
- for (manager in uiState.value.ManagerList) {
+ for (manager in uiState.value.managerList) {
var temp = false
for (dayList in manager.dayDataList) {
if (dayList.dayState == State.SELECT) {
@@ -105,89 +105,89 @@ class NewRulesViewModel @Inject constructor(
if (isChange) {
val tempManager = listOf(
Manager(
- uiState.value.ManagerList[0].managerHomie,
+ uiState.value.managerList[0].managerHomie,
dayDataList = listOf(
- DayData("월", State.UNSELECT),
- DayData("화", State.UNSELECT),
- DayData("수", State.UNSELECT),
- DayData("목", State.UNSELECT),
- DayData("금", State.UNSELECT),
- DayData("토", State.UNSELECT),
- DayData("일", State.UNSELECT)
+ DayDataInfo("월", State.UNSELECT),
+ DayDataInfo("화", State.UNSELECT),
+ DayDataInfo("수", State.UNSELECT),
+ DayDataInfo("목", State.UNSELECT),
+ DayDataInfo("금", State.UNSELECT),
+ DayDataInfo("토", State.UNSELECT),
+ DayDataInfo("일", State.UNSELECT)
)
)
)
- _uiState.value = _uiState.value.copy(ManagerList = tempManager)
+ _uiState.value = _uiState.value.copy(managerList = tempManager)
} else {
val tempManager = listOf(
Manager(
- uiState.value.ManagerList[0].managerHomie,
+ uiState.value.managerList[0].managerHomie,
dayDataList = listOf(
- DayData("월", State.BLOCK),
- DayData("화", State.BLOCK),
- DayData("수", State.BLOCK),
- DayData("목", State.BLOCK),
- DayData("금", State.BLOCK),
- DayData("토", State.BLOCK),
- DayData("일", State.BLOCK)
+ DayDataInfo("월", State.BLOCK),
+ DayDataInfo("화", State.BLOCK),
+ DayDataInfo("수", State.BLOCK),
+ DayDataInfo("목", State.BLOCK),
+ DayDataInfo("금", State.BLOCK),
+ DayDataInfo("토", State.BLOCK),
+ DayDataInfo("일", State.BLOCK)
)
)
)
- _uiState.value = _uiState.value.copy(ManagerList = tempManager)
+ _uiState.value = _uiState.value.copy(managerList = tempManager)
}
}
fun deleteManager(index: Int) {
- uiState.value.homieState[uiState.value.ManagerList[index].managerHomie.userName] = true
- if (uiState.value.ManagerList.size > 1) {
+ uiState.value.homieState[uiState.value.managerList[index].managerHomie.userName] = true
+ if (uiState.value.managerList.size > 1) {
val tempManager = mutableListOf()
- _uiState.value.ManagerList.forEach { manager -> tempManager.add(manager) }
+ _uiState.value.managerList.forEach { manager -> tempManager.add(manager) }
tempManager.removeAt(index)
- _uiState.value = _uiState.value.copy(ManagerList = tempManager)
+ _uiState.value = _uiState.value.copy(managerList = tempManager)
} else {
- _uiState.value = _uiState.value.copy(ManagerList = listOf(Manager()))
+ _uiState.value = _uiState.value.copy(managerList = listOf(Manager()))
setCheckBoxState("deleteManager", State.UNSELECT)
}
}
- fun choiceManager(managerIndex: Int, homie: Homie) {
- if (uiState.value.ManagerList[managerIndex].managerHomie.userName != "담당자 없음") {
- _uiState.value.homieState[uiState.value.ManagerList[managerIndex].managerHomie.userName] =
+ fun choiceManager(managerIndex: Int, homie: HomieInfo) {
+ if (uiState.value.managerList[managerIndex].managerHomie.userName != "담당자 없음") {
+ _uiState.value.homieState[uiState.value.managerList[managerIndex].managerHomie.userName] =
true
}
val tempManager = Manager(
managerHomie = homie,
- dayDataList = uiState.value.ManagerList[managerIndex].dayDataList
+ dayDataList = uiState.value.managerList[managerIndex].dayDataList
)
val tempManagerList = mutableListOf()
- _uiState.value.ManagerList.forEach { manager -> tempManagerList.add(manager) }
+ _uiState.value.managerList.forEach { manager -> tempManagerList.add(manager) }
tempManagerList[managerIndex] = tempManager
_uiState.value.homieState[homie.userName] = false
- _uiState.value = _uiState.value.copy(ManagerList = tempManagerList)
+ _uiState.value = _uiState.value.copy(managerList = tempManagerList)
}
- fun selectDay(managerIndex: Int, dayData: DayData) {
+ fun selectDay(managerIndex: Int, dayData: DayDataInfo) {
if (dayData.dayState != State.BLOCK) {
val tempManager = Manager(
- managerHomie = _uiState.value.ManagerList[managerIndex].managerHomie,
+ managerHomie = _uiState.value.managerList[managerIndex].managerHomie,
dayDataList = changeDayState(dayData, managerIndex)
)
val tempManagerList = mutableListOf()
- uiState.value.ManagerList.forEach { manager -> tempManagerList.add(manager) }
+ uiState.value.managerList.forEach { manager -> tempManagerList.add(manager) }
tempManagerList[managerIndex] = tempManager
- _uiState.value = _uiState.value.copy(ManagerList = tempManagerList)
+ _uiState.value = _uiState.value.copy(managerList = tempManagerList)
}
}
fun isShowAddButton(): Boolean =
- uiState.value.ManagerList[uiState.value.ManagerList.size - 1].managerHomie.userName != "담당자 없음"
+ uiState.value.managerList[uiState.value.managerList.size - 1].managerHomie.userName != "담당자 없음"
fun addManager() {
val tempManagerList = mutableListOf()
val nextManager = Manager(managerHomie = nextManager())
- uiState.value.ManagerList.forEach { manager -> tempManagerList.add(manager) }
+ uiState.value.managerList.forEach { manager -> tempManagerList.add(manager) }
tempManagerList.add(nextManager)
- _uiState.value = _uiState.value.copy(ManagerList = tempManagerList)
+ _uiState.value = _uiState.value.copy(managerList = tempManagerList)
}
fun addNewRule() {
@@ -197,16 +197,16 @@ class NewRulesViewModel @Inject constructor(
categoryId = uiState.value.categoryId,
notificationState = uiState.value.notificationState,
checkBoxState = uiState.value.checkBoxState,
- managerList = uiState.value.ManagerList
+ managerList = uiState.value.managerList
)
}
}
- private fun nextManager(): Homie {
- var tempHomie = Homie("", "담당자 없음", typeColor = "NULL")
+ private fun nextManager(): HomieInfo {
+ var tempHomie = HomieInfo("", "담당자 없음", typeColor = "NULL")
for (i in uiState.value.homies) {
if (uiState.value.homieState[i.userName]!!) {
- tempHomie = Homie(
+ tempHomie = HomieInfo(
id = i.id,
userName = i.userName,
typeColor = i.typeColor
@@ -218,23 +218,23 @@ class NewRulesViewModel @Inject constructor(
return tempHomie
}
- private fun changeDayState(dayData: DayData, managerIndex: Int): List {
- val tempDay = mutableListOf()
- uiState.value.ManagerList[managerIndex].dayDataList.forEach { d ->
+ private fun changeDayState(dayData: DayDataInfo, managerIndex: Int): List {
+ val tempDay = mutableListOf()
+ uiState.value.managerList[managerIndex].dayDataList.forEach { d ->
if (d.day == dayData.day) {
when (dayData.dayState) {
State.UNSELECT -> {
- tempDay.add(DayData(d.day, State.SELECT))
+ tempDay.add(DayDataInfo(d.day, State.SELECT))
setCheckBoxState("changeDayState Unselect", State.BLOCK)
}
State.SELECT -> {
- tempDay.add(DayData(d.day, State.UNSELECT))
- if (uiState.value.ManagerList.size == 1) {
+ tempDay.add(DayDataInfo(d.day, State.UNSELECT))
+ if (uiState.value.managerList.size == 1) {
var isCheck = true
- uiState.value.ManagerList[0].dayDataList.forEach { dayData ->
+ uiState.value.managerList[0].dayDataList.forEach { dayData ->
if (dayData.dayState == State.SELECT) isCheck = false
}
- if (isCheck && uiState.value.ManagerList[0].managerHomie.userName == "담당자 없음") {
+ if (isCheck && uiState.value.managerList[0].managerHomie.userName == "담당자 없음") {
setCheckBoxState("changeDayState select", State.UNSELECT)
}
}
@@ -252,20 +252,20 @@ data class NewRulesUiState(
val categoryId: String = "",
val notificationState: Boolean = false,
val checkBoxState: State = State.UNSELECT,
- val ruleCategory: List =
+ val ruleCategory: List =
listOf(
- Category("1", "청소기"),
- Category("2", "분리수거"),
- Category("3", "세탁기"),
- Category("4", "물 주기")
+ CategoryInfo("1", "청소기"),
+ CategoryInfo("2", "분리수거"),
+ CategoryInfo("3", "세탁기"),
+ CategoryInfo("4", "물 주기")
),
- val homies: List =
+ val homies: List =
listOf(
- Homie("1", "강원용", typeColor = "RED"),
- Homie("2", "이영주", typeColor = "BLUE"),
- Homie("3", "이준원", typeColor = "YELLOW"),
- Homie("4", "최인영", typeColor = "GREEN"),
- Homie("5", "최소현", typeColor = "PURPLE")
+ HomieInfo("1", "강원용", typeColor = "RED"),
+ HomieInfo("2", "이영주", typeColor = "BLUE"),
+ HomieInfo("3", "이준원", typeColor = "YELLOW"),
+ HomieInfo("4", "최인영", typeColor = "GREEN"),
+ HomieInfo("5", "최소현", typeColor = "PURPLE")
),
val homieState: HashMap = hashMapOf(
"강원용" to true,
@@ -274,5 +274,5 @@ data class NewRulesUiState(
"최인영" to true,
"최소현" to true
),
- val ManagerList: List = listOf(Manager())
+ val managerList: List = listOf(Manager())
)
diff --git a/app/src/main/java/com/hous/hous_aos/ui/newrules/component/CategoryDropDown.kt b/app/src/main/java/com/hous/hous_aos/ui/newrules/component/CategoryDropDown.kt
index b3c9ab53..5434575a 100644
--- a/app/src/main/java/com/hous/hous_aos/ui/newrules/component/CategoryDropDown.kt
+++ b/app/src/main/java/com/hous/hous_aos/ui/newrules/component/CategoryDropDown.kt
@@ -16,12 +16,12 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
+import com.hous.domain.model.CategoryInfo
import com.hous.hous_aos.R
-import com.hous.domain.model.Category
@Composable
fun CategoryDropDownMenu(
- ruleCategoryList: List,
+ ruleCategoryList: List,
setCategory: (String, String) -> Unit
) {
var isExpanded by remember { mutableStateOf(false) }
@@ -40,14 +40,14 @@ fun CategoryDropDownMenu(
expanded = isExpanded,
onDismissRequest = { isExpanded = false }
) {
- ruleCategoryList.forEach { category ->
+ ruleCategoryList.forEach { categoryInfo ->
DropdownMenuItem(
onClick = {
- setCategory(category.id, category.categoryName)
+ setCategory(categoryInfo.id, categoryInfo.categoryName)
isExpanded = false
}
) {
- Text(category.categoryName)
+ Text(categoryInfo.categoryName)
}
}
}
diff --git a/app/src/main/java/com/hous/hous_aos/ui/newrules/component/CategoryItem.kt b/app/src/main/java/com/hous/hous_aos/ui/newrules/component/CategoryItem.kt
index 8d945f6b..b382f934 100644
--- a/app/src/main/java/com/hous/hous_aos/ui/newrules/component/CategoryItem.kt
+++ b/app/src/main/java/com/hous/hous_aos/ui/newrules/component/CategoryItem.kt
@@ -18,14 +18,14 @@ import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
+import com.hous.domain.model.CategoryInfo
import com.hous.hous_aos.R
-import com.hous.domain.model.Category
@Composable
fun CategoryItem(
radius: Dp,
categoryName: String,
- ruleCategoryList: List,
+ ruleCategoryList: List,
setCategory: (String, String) -> Unit
) {
Box(
diff --git a/app/src/main/java/com/hous/hous_aos/ui/newrules/component/Day.kt b/app/src/main/java/com/hous/hous_aos/ui/newrules/component/Day.kt
index dd9e653e..88b784ed 100644
--- a/app/src/main/java/com/hous/hous_aos/ui/newrules/component/Day.kt
+++ b/app/src/main/java/com/hous/hous_aos/ui/newrules/component/Day.kt
@@ -17,15 +17,15 @@ import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.unit.dp
-import com.hous.domain.model.DayData
+import com.hous.domain.model.DayDataInfo
import com.hous.domain.model.State
import com.hous.hous_aos.R
@Composable
fun NewRulesDay(
- dayData: DayData,
+ dayData: DayDataInfo,
currentIndex: Int,
- selectDay: (Int, DayData) -> Unit
+ selectDay: (Int, DayDataInfo) -> Unit
) {
val color = when (dayData.dayState) {
State.UNSELECT -> colorResource(id = R.color.white)
diff --git a/app/src/main/java/com/hous/hous_aos/ui/newrules/component/DayList.kt b/app/src/main/java/com/hous/hous_aos/ui/newrules/component/DayList.kt
index f0c02486..278eb58a 100644
--- a/app/src/main/java/com/hous/hous_aos/ui/newrules/component/DayList.kt
+++ b/app/src/main/java/com/hous/hous_aos/ui/newrules/component/DayList.kt
@@ -5,14 +5,14 @@ import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.runtime.Composable
import androidx.compose.ui.unit.dp
-import com.hous.domain.model.DayData
+import com.hous.domain.model.DayDataInfo
import com.hous.domain.model.Manager
@Composable
fun NewRulesDayList(
manager: Manager,
currentIndex: Int,
- selectDay: (Int, DayData) -> Unit
+ selectDay: (Int, DayDataInfo) -> Unit
) {
LazyRow(horizontalArrangement = Arrangement.spacedBy(6.dp)) {
itemsIndexed(manager.dayDataList) { _, value ->
diff --git a/app/src/main/java/com/hous/hous_aos/ui/newrules/component/ManagerAddButton.kt b/app/src/main/java/com/hous/hous_aos/ui/newrules/component/ManagerAddButton.kt
index 922e59b6..3e36808f 100644
--- a/app/src/main/java/com/hous/hous_aos/ui/newrules/component/ManagerAddButton.kt
+++ b/app/src/main/java/com/hous/hous_aos/ui/newrules/component/ManagerAddButton.kt
@@ -16,13 +16,13 @@ import androidx.compose.ui.draw.clip
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
-import com.hous.domain.model.Homie
+import com.hous.domain.model.HomieInfo
import com.hous.hous_aos.R
import com.hous.hous_aos.ui.newrules.isAddDay
@Composable
fun NewRulesAddMangerButton(
- homies: List,
+ homies: List,
homieState: HashMap,
isShowAddButton: () -> Boolean,
addManager: () -> Unit
diff --git a/app/src/main/java/com/hous/hous_aos/ui/newrules/component/ManagerBox.kt b/app/src/main/java/com/hous/hous_aos/ui/newrules/component/ManagerBox.kt
index 53ac621d..ef01111e 100644
--- a/app/src/main/java/com/hous/hous_aos/ui/newrules/component/ManagerBox.kt
+++ b/app/src/main/java/com/hous/hous_aos/ui/newrules/component/ManagerBox.kt
@@ -20,7 +20,7 @@ import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
-import com.hous.domain.model.Homie
+import com.hous.domain.model.HomieInfo
import com.hous.domain.model.Manager
import com.hous.domain.model.State
import com.hous.hous_aos.R
@@ -30,10 +30,10 @@ fun ManagerBox(
radius: Dp,
managerIndex: Int,
manager: Manager,
- homies: List,
+ homies: List,
homieState: HashMap,
checkBoxState: State,
- choiceManager: (Int, Homie) -> Unit
+ choiceManager: (Int, HomieInfo) -> Unit
) {
Box(
modifier = Modifier
diff --git a/app/src/main/java/com/hous/hous_aos/ui/newrules/component/ManagerDropDown.kt b/app/src/main/java/com/hous/hous_aos/ui/newrules/component/ManagerDropDown.kt
index ab54ecad..ca9d45c8 100644
--- a/app/src/main/java/com/hous/hous_aos/ui/newrules/component/ManagerDropDown.kt
+++ b/app/src/main/java/com/hous/hous_aos/ui/newrules/component/ManagerDropDown.kt
@@ -29,18 +29,18 @@ import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.unit.dp
-import com.hous.hous_aos.R
-import com.hous.domain.model.Homie
+import com.hous.domain.model.HomieInfo
import com.hous.domain.model.State
+import com.hous.hous_aos.R
import com.hous.hous_aos.ui.newrules.isAddDay
@Composable
fun ManagerDropDownMenu(
managerIndex: Int,
- homies: List,
+ homies: List,
homieState: HashMap,
checkBoxState: State,
- choiceManager: (Int, Homie) -> Unit
+ choiceManager: (Int, HomieInfo) -> Unit
) {
if (checkBoxState != State.SELECT && isAddDay(homies, homieState)) {
var isExpanded by remember { mutableStateOf(false) }
@@ -61,15 +61,15 @@ fun ManagerDropDownMenu(
expanded = isExpanded,
onDismissRequest = { isExpanded = false }
) {
- homies.forEach { homie ->
- if (homieState[homie.userName]!!) {
+ homies.forEach { homieInfo ->
+ if (homieState[homieInfo.userName]!!) {
DropdownMenuItem(
onClick = {
- choiceManager(managerIndex, homie)
+ choiceManager(managerIndex, homieInfo)
isExpanded = false
}
) {
- val color = when (homie.typeColor) {
+ val color = when (homieInfo.typeColor) {
"RED" -> colorResource(id = R.color.hous_red)
"BLUE" -> colorResource(id = R.color.hous_blue)
"YELLOW" -> colorResource(id = R.color.hous_yellow)
@@ -89,7 +89,7 @@ fun ManagerDropDownMenu(
)
Spacer(modifier = Modifier.size(6.dp))
Text(
- text = homie.userName,
+ text = homieInfo.userName,
fontFamily = FontFamily(
Font(
resId = R.font.spoqa_han_sans_neo_medium,
diff --git a/app/src/main/java/com/hous/hous_aos/ui/newrules/component/ManagerItem.kt b/app/src/main/java/com/hous/hous_aos/ui/newrules/component/ManagerItem.kt
index f2db6187..c0de3841 100644
--- a/app/src/main/java/com/hous/hous_aos/ui/newrules/component/ManagerItem.kt
+++ b/app/src/main/java/com/hous/hous_aos/ui/newrules/component/ManagerItem.kt
@@ -8,8 +8,8 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
-import com.hous.domain.model.DayData
-import com.hous.domain.model.Homie
+import com.hous.domain.model.DayDataInfo
+import com.hous.domain.model.HomieInfo
import com.hous.domain.model.Manager
import com.hous.domain.model.State
@@ -18,12 +18,12 @@ fun ManagerItem(
manager: Manager,
currentIndex: Int,
checkBoxState: State,
- homies: List,
+ homies: List,
homieState: HashMap,
setCheckBoxState: (String, State) -> Unit,
deleteManager: (Int) -> Unit,
- choiceManager: (Int, Homie) -> Unit,
- selectDay: (Int, DayData) -> Unit
+ choiceManager: (Int, HomieInfo) -> Unit,
+ selectDay: (Int, DayDataInfo) -> Unit
) {
Column {
Row(verticalAlignment = Alignment.CenterVertically) {
diff --git a/app/src/main/java/com/hous/hous_aos/ui/rules/HomeRulesCategoryAdapter.kt b/app/src/main/java/com/hous/hous_aos/ui/rules/HomeRulesCategoryAdapter.kt
index 0d40198e..bbd5d91b 100644
--- a/app/src/main/java/com/hous/hous_aos/ui/rules/HomeRulesCategoryAdapter.kt
+++ b/app/src/main/java/com/hous/hous_aos/ui/rules/HomeRulesCategoryAdapter.kt
@@ -6,7 +6,7 @@ import androidx.annotation.DrawableRes
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
-import com.hous.data.entity.Category
+import com.hous.domain.model.CategoryInfo
import com.hous.hous_aos.R
import com.hous.hous_aos.databinding.ItemRulesRuleBinding
@@ -16,7 +16,7 @@ class HomeRulesCategoryAdapter(
private val onPlusClick: () -> Unit,
private val onChangeIsSelected: (Int) -> Unit
) :
- ListAdapter(
+ ListAdapter(
CategoryOfRuleDiffUtilCallback
) {
private val iconTypeHashMap: HashMap = hashMapOf(
@@ -79,7 +79,7 @@ class HomeRulesCategoryAdapter(
private val binding: ItemRulesRuleBinding
) : RecyclerView.ViewHolder(binding.root) {
- fun onBind(data: com.hous.data.entity.Category) {
+ fun onBind(data: CategoryInfo) {
binding.data = data
binding.iconType = iconTypeHashMap[data.categoryIcon]
/** 앱잼 내에서는 비활성화*/
@@ -100,7 +100,7 @@ class HomeRulesCategoryAdapter(
private val binding: ItemRulesRuleBinding
) : RecyclerView.ViewHolder(binding.root) {
- fun onBind(data: com.hous.data.entity.Category) {
+ fun onBind(data: CategoryInfo) {
binding.data = data
binding.iconType = CategoryIconType.NONE
/** 앱잼 내에서는 비활성화*/
@@ -112,17 +112,17 @@ class HomeRulesCategoryAdapter(
companion object {
private val CategoryOfRuleDiffUtilCallback =
- object : DiffUtil.ItemCallback() {
+ object : DiffUtil.ItemCallback() {
override fun areItemsTheSame(
- oldItem: com.hous.data.entity.Category,
- newItem: com.hous.data.entity.Category
+ oldItem: CategoryInfo,
+ newItem: CategoryInfo
): Boolean {
return oldItem.id == newItem.id
}
override fun areContentsTheSame(
- oldItem: com.hous.data.entity.Category,
- newItem: com.hous.data.entity.Category
+ oldItem: CategoryInfo,
+ newItem: CategoryInfo
): Boolean {
return oldItem == newItem
}
diff --git a/app/src/main/java/com/hous/hous_aos/ui/rules/RulesFragment.kt b/app/src/main/java/com/hous/hous_aos/ui/rules/RulesFragment.kt
index 6d489934..7c8ac6c8 100644
--- a/app/src/main/java/com/hous/hous_aos/ui/rules/RulesFragment.kt
+++ b/app/src/main/java/com/hous/hous_aos/ui/rules/RulesFragment.kt
@@ -37,7 +37,6 @@ class RulesFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
-
initTransaction()
initAdapter()
observeCategory()
diff --git a/app/src/main/java/com/hous/hous_aos/ui/rules/RulesViewModel.kt b/app/src/main/java/com/hous/hous_aos/ui/rules/RulesViewModel.kt
index a81fedd2..6a79a2c4 100644
--- a/app/src/main/java/com/hous/hous_aos/ui/rules/RulesViewModel.kt
+++ b/app/src/main/java/com/hous/hous_aos/ui/rules/RulesViewModel.kt
@@ -1,18 +1,20 @@
package com.hous.hous_aos.ui.rules
-import android.util.Log
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
-import com.hous.data.entity.Category
-import com.hous.data.entity.Homie
-import com.hous.data.entity.Rule
-import com.hous.data.model.response.TempManagerRequest
import com.hous.data.repository.RulesTodayRepository
+import com.hous.domain.model.CategoryInfo
+import com.hous.domain.model.HomieInfo
+import com.hous.domain.model.RuleInfo
+import com.hous.domain.model.TempManagerInfo
+import com.hous.domain.model.rules.RulesTodayInfo
+import com.hous.hous_aos.util.safeLet
import dagger.hilt.android.lifecycle.HiltViewModel
-import javax.inject.Inject
import kotlinx.coroutines.launch
+import timber.log.Timber
+import javax.inject.Inject
@HiltViewModel
class RulesViewModel @Inject constructor(
@@ -25,26 +27,26 @@ class RulesViewModel @Inject constructor(
val isSelectedCategorySmile: LiveData get() = _isSelectedCategorySmile
private var _categoryOfRuleList =
- MutableLiveData>()
+ MutableLiveData>()
val categoryOfRuleList get() = _categoryOfRuleList
private var _todayTodoList =
- MutableLiveData>()
+ MutableLiveData>()
val todayTodoList get() = _todayTodoList
private var _myTodoList =
- MutableLiveData>()
+ MutableLiveData>()
val myTodoList get() = _myTodoList
private var _keyRulesTableList =
- MutableLiveData>()
+ MutableLiveData>()
val keyRulesTableList get() = _keyRulesTableList
private var _generalRulesTableList =
- MutableLiveData>()
+ MutableLiveData>()
val generalRulesTableList get() = _generalRulesTableList
- private var _tmpManagerList = MutableLiveData>()
+ private var _tmpManagerList = MutableLiveData>()
val tmpManagerList get() = _tmpManagerList
private var _tmpTodayToDoPosition = MutableLiveData(0)
@@ -61,25 +63,22 @@ class RulesViewModel @Inject constructor(
init {
viewModelScope.launch {
- rulesTodayRepository.getTodayTodayInfoList("")
- .onSuccess {
- _todayTodoList.value = it.data!!.todayTodoRules
- _categoryOfRuleList.value = it.data!!.homeRuleCategories
- _categoryOfRuleList.value = (_categoryOfRuleList.value!!).plus(
- Category(
+ val rulesTodayInfo: RulesTodayInfo? = rulesTodayRepository.getTodayTodayInfoList("")
+ if (rulesTodayInfo != null) {
+ rulesTodayInfo.let { rulesTodayInfo ->
+ Timber.d("RulesViewModel init")
+ _todayTodoList.value = rulesTodayInfo.todayTodoRules
+ _categoryOfRuleList.value = rulesTodayInfo.homeRuleCategories.plus(
+ CategoryInfo(
id = "62d6b94e0e9be86f165d48db",
categoryName = "없음",
categoryIcon = "CLEAN"
)
)
- Log.d(
- TAG,
- "통신 시작 -- ${_todayTodoList?.value}"
- )
- }
- .onFailure {
- Log.d(TAG, "RulesViewModel - init - getRulesTodayList fail : ${it.message}")
}
+ } else {
+ Timber.e("rulesTodayInfo: $rulesTodayInfo")
+ }
}
}
@@ -88,28 +87,29 @@ class RulesViewModel @Inject constructor(
* 임시 담당자 save버튼 누르면 서버로 보내기
* */
fun putToTmpManagerList() {
- val clickedTmpManagerList: MutableList = mutableListOf()
- _tmpManagerList.value?.forEach {
- if (it.isChecked) clickedTmpManagerList.add(it.id!!)
- }
- val tmp = TempManagerRequest(clickedTmpManagerList)
- Log.d(
- TAG,
- "Put -- tmp.tmpRuleMembers: ${tmp.tmpRuleMembers} tmp.size : ${tmp.tmpRuleMembers.size}"
- )
- viewModelScope.launch {
- rulesTodayRepository.putTempManagerInfoList(
- "",
- _todayTodoList.value!![tmpTodayToDoPosition.value!!].id,
- tmp
- )
- .onSuccess {
- fetchToTodayToDoList()
- }
- .onFailure {
- Log.d(TAG, " result fail : $tmp")
- Log.d(TAG, " result fail : ${it.message}")
+ val clickedTmpManagerList: MutableList =
+ mutableListOf().also { clickedTmpManagerList ->
+ _tmpManagerList.value?.forEach { homieInfo ->
+ homieInfo.id?.let { id ->
+ if (homieInfo.isChecked) clickedTmpManagerList.add(id)
+ } ?: Timber.e("homieInfo.id: ${homieInfo.id}")
}
+ Timber.d("clickedTmpManagerList - $clickedTmpManagerList")
+ }
+
+ viewModelScope.launch {
+ safeLet(
+ todayTodoList.value,
+ tmpTodayToDoPosition.value
+ ) { todayTodoList: List, position: Int ->
+ rulesTodayRepository.putTempManagerInfoList(
+ "",
+ todayTodoList[position].id,
+ clickedTmpManagerList
+ )
+ fetchToTodayToDoList()
+ }
+ ?: Timber.e("Put 실패 - todayTodoList: ${todayTodoList.value}, tmpTodayToDoPosition: ${tmpTodayToDoPosition.value}}")
}
}
@@ -117,61 +117,39 @@ class RulesViewModel @Inject constructor(
* 임시 담당자 checked 바꾸기
* */
fun setSelectedTmpManager(position: Int) {
- requireNotNull(_tmpManagerList.value)[position].isChecked =
- !requireNotNull(_tmpManagerList.value)[position].isChecked
+ _tmpManagerList.value?.let { tmpManagerList ->
+ val checkState = !(tmpManagerList[position].isChecked)
+ tmpManagerList[position].isChecked = checkState
+ }
}
/** get
* 임시 담당자 다이얼로그 조회 */
fun fetchToTmpManagerList(position: Int) {
- Log.d(
- TAG,
- "RulesViewModel - fetchToTmpManagerList() _todayTodoList.value!![position].id: ${_todayTodoList.value!![position].id}"
- )
viewModelScope.launch {
- rulesTodayRepository.getTempManagerInfoList("", _todayTodoList.value!![position].id)
- .onSuccess {
- _tmpManagerList.value = it.data!!.homies
- _tmpTodayToDoPosition.postValue(position)
- }
- .onFailure {
- Log.d(TAG, "RulesViewModel - fetchToTmpManagerList() - ${it.message}")
- }
+ val tempManagerInfo: TempManagerInfo? =
+ rulesTodayRepository.getTempManagerInfoList("", _todayTodoList.value!![position].id)
+ tempManagerInfo?.let { tempManagerInfo ->
+ _tmpManagerList.value = tempManagerInfo.homies
+ _tmpTodayToDoPosition.value = position
+ } ?: Timber.e("서버통신 실패")
}
}
- fun fetchToTodayToDoList() {
+ fun fetchToTodayToDoList() =
viewModelScope.launch {
- rulesTodayRepository.getTodayTodayInfoList("")
- .onSuccess {
- _todayTodoList.value = it.data!!.todayTodoRules
-// Log.d(
-// TAG,
-// "다시서버통신 -- Size: ${_todayTodoList?.value!![0].todayMembersWithTypeColor.size}"
-// )
- }
- .onFailure {
- Log.d(
- TAG,
- "RulesViewModel - init - getRulesTodayList fail : ${it.message}"
- )
- }
+ rulesTodayRepository.getTodayTodayInfoList("")?.let { rulesTodayInfo ->
+ _todayTodoList.value = rulesTodayInfo.todayTodoRules
+ } ?: Timber.e("서버통신 실패")
}
- }
/** get
* My -To - DO 서버통신*/
fun fetchToMyTodayToDoList() {
viewModelScope.launch {
- rulesTodayRepository.getMyTodoInfoList("")
- .onSuccess {
- _myTodoList.value = it.data!!
- Log.d(TAG, "RulesViewModel - fetchToMyTodayToDoList() called")
- Log.d("MYTODO", "Success ")
- }
- .onFailure {
- Log.d(TAG, "fail : ${it.message}")
- }
+ rulesTodayRepository.getMyTodoInfoList("")?.let { ruleInfoList ->
+ _myTodoList.value = ruleInfoList
+ } ?: Timber.e("서버통신 실패")
}
}
@@ -179,26 +157,18 @@ class RulesViewModel @Inject constructor(
* 나의 to-do check한 거 보내기
* */
fun setMyToDoCheckBoxSelected(position: Int) {
- val isSelected = myTodoList.value!![position].isChecked
- myTodoList.value!![position].isChecked = !isSelected
- val checked = myTodoList.value!![position].isChecked
- val id = myTodoList.value!![position].id
- viewModelScope.launch {
- rulesTodayRepository.putMyToDoCheckLust(
- "",
- id,
- com.hous.data.model.request.MyToDoCheckRequest(checked)
- )
- .onSuccess {
- Log.d(TAG, "Success - id: $id, checked: $checked ")
- }
- .onFailure {
- Log.d(
- TAG,
- "fail - $id, checked: $checked - :${it.message}"
- )
- }
- }
+ myTodoList.value?.let { myTodoList ->
+ val checkState = !(myTodoList[position].isChecked)
+ myTodoList[position].isChecked = checkState
+ val id = myTodoList[position].id
+ viewModelScope.launch {
+ rulesTodayRepository.putMyToDoCheckLust(
+ "",
+ id,
+ checkState
+ )
+ }
+ } ?: Timber.e("myTodoList: ${myTodoList.value}")
}
/**
@@ -208,33 +178,17 @@ class RulesViewModel @Inject constructor(
val categoryId = categoryOfRuleList.value!![position].id
_categoryName.value = categoryOfRuleList.value!![position].categoryName
_categoryId.value = categoryOfRuleList.value!![position].id
- Log.d("RulesViewModel", "categoryId: $categoryId")
viewModelScope.launch {
- rulesTodayRepository.getRuleTableInfoList("", categoryId)
- .onSuccess {
- Log.d("RulesViewModel", "Success - RulesTableList() ${it.message}")
- val data = it.data
- Log.d("RulesViewModel", "Success- data: $data")
- val tmpGeneralRulesTableList = data!!.rules
- val tmpKeyRulesTableList = data.keyRules
- val totalRulesDataSize =
- tmpGeneralRulesTableList.size + tmpKeyRulesTableList.size
-
- _ruleTableSize.value = totalRulesDataSize
- _generalRulesTableList.value = tmpGeneralRulesTableList
- _keyRulesTableList.value = tmpKeyRulesTableList
- Log.d(
- "RulesViewModel",
- "Success -keyRulesTableList: ${generalRulesTableList.value}"
- )
- Log.d(
- "RulesViewModel",
- "Success -tmpGeneralRulesTableList: ${keyRulesTableList.value}"
- )
- }
- .onFailure {
- Log.d("RulesViewModel", "Fail - RulesTableList() ${it.message}")
- }
+ rulesTodayRepository.getRuleTableInfoList("", categoryId)?.let {
+ val tmpGeneralRulesTableList = it.rules
+ val tmpKeyRulesTableList = it.keyRules
+ val totalRulesDataSize =
+ tmpGeneralRulesTableList.size + tmpKeyRulesTableList.size
+
+ _ruleTableSize.value = totalRulesDataSize
+ _generalRulesTableList.value = tmpGeneralRulesTableList
+ _keyRulesTableList.value = tmpKeyRulesTableList
+ }
}
}
@@ -268,8 +222,4 @@ class RulesViewModel @Inject constructor(
tmpCategoryOfRuleList[position].isChecked = true
_categoryOfRuleList.value = tmpCategoryOfRuleList.toList()
}
-
- companion object {
- private const val TAG = "RulesViewModel"
- }
}
diff --git a/app/src/main/java/com/hous/hous_aos/ui/rules/my_to_do/MyToDoAdapter.kt b/app/src/main/java/com/hous/hous_aos/ui/rules/my_to_do/MyToDoAdapter.kt
index 4b0ad9be..17e7c127 100644
--- a/app/src/main/java/com/hous/hous_aos/ui/rules/my_to_do/MyToDoAdapter.kt
+++ b/app/src/main/java/com/hous/hous_aos/ui/rules/my_to_do/MyToDoAdapter.kt
@@ -5,11 +5,11 @@ import android.view.ViewGroup
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
-import com.hous.data.entity.Rule
+import com.hous.domain.model.RuleInfo
import com.hous.hous_aos.databinding.ItemRulesMyToDoBinding
class MyToDoAdapter(private val onClickIcon: (Int) -> Unit) :
- ListAdapter(
+ ListAdapter(
MyTodoDiffUtilCallback
) {
private val iconTypeHashMap: HashMap = hashMapOf(
@@ -28,7 +28,7 @@ class MyToDoAdapter(private val onClickIcon: (Int) -> Unit) :
private val iconTypeHashMap: HashMap,
private val onClickIcon: (Int) -> Unit
) : RecyclerView.ViewHolder(binding.root) {
- fun onBind(data: Rule) {
+ fun onBind(data: RuleInfo) {
binding.data = data
binding.iconType = iconTypeHashMap[data.categoryIcon]
binding.clMyToDo.setOnClickListener {
@@ -55,18 +55,18 @@ class MyToDoAdapter(private val onClickIcon: (Int) -> Unit) :
companion object {
private val MyTodoDiffUtilCallback =
- object : DiffUtil.ItemCallback() {
+ object : DiffUtil.ItemCallback() {
override fun areItemsTheSame(
- oldItem: Rule,
- newItem: Rule
+ oldItem: RuleInfo,
+ newItem: RuleInfo
): Boolean {
return oldItem.id == newItem.id
}
override fun areContentsTheSame(
- oldItem: Rule,
- newItem: Rule
+ oldItem: RuleInfo,
+ newItem: RuleInfo
): Boolean {
return oldItem == newItem
}
diff --git a/app/src/main/java/com/hous/hous_aos/ui/rules/rules_table/GeneralRulesAdapter.kt b/app/src/main/java/com/hous/hous_aos/ui/rules/rules_table/GeneralRulesAdapter.kt
index 74714ca9..8bdfbbb7 100644
--- a/app/src/main/java/com/hous/hous_aos/ui/rules/rules_table/GeneralRulesAdapter.kt
+++ b/app/src/main/java/com/hous/hous_aos/ui/rules/rules_table/GeneralRulesAdapter.kt
@@ -1,17 +1,17 @@
package com.hous.hous_aos.ui.rules.rules_table
-import android.util.Log
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.hous.data.entity.Rule
+import com.hous.domain.model.RuleInfo
import com.hous.hous_aos.databinding.ItemRulesTableGeneralBinding
import com.hous.hous_aos.ui.rules.IconColor
+import timber.log.Timber
class GeneralRulesAdapter :
- ListAdapter(generalRulesDiffUtil) {
+ ListAdapter(generalRulesDiffUtil) {
private val iconColorHashMap: HashMap = hashMapOf(
"RED" to IconColor.RED,
@@ -30,8 +30,8 @@ class GeneralRulesAdapter :
override fun onBindViewHolder(holder: GeneralRulesViewHolder, position: Int) {
val currentItem = currentList[position]
- Log.d("크기", "$currentList")
- Log.d("크기", "${currentList.size}")
+ Timber.d("크기", "$currentList")
+ Timber.d("크기", "${currentList.size}")
holder.onBind(currentItem)
}
@@ -40,11 +40,10 @@ class GeneralRulesAdapter :
private val iconColorHashMap: HashMap
) :
RecyclerView.ViewHolder(binding.root) {
- fun onBind(data: Rule) {
+ fun onBind(data: RuleInfo) {
binding.data = data
val memberCnt = if (data.membersCnt >= 4) 3 else data.membersCnt
- Log.d(
- "GeneralAdapter",
+ Timber.d(
"memberCnt:$memberCnt , data.iconList.size 값 : ${data.typeColors.size} ,data.iconList: ${data.typeColors} 이 들어왔습니다."
)
when (memberCnt) {
@@ -73,17 +72,17 @@ class GeneralRulesAdapter :
}
companion object {
- private val generalRulesDiffUtil = object : DiffUtil.ItemCallback() {
+ private val generalRulesDiffUtil = object : DiffUtil.ItemCallback() {
override fun areItemsTheSame(
- oldItem: Rule,
- newItem: Rule
+ oldItem: RuleInfo,
+ newItem: RuleInfo
): Boolean {
return oldItem.id == newItem.id
}
override fun areContentsTheSame(
- oldItem: Rule,
- newItem: Rule
+ oldItem: RuleInfo,
+ newItem: RuleInfo
): Boolean {
return oldItem == newItem
}
diff --git a/app/src/main/java/com/hous/hous_aos/ui/rules/rules_table/KeyRulesAdapter.kt b/app/src/main/java/com/hous/hous_aos/ui/rules/rules_table/KeyRulesAdapter.kt
index a8a80a6b..5a0b3954 100644
--- a/app/src/main/java/com/hous/hous_aos/ui/rules/rules_table/KeyRulesAdapter.kt
+++ b/app/src/main/java/com/hous/hous_aos/ui/rules/rules_table/KeyRulesAdapter.kt
@@ -5,11 +5,11 @@ import android.view.ViewGroup
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
-import com.hous.data.entity.Rule
+import com.hous.domain.model.RuleInfo
import com.hous.hous_aos.databinding.ItemRulesTableKeysBinding
class KeyRulesAdapter :
- ListAdapter(rulesTableDiffUtil) {
+ ListAdapter(rulesTableDiffUtil) {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): KeyRulesViewHolder {
val binding =
@@ -24,18 +24,18 @@ class KeyRulesAdapter :
class KeyRulesViewHolder(private val binding: ItemRulesTableKeysBinding) :
RecyclerView.ViewHolder(binding.root) {
- fun onBind(data: Rule) {
+ fun onBind(data: RuleInfo) {
binding.data = data
}
}
companion object {
- private val rulesTableDiffUtil = object : DiffUtil.ItemCallback() {
- override fun areItemsTheSame(oldItem: Rule, newItem: Rule): Boolean {
+ private val rulesTableDiffUtil = object : DiffUtil.ItemCallback() {
+ override fun areItemsTheSame(oldItem: RuleInfo, newItem: RuleInfo): Boolean {
return oldItem.id == newItem.id
}
- override fun areContentsTheSame(oldItem: Rule, newItem: Rule): Boolean {
+ override fun areContentsTheSame(oldItem: RuleInfo, newItem: RuleInfo): Boolean {
return oldItem == newItem
}
}
diff --git a/app/src/main/java/com/hous/hous_aos/ui/rules/rules_table/RulesTableFragment.kt b/app/src/main/java/com/hous/hous_aos/ui/rules/rules_table/RulesTableFragment.kt
index 11fff3b6..d129a49d 100644
--- a/app/src/main/java/com/hous/hous_aos/ui/rules/rules_table/RulesTableFragment.kt
+++ b/app/src/main/java/com/hous/hous_aos/ui/rules/rules_table/RulesTableFragment.kt
@@ -5,7 +5,6 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
-import androidx.compose.runtime.snapshots.Snapshot.Companion.observe
import androidx.databinding.DataBindingUtil
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
@@ -27,7 +26,7 @@ class RulesTableFragment : Fragment() {
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
- ): View? {
+ ): View {
_binding =
DataBindingUtil.inflate(inflater, R.layout.fragment_rules_table, container, false)
binding.viewModel = viewModel
diff --git a/app/src/main/java/com/hous/hous_aos/ui/rules/today_to_do/TodayToDoFragment.kt b/app/src/main/java/com/hous/hous_aos/ui/rules/today_to_do/TodayToDoFragment.kt
index 18385389..1bc6cfa9 100644
--- a/app/src/main/java/com/hous/hous_aos/ui/rules/today_to_do/TodayToDoFragment.kt
+++ b/app/src/main/java/com/hous/hous_aos/ui/rules/today_to_do/TodayToDoFragment.kt
@@ -13,7 +13,6 @@ import com.hous.hous_aos.R
import com.hous.hous_aos.databinding.FragmentTodayToDoBinding
import com.hous.hous_aos.ui.rules.RulesViewModel
import com.hous.hous_aos.ui.rules.ToDoViewType
-import com.hous.hous_aos.ui.rules.adapter.TodayTodoAdapter
import com.hous.hous_aos.ui.rules.my_to_do.MyToDoFragment
import com.hous.hous_aos.ui.rules.today_to_do.tem_dialog.TempManagerDialogFragment
import dagger.hilt.android.AndroidEntryPoint
diff --git a/app/src/main/java/com/hous/hous_aos/ui/rules/today_to_do/TodayTodoAdapter.kt b/app/src/main/java/com/hous/hous_aos/ui/rules/today_to_do/TodayTodoAdapter.kt
index e3d46fd6..45813100 100644
--- a/app/src/main/java/com/hous/hous_aos/ui/rules/today_to_do/TodayTodoAdapter.kt
+++ b/app/src/main/java/com/hous/hous_aos/ui/rules/today_to_do/TodayTodoAdapter.kt
@@ -1,23 +1,23 @@
-package com.hous.hous_aos.ui.rules.adapter
+package com.hous.hous_aos.ui.rules.today_to_do
-import android.util.Log
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.hous.data.entity.Rule
+import com.hous.domain.model.HomieInfo
+import com.hous.domain.model.RuleInfo
import com.hous.hous_aos.databinding.ItemRulesTodayToDoItemMultiBinding
import com.hous.hous_aos.databinding.ItemRulesTodayToDoItemNoneBinding
import com.hous.hous_aos.databinding.ItemRulesTodayToDoItemOneBinding
import com.hous.hous_aos.ui.rules.IconColor
-import com.hous.hous_aos.ui.rules.today_to_do.ItemToDoViewType
+import timber.log.Timber
class TodayTodoAdapter(
private val onClickIcon: () -> Unit,
private val fetchToTmpManagerList: (Int) -> Unit
) :
- ListAdapter(
+ ListAdapter(
TodayTodoDiffUtilCallback
) {
@@ -81,8 +81,8 @@ class TodayTodoAdapter(
private val onClickIcon: () -> Unit,
private val binding: ItemRulesTodayToDoItemNoneBinding
) : RecyclerView.ViewHolder(binding.root) {
- fun onBind(data: com.hous.data.entity.Rule) {
- Log.d(TAG, "NONE : , data: $data")
+ fun onBind(data: RuleInfo) {
+ Timber.d("NONE : , data: $data")
binding.data = data
binding.ivManagerEmpty.setOnClickListener {
fetchToTmpManagerList(absoluteAdapterPosition)
@@ -96,8 +96,8 @@ class TodayTodoAdapter(
private val onClickIcon: () -> Unit,
private val binding: ItemRulesTodayToDoItemOneBinding
) : RecyclerView.ViewHolder(binding.root) {
- fun onBind(data: com.hous.data.entity.Rule) {
- Log.d(TAG, "One : , data: $data")
+ fun onBind(data: RuleInfo) {
+ Timber.d("One : , data: $data")
binding.data = data
binding.tvManager.text =
changeListToString(requireNotNull(data.todayMembersWithTypeColor))
@@ -109,7 +109,7 @@ class TodayTodoAdapter(
}
}
- private fun changeListToString(managerDataList: List): String {
+ private fun changeListToString(managerDataList: List): String {
val textList = managerDataList.map { it.userName }
return textList[0]
}
@@ -132,8 +132,8 @@ class TodayTodoAdapter(
private val onClickIcon: () -> Unit,
private val binding: ItemRulesTodayToDoItemMultiBinding
) : RecyclerView.ViewHolder(binding.root) {
- fun onBind(data: com.hous.data.entity.Rule) {
- Log.d(TAG, "MULTI : , data: $data")
+ fun onBind(data: RuleInfo) {
+ Timber.d("MULTI : , data: $data")
binding.data = data
binding.tvManager.text =
changeListToString(requireNotNull(data.todayMembersWithTypeColor))
@@ -167,7 +167,7 @@ class TodayTodoAdapter(
}
}
- private fun changeListToString(managerDataList: List): String {
+ private fun changeListToString(managerDataList: List): String {
val textList = managerDataList.map { it.userName }
val sizeOfTextList = textList.size
return if (sizeOfTextList in 2..3) {
@@ -202,24 +202,23 @@ class TodayTodoAdapter(
companion object {
private val TodayTodoDiffUtilCallback =
- object : DiffUtil.ItemCallback() {
+ object : DiffUtil.ItemCallback() {
override fun areItemsTheSame(
- oldItem: Rule,
- newItem: Rule
+ oldItem: RuleInfo,
+ newItem: RuleInfo
): Boolean {
return oldItem.id == newItem.id
}
override fun areContentsTheSame(
- oldItem: Rule,
- newItem: Rule
+ oldItem: RuleInfo,
+ newItem: RuleInfo
): Boolean {
return oldItem == newItem
}
}
- const val TAG = "로그"
- private const val MANAGER_NUMBER_ZERO = 0
+
private const val MANAGER_NUMBER_ONE = 1
private const val MANAGER_NUMBER_TWO = 2
private const val BLUE = "BLUE"
diff --git a/app/src/main/java/com/hous/hous_aos/ui/rules/today_to_do/tem_dialog/TempManagerDialogFragment.kt b/app/src/main/java/com/hous/hous_aos/ui/rules/today_to_do/tem_dialog/TempManagerDialogFragment.kt
index eda09214..2ce8bd57 100644
--- a/app/src/main/java/com/hous/hous_aos/ui/rules/today_to_do/tem_dialog/TempManagerDialogFragment.kt
+++ b/app/src/main/java/com/hous/hous_aos/ui/rules/today_to_do/tem_dialog/TempManagerDialogFragment.kt
@@ -25,7 +25,7 @@ class TempManagerDialogFragment : DialogFragment() {
_binding =
DataBindingUtil.inflate(inflater, R.layout.fragment_temp_manager, container, false)
binding.viewModel = viewModel
- binding.lifecycleOwner = requireActivity()
+ binding.lifecycleOwner = viewLifecycleOwner
return binding.root
}
diff --git a/app/src/main/java/com/hous/hous_aos/ui/rules/today_to_do/tem_dialog/TempMangerAdapter.kt b/app/src/main/java/com/hous/hous_aos/ui/rules/today_to_do/tem_dialog/TempMangerAdapter.kt
index 32afb355..7aa8ce45 100644
--- a/app/src/main/java/com/hous/hous_aos/ui/rules/today_to_do/tem_dialog/TempMangerAdapter.kt
+++ b/app/src/main/java/com/hous/hous_aos/ui/rules/today_to_do/tem_dialog/TempMangerAdapter.kt
@@ -5,12 +5,12 @@ import android.view.ViewGroup
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
-import com.hous.data.entity.Homie
+import com.hous.domain.model.HomieInfo
import com.hous.hous_aos.databinding.ItemRulesTmpManagersBinding
import com.hous.hous_aos.ui.rules.HomieIconType
class TempMangerAdapter(private val setSelectedTmpManager: (Int) -> Unit) :
- ListAdapter(tempManagerDiffUtil) {
+ ListAdapter(tempManagerDiffUtil) {
private val homieIconHashMap: HashMap = hashMapOf(
"RED" to HomieIconType.RED,
"BLUE" to HomieIconType.BLUE,
@@ -37,7 +37,7 @@ class TempMangerAdapter(private val setSelectedTmpManager: (Int) -> Unit) :
private val setSelectedTmpManager: (Int) -> Unit
) :
RecyclerView.ViewHolder(binding.root) {
- fun onBind(data: Homie) {
+ fun onBind(data: HomieInfo) {
binding.data = data
binding.homieIconType = homieIconHashMap[data.typeColor]
binding.ivManagerIcon.setOnClickListener {
@@ -48,17 +48,17 @@ class TempMangerAdapter(private val setSelectedTmpManager: (Int) -> Unit) :
}
companion object {
- private val tempManagerDiffUtil = object : DiffUtil.ItemCallback() {
+ private val tempManagerDiffUtil = object : DiffUtil.ItemCallback() {
override fun areItemsTheSame(
- oldItem: Homie,
- newItem: Homie
+ oldItem: HomieInfo,
+ newItem: HomieInfo
): Boolean {
return oldItem.id == newItem.id
}
override fun areContentsTheSame(
- oldItem: Homie,
- newItem: Homie
+ oldItem: HomieInfo,
+ newItem: HomieInfo
): Boolean {
return oldItem == newItem
}
diff --git a/app/src/main/java/com/hous/hous_aos/util/SafeLet.kt b/app/src/main/java/com/hous/hous_aos/util/SafeLet.kt
new file mode 100644
index 00000000..35569106
--- /dev/null
+++ b/app/src/main/java/com/hous/hous_aos/util/SafeLet.kt
@@ -0,0 +1,7 @@
+package com.hous.hous_aos.util
+
+/**
+ * 변수 2가지 이상 null 체크할 때 사용 */
+inline fun safeLet(p1: T1?, p2: T2?, block: (T1, T2) -> R?): R? {
+ return if (p1 != null && p2 != null) block(p1, p2) else null
+}
diff --git a/app/src/main/java/com/hous/hous_aos/util/TimberDebugTree.kt b/app/src/main/java/com/hous/hous_aos/util/TimberDebugTree.kt
new file mode 100644
index 00000000..b675bdc4
--- /dev/null
+++ b/app/src/main/java/com/hous/hous_aos/util/TimberDebugTree.kt
@@ -0,0 +1,12 @@
+package com.hous.hous_aos.util
+
+import timber.log.Timber
+
+/**
+ * DebugTree를 상속받아 더 자세한 Log남기기*/
+class TimberDebugTree : Timber.DebugTree() {
+
+ override fun createStackElementTag(element: StackTraceElement): String? {
+ return "${element.fileName} : ${element.lineNumber} - ${element.methodName}"
+ }
+}
diff --git a/app/src/main/res/layout/fragment_rules_table.xml b/app/src/main/res/layout/fragment_rules_table.xml
index 70e4b7a9..7c023bd7 100644
--- a/app/src/main/res/layout/fragment_rules_table.xml
+++ b/app/src/main/res/layout/fragment_rules_table.xml
@@ -37,6 +37,7 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:itemCount="3"
+ android:clipToPadding="true"
tools:listitem="@layout/item_rules_table_general" />
+ type="com.hous.domain.model.RuleInfo" />
+ type="com.hous.domain.model.CategoryInfo" />
+ type="com.hous.domain.model.RuleInfo" />
+ type="com.hous.domain.model.RuleInfo" />
+ type="com.hous.domain.model.HomieInfo" />
+ type="com.hous.domain.model.RuleInfo" />
+ type="com.hous.domain.model.RuleInfo" />
+ type="com.hous.domain.model.RuleInfo" />
+ ): WrapperClass
@DELETE("room/{roomId}/event/{eventId}")
suspend fun deleteEvent(
@Path("roomId") roomId: String,
@Path("eventId") eventId: String
- ): com.hous.data.model.WrapperClass
+ ): WrapperClass
@GET("room/{roomId}/event/{eventId}")
suspend fun getEventList(
@Path("roomId") roomId: String,
@Path("eventId") eventId: String
- ): com.hous.data.model.WrapperClass
+ ): WrapperClass
@PUT("room/{roomId}/event/{eventId}")
suspend fun putEventList(
@Path("roomId") roomId: String,
@Path("eventId") eventId: String,
- @Body body: com.hous.data.model.request.EventListRequest
- ): com.hous.data.model.WrapperClass
+ @Body body: EventListRequest
+ ): WrapperClass
@POST("room/{roomId}/event")
suspend fun addEvent(
@Path("roomId") roomId: String,
- @Body body: com.hous.data.model.request.EventListRequest
- ): com.hous.data.model.WrapperClass
+ @Body body: EventListRequest
+ ): WrapperClass
@GET("user/{homieId}")
suspend fun getHomieList(
@Path("homieId") homieId: String
- ): com.hous.data.model.WrapperClass
+ ): WrapperClass
@GET("user/{userId}/type")
suspend fun getHomieResult(
@Path("userId") userId: String
- ): com.hous.data.model.WrapperClass
+ ): WrapperClass
}
diff --git a/data/src/main/java/com/hous/data/api/RulesApi.kt b/data/src/main/java/com/hous/data/api/RulesApi.kt
index ae041bd4..96d4e907 100644
--- a/data/src/main/java/com/hous/data/api/RulesApi.kt
+++ b/data/src/main/java/com/hous/data/api/RulesApi.kt
@@ -1,5 +1,11 @@
package com.hous.data.api
+import com.hous.data.entity.Rule
+import com.hous.data.model.WrapperClass
+import com.hous.data.model.request.MyToDoCheckRequest
+import com.hous.data.model.request.TempManagerRequest
+import com.hous.data.model.response.RulesTodayInfoListResponse
+import com.hous.data.model.response.TempManagerResponse
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.PUT
@@ -9,32 +15,32 @@ interface RulesApi {
@GET("room/{roomId}/rules")
suspend fun getTodayTodayInfoList(
@Path("roomId") roomId: String
- ): com.hous.data.model.WrapperClass
+ ): WrapperClass
@GET("/room/{roomId}/rule/{ruleId}/today")
suspend fun getTempManagerInfoList(
@Path("roomId") roomId: String,
@Path("ruleId") ruleId: String
- ): com.hous.data.model.WrapperClass
+ ): WrapperClass
@PUT("/room/{roomId}/rule/{ruleId}/today")
suspend fun putTempManagerInfoList(
@Path("roomId") roomId: String,
@Path("ruleId") ruleId: String,
- @Body tmpRuleMembers: com.hous.data.model.response.TempManagerRequest
- ): com.hous.data.model.WrapperClass
+ @Body tmpRuleMembers: TempManagerRequest
+ ): Any?
@GET("/room/{roomId}/rules/me")
suspend fun getMyTodoInfoList(
@Path("roomId") roomId: String
- ): com.hous.data.model.WrapperClass>
+ ): WrapperClass>
@PUT("room/{roomId}/rule/{ruleId}/check")
suspend fun putMyToDoCheckList(
@Path("roomId") roomId: String,
@Path("ruleId") ruleId: String,
- @Body isCheck: com.hous.data.model.request.MyToDoCheckRequest
- ): com.hous.data.model.WrapperClass
+ @Body isCheck: MyToDoCheckRequest
+ ): WrapperClass
@GET("/room/{roomId}/category/{categoryId}/rule")
suspend fun getRuleTableInfoList(
diff --git a/data/src/main/java/com/hous/data/entity/Category.kt b/data/src/main/java/com/hous/data/entity/Category.kt
index 44e2b084..0b671f8d 100644
--- a/data/src/main/java/com/hous/data/entity/Category.kt
+++ b/data/src/main/java/com/hous/data/entity/Category.kt
@@ -1,7 +1,7 @@
package com.hous.data.entity
import com.google.gson.annotations.SerializedName
-import com.hous.domain.model.Category
+import com.hous.domain.model.CategoryInfo
data class Category(
@SerializedName("_id") val id: String = "",
@@ -10,5 +10,5 @@ data class Category(
val ruleName: String = "",
var isChecked: Boolean = false
) {
- fun toCategory() = Category(id, categoryName, categoryIcon, ruleName, isChecked)
+ fun toCategoryInfo() = CategoryInfo(id, categoryName, categoryIcon, ruleName, isChecked)
}
diff --git a/data/src/main/java/com/hous/data/entity/Homie.kt b/data/src/main/java/com/hous/data/entity/Homie.kt
index c64987ef..709d1ebb 100644
--- a/data/src/main/java/com/hous/data/entity/Homie.kt
+++ b/data/src/main/java/com/hous/data/entity/Homie.kt
@@ -1,7 +1,7 @@
package com.hous.data.entity
import com.google.gson.annotations.SerializedName
-import com.hous.domain.model.Homie
+import com.hous.domain.model.HomieInfo
data class Homie(
@SerializedName("_id") val id: String? = null,
@@ -16,7 +16,7 @@ data class Homie(
var isChecked: Boolean = false,
val notificationState: Boolean = false
) {
- fun toHomie(): Homie = Homie(
+ fun toHomieInfo(): HomieInfo = HomieInfo(
id,
userName,
typeName,
diff --git a/data/src/main/java/com/hous/data/entity/Rule.kt b/data/src/main/java/com/hous/data/entity/Rule.kt
index 431e58b4..366e1157 100644
--- a/data/src/main/java/com/hous/data/entity/Rule.kt
+++ b/data/src/main/java/com/hous/data/entity/Rule.kt
@@ -1,6 +1,7 @@
package com.hous.data.entity
import com.google.gson.annotations.SerializedName
+import com.hous.domain.model.RuleInfo
data class Rule(
@SerializedName("_id") val id: String = "",
@@ -11,5 +12,17 @@ data class Rule(
val isAllChecked: Boolean = false,
val membersCnt: Int = 0,
val typeColors: List = emptyList(),
- val categoryIcon: String = "",
-)
+ val categoryIcon: String = ""
+) {
+ fun toRuleInfo() = RuleInfo(
+ id,
+ isChecked,
+ ruleName,
+ todayMembersWithTypeColor.map { it.toHomieInfo() },
+ isTmpMember,
+ isAllChecked,
+ membersCnt,
+ typeColors,
+ categoryIcon
+ )
+}
diff --git a/data/src/main/java/com/hous/data/model/response/TempManagerRequest.kt b/data/src/main/java/com/hous/data/model/request/TempManagerRequest.kt
similarity index 69%
rename from data/src/main/java/com/hous/data/model/response/TempManagerRequest.kt
rename to data/src/main/java/com/hous/data/model/request/TempManagerRequest.kt
index d88975bd..a0b7b1c6 100644
--- a/data/src/main/java/com/hous/data/model/response/TempManagerRequest.kt
+++ b/data/src/main/java/com/hous/data/model/request/TempManagerRequest.kt
@@ -1,4 +1,4 @@
-package com.hous.data.model.response
+package com.hous.data.model.request
data class TempManagerRequest(
val tmpRuleMembers: List = emptyList()
diff --git a/data/src/main/java/com/hous/data/repository/NewRulesRepositoryImpl.kt b/data/src/main/java/com/hous/data/repository/NewRulesRepositoryImpl.kt
index 33a8f07b..4dee5dc1 100644
--- a/data/src/main/java/com/hous/data/repository/NewRulesRepositoryImpl.kt
+++ b/data/src/main/java/com/hous/data/repository/NewRulesRepositoryImpl.kt
@@ -4,7 +4,7 @@ import android.util.Log
import com.hous.data.model.request.Member
import com.hous.data.model.request.NewRulesRequest
import com.hous.data.source.remote.RemoteNewRulesDataSource
-import com.hous.domain.model.DayData
+import com.hous.domain.model.DayDataInfo
import com.hous.domain.model.Manager
import com.hous.domain.model.NewRuleInfo
import com.hous.domain.model.State
@@ -43,12 +43,12 @@ class NewRulesRepositoryImpl @Inject constructor(
runCatching {
val response = remoteNewRulesDataSource.getNewRuleList(roomId)
NewRuleInfo(
- response.data!!.ruleCategories.map { it.toCategory() },
- response.data.homies.map { it.toHomie() }
+ response.data!!.ruleCategories.map { it.toCategoryInfo() },
+ response.data.homies.map { it.toHomieInfo() }
)
}
- private fun dayToInt(dayDataList: List): List {
+ private fun dayToInt(dayDataList: List): List {
val tempList = mutableListOf()
for (index in 0 until 7) {
if (dayDataList[index].dayState == State.SELECT) tempList.add(index)
diff --git a/data/src/main/java/com/hous/data/repository/RulesTodayRepository.kt b/data/src/main/java/com/hous/data/repository/RulesTodayRepository.kt
deleted file mode 100644
index 8b9654fc..00000000
--- a/data/src/main/java/com/hous/data/repository/RulesTodayRepository.kt
+++ /dev/null
@@ -1,37 +0,0 @@
-package com.hous.data.repository
-
-import com.hous.data.entity.Rule
-import com.hous.data.model.WrapperClass
-import com.hous.data.model.request.MyToDoCheckRequest
-import com.hous.data.model.response.RulesTableResponse
-import com.hous.data.model.response.RulesTodayInfoListResponse
-import com.hous.data.model.response.TempManagerRequest
-import com.hous.data.model.response.TempManagerResponse
-
-interface RulesTodayRepository {
- suspend fun getTodayTodayInfoList(roomId: String): Result>
-
- suspend fun getTempManagerInfoList(
- roomId: String,
- rulesId: String
- ): Result>
-
- suspend fun putTempManagerInfoList(
- roomId: String,
- ruleId: String,
- tmpRuleMembers: TempManagerRequest
- ): Result>
-
- suspend fun getMyTodoInfoList(roomId: String): Result>>
-
- suspend fun putMyToDoCheckLust(
- roomId: String,
- ruleId: String,
- isCheck: MyToDoCheckRequest
- ): Result>
-
- suspend fun getRuleTableInfoList(
- roomId: String,
- categoryId: String
- ): Result>
-}
diff --git a/data/src/main/java/com/hous/data/repository/RulesTodayRepositoryImpl.kt b/data/src/main/java/com/hous/data/repository/RulesTodayRepositoryImpl.kt
index bbf4f730..111c1b7a 100644
--- a/data/src/main/java/com/hous/data/repository/RulesTodayRepositoryImpl.kt
+++ b/data/src/main/java/com/hous/data/repository/RulesTodayRepositoryImpl.kt
@@ -1,65 +1,52 @@
package com.hous.data.repository
-import com.hous.data.entity.Rule
-import com.hous.data.model.WrapperClass
import com.hous.data.model.request.MyToDoCheckRequest
-import com.hous.data.model.response.RulesTableResponse
-import com.hous.data.model.response.RulesTodayInfoListResponse
-import com.hous.data.model.response.TempManagerRequest
-import com.hous.data.model.response.TempManagerResponse
+import com.hous.data.model.request.TempManagerRequest
import com.hous.data.source.remote.RemoteRulesTodayDataSource
+import com.hous.domain.model.RuleInfo
+import com.hous.domain.model.TempManagerInfo
+import com.hous.domain.model.rules.RulesTableInfo
+import com.hous.domain.model.rules.RulesTodayInfo
import javax.inject.Inject
class RulesTodayRepositoryImpl @Inject constructor(
private val remoteRulesTodayDataSource: RemoteRulesTodayDataSource
) : RulesTodayRepository {
- override suspend fun getTodayTodayInfoList(roomId: String): Result> {
- return runCatching { remoteRulesTodayDataSource.getTodayTodayInfoList(roomId) }
- }
+ override suspend fun getTodayTodayInfoList(roomId: String): RulesTodayInfo? =
+ remoteRulesTodayDataSource.getTodayTodayInfoList(roomId)
override suspend fun getTempManagerInfoList(
roomId: String,
rulesId: String
- ): Result> {
- return runCatching { remoteRulesTodayDataSource.getTempManagerInfoList(roomId, rulesId) }
- }
+ ): TempManagerInfo? = remoteRulesTodayDataSource.getTempManagerInfoList(roomId, rulesId)
override suspend fun putTempManagerInfoList(
roomId: String,
ruleId: String,
- tmpRuleMembers: TempManagerRequest
- ): Result> {
- return runCatching {
- remoteRulesTodayDataSource.putTempManagerInfoList(
- roomId,
- ruleId,
- tmpRuleMembers
- )
- }
+ tmpRuleMembers: List
+ ): Any? {
+ return remoteRulesTodayDataSource.putTempManagerInfoList(
+ roomId,
+ ruleId,
+ TempManagerRequest(tmpRuleMembers)
+ )
}
- override suspend fun getMyTodoInfoList(roomId: String): Result>> {
- return runCatching {
- remoteRulesTodayDataSource.getMyToDoInfoList(roomId)
- }
+ override suspend fun getMyTodoInfoList(roomId: String): List? {
+ return remoteRulesTodayDataSource.getMyToDoInfoList(roomId)
}
override suspend fun putMyToDoCheckLust(
roomId: String,
ruleId: String,
- isCheck: MyToDoCheckRequest
- ): Result> {
- return runCatching {
- remoteRulesTodayDataSource.putMyToDoCheckLust(roomId, ruleId, isCheck)
- }
+ isCheck: Boolean
+ ) {
+ remoteRulesTodayDataSource.putMyToDoCheckLust(roomId, ruleId, MyToDoCheckRequest(isCheck))
}
override suspend fun getRuleTableInfoList(
roomId: String,
categoryId: String
- ): Result> {
- return runCatching {
- remoteRulesTodayDataSource.getRuleTableInfoList(roomId, categoryId)
- }
- }
+ ): RulesTableInfo? =
+ remoteRulesTodayDataSource.getRuleTableInfoList(roomId, categoryId)
}
diff --git a/data/src/main/java/com/hous/data/source/remote/RemoteRulesTodayDataSource.kt b/data/src/main/java/com/hous/data/source/remote/RemoteRulesTodayDataSource.kt
index c2e95549..1f2565a2 100644
--- a/data/src/main/java/com/hous/data/source/remote/RemoteRulesTodayDataSource.kt
+++ b/data/src/main/java/com/hous/data/source/remote/RemoteRulesTodayDataSource.kt
@@ -1,37 +1,36 @@
package com.hous.data.source.remote
-import com.hous.data.entity.Rule
-import com.hous.data.model.WrapperClass
import com.hous.data.model.request.MyToDoCheckRequest
-import com.hous.data.model.response.RulesTableResponse
-import com.hous.data.model.response.RulesTodayInfoListResponse
-import com.hous.data.model.response.TempManagerRequest
-import com.hous.data.model.response.TempManagerResponse
+import com.hous.data.model.request.TempManagerRequest
+import com.hous.domain.model.RuleInfo
+import com.hous.domain.model.TempManagerInfo
+import com.hous.domain.model.rules.RulesTableInfo
+import com.hous.domain.model.rules.RulesTodayInfo
interface RemoteRulesTodayDataSource {
- suspend fun getTodayTodayInfoList(roomId: String): WrapperClass
+ suspend fun getTodayTodayInfoList(roomId: String): RulesTodayInfo?
suspend fun getTempManagerInfoList(
roomId: String,
ruleId: String
- ): WrapperClass
+ ): TempManagerInfo?
suspend fun putTempManagerInfoList(
roomId: String,
ruleId: String,
tmpRuleMembers: TempManagerRequest
- ): WrapperClass
+ ): Any?
- suspend fun getMyToDoInfoList(roomId: String): WrapperClass>
+ suspend fun getMyToDoInfoList(roomId: String): List?
suspend fun putMyToDoCheckLust(
roomId: String,
ruleId: String,
isCheck: MyToDoCheckRequest
- ): WrapperClass
+ )
suspend fun getRuleTableInfoList(
roomId: String,
categoryId: String
- ): WrapperClass
+ ): RulesTableInfo?
}
diff --git a/data/src/main/java/com/hous/data/source/remote/RemoteRulesTodayDataSourceImpl.kt b/data/src/main/java/com/hous/data/source/remote/RemoteRulesTodayDataSourceImpl.kt
index 64db47b4..fcd7570f 100644
--- a/data/src/main/java/com/hous/data/source/remote/RemoteRulesTodayDataSourceImpl.kt
+++ b/data/src/main/java/com/hous/data/source/remote/RemoteRulesTodayDataSourceImpl.kt
@@ -2,13 +2,13 @@ package com.hous.data.source.remote
import com.hous.data.BuildConfig
import com.hous.data.api.RulesApi
-import com.hous.data.entity.Rule
-import com.hous.data.model.WrapperClass
import com.hous.data.model.request.MyToDoCheckRequest
-import com.hous.data.model.response.RulesTableResponse
-import com.hous.data.model.response.RulesTodayInfoListResponse
-import com.hous.data.model.response.TempManagerRequest
-import com.hous.data.model.response.TempManagerResponse
+import com.hous.data.model.request.TempManagerRequest
+import com.hous.domain.model.RuleInfo
+import com.hous.domain.model.TempManagerInfo
+import com.hous.domain.model.rules.RulesTableInfo
+import com.hous.domain.model.rules.RulesTodayInfo
+import timber.log.Timber
import javax.inject.Inject
class RemoteRulesTodayDataSourceImpl @Inject constructor(
@@ -17,41 +17,108 @@ class RemoteRulesTodayDataSourceImpl @Inject constructor(
RemoteRulesTodayDataSource {
private val ROOM_ID = BuildConfig.ROOM_ID
- override suspend fun getTodayTodayInfoList(roomId: String): WrapperClass {
- return rulesApi.getTodayTodayInfoList(ROOM_ID)
- }
+ override suspend fun getTodayTodayInfoList(roomId: String): RulesTodayInfo? =
+ runCatching {
+ rulesApi.getTodayTodayInfoList(ROOM_ID)
+ }.fold(
+ { response ->
+ return RulesTodayInfo(
+ response.data?.homeRuleCategories!!.map { categoryData ->
+ categoryData.toCategoryInfo()
+ },
+ response.data.todayTodoRules.map { ruleData ->
+ ruleData.toRuleInfo()
+ }
+ )
+ },
+ {
+ Timber.e(it.message)
+ return null
+ }
+ )
override suspend fun getTempManagerInfoList(
roomId: String,
ruleId: String
- ): WrapperClass {
- return rulesApi.getTempManagerInfoList(ROOM_ID, ruleId)
- }
+ ): TempManagerInfo? =
+ runCatching {
+ rulesApi.getTempManagerInfoList(ROOM_ID, ruleId)
+ }.fold(
+ { response ->
+ return TempManagerInfo(
+ response.data!!.id,
+ response.data.homies.map { homieData ->
+ homieData.toHomieInfo()
+ }
+ )
+ },
+ {
+ Timber.e(it.message)
+ return null
+ }
+ )
override suspend fun putTempManagerInfoList(
roomId: String,
ruleId: String,
tmpRuleMembers: TempManagerRequest
- ): WrapperClass {
- return rulesApi.putTempManagerInfoList(ROOM_ID, ruleId, tmpRuleMembers)
+ ): Any? {
+ return runCatching {
+ rulesApi.putTempManagerInfoList(
+ ROOM_ID,
+ ruleId,
+ tmpRuleMembers
+ )
+ }.fold(
+ {}, {
+ Timber.e(it.message)
+ null
+ }
+ )
}
- override suspend fun getMyToDoInfoList(roomId: String): WrapperClass> {
- return rulesApi.getMyTodoInfoList(ROOM_ID)
+ override suspend fun getMyToDoInfoList(roomId: String): List? {
+ return runCatching { rulesApi.getMyTodoInfoList(ROOM_ID) }.fold(
+ { response ->
+ response.data?.map { ruleData ->
+ ruleData.toRuleInfo()
+ }
+ },
+ {
+ Timber.e(it.message)
+ null
+ }
+ )
}
override suspend fun putMyToDoCheckLust(
roomId: String,
ruleId: String,
isCheck: MyToDoCheckRequest
- ): WrapperClass {
- return rulesApi.putMyToDoCheckList(ROOM_ID, ruleId, isCheck)
+ ) {
+ runCatching { rulesApi.putMyToDoCheckList(ROOM_ID, ruleId, isCheck) }.onFailure {
+ Timber.e(it.message)
+ }
}
override suspend fun getRuleTableInfoList(
roomId: String,
categoryId: String
- ): WrapperClass {
- return rulesApi.getRuleTableInfoList(ROOM_ID, categoryId)
- }
+ ): RulesTableInfo? =
+ runCatching { rulesApi.getRuleTableInfoList(ROOM_ID, categoryId) }.fold(
+ { response ->
+ return RulesTableInfo(
+ response.data?.keyRules!!.map { ruleData ->
+ ruleData.toRuleInfo()
+ },
+ response.data.rules.map { ruleData ->
+ ruleData.toRuleInfo()
+ }
+ )
+ },
+ {
+ Timber.e(it.message)
+ null
+ }
+ )
}
diff --git a/domain/src/main/java/com/hous/domain/model/Category.kt b/domain/src/main/java/com/hous/domain/model/CategoryInfo.kt
similarity index 88%
rename from domain/src/main/java/com/hous/domain/model/Category.kt
rename to domain/src/main/java/com/hous/domain/model/CategoryInfo.kt
index f50a1bbe..a314c757 100644
--- a/domain/src/main/java/com/hous/domain/model/Category.kt
+++ b/domain/src/main/java/com/hous/domain/model/CategoryInfo.kt
@@ -1,6 +1,6 @@
package com.hous.domain.model
-data class Category(
+data class CategoryInfo(
val id: String = "",
val categoryName: String = "",
val categoryIcon: String = "",
diff --git a/domain/src/main/java/com/hous/domain/model/DayData.kt b/domain/src/main/java/com/hous/domain/model/DayDataInfo.kt
similarity index 76%
rename from domain/src/main/java/com/hous/domain/model/DayData.kt
rename to domain/src/main/java/com/hous/domain/model/DayDataInfo.kt
index b1a6f9c8..75e796bb 100644
--- a/domain/src/main/java/com/hous/domain/model/DayData.kt
+++ b/domain/src/main/java/com/hous/domain/model/DayDataInfo.kt
@@ -1,6 +1,6 @@
package com.hous.domain.model
-data class DayData(
+data class DayDataInfo(
val day: String,
val dayState: State
)
diff --git a/domain/src/main/java/com/hous/domain/model/Homie.kt b/domain/src/main/java/com/hous/domain/model/HomieInfo.kt
similarity index 94%
rename from domain/src/main/java/com/hous/domain/model/Homie.kt
rename to domain/src/main/java/com/hous/domain/model/HomieInfo.kt
index 073804d5..b6025642 100644
--- a/domain/src/main/java/com/hous/domain/model/Homie.kt
+++ b/domain/src/main/java/com/hous/domain/model/HomieInfo.kt
@@ -1,6 +1,6 @@
package com.hous.domain.model
-data class Homie(
+data class HomieInfo(
val id: String? = null,
val userName: String = "",
val typeName: String = "",
diff --git a/domain/src/main/java/com/hous/domain/model/Manager.kt b/domain/src/main/java/com/hous/domain/model/Manager.kt
index d4d30ba8..fd30fe62 100644
--- a/domain/src/main/java/com/hous/domain/model/Manager.kt
+++ b/domain/src/main/java/com/hous/domain/model/Manager.kt
@@ -1,17 +1,17 @@
package com.hous.domain.model
data class Manager(
- val managerHomie: Homie = Homie(
+ val managerHomie: HomieInfo = HomieInfo(
userName = "담당자 없음",
typeColor = "NULL"
),
- val dayDataList: List = listOf(
- DayData("월", State.UNSELECT),
- DayData("화", State.UNSELECT),
- DayData("수", State.UNSELECT),
- DayData("목", State.UNSELECT),
- DayData("금", State.UNSELECT),
- DayData("토", State.UNSELECT),
- DayData("일", State.UNSELECT)
+ val dayDataList: List = listOf(
+ DayDataInfo("월", State.UNSELECT),
+ DayDataInfo("화", State.UNSELECT),
+ DayDataInfo("수", State.UNSELECT),
+ DayDataInfo("목", State.UNSELECT),
+ DayDataInfo("금", State.UNSELECT),
+ DayDataInfo("토", State.UNSELECT),
+ DayDataInfo("일", State.UNSELECT)
)
)
diff --git a/domain/src/main/java/com/hous/domain/model/NewRuleInfo.kt b/domain/src/main/java/com/hous/domain/model/NewRuleInfo.kt
index 7d05ae08..e18a7798 100644
--- a/domain/src/main/java/com/hous/domain/model/NewRuleInfo.kt
+++ b/domain/src/main/java/com/hous/domain/model/NewRuleInfo.kt
@@ -1,6 +1,6 @@
package com.hous.domain.model
data class NewRuleInfo(
- val ruleCategories: List = emptyList(),
- val homies: List = emptyList()
+ val ruleCategories: List = emptyList(),
+ val homies: List = emptyList()
)
diff --git a/domain/src/main/java/com/hous/domain/model/RuleInfo.kt b/domain/src/main/java/com/hous/domain/model/RuleInfo.kt
new file mode 100644
index 00000000..ed40ee83
--- /dev/null
+++ b/domain/src/main/java/com/hous/domain/model/RuleInfo.kt
@@ -0,0 +1,13 @@
+package com.hous.domain.model
+
+data class RuleInfo(
+ val id: String = "",
+ var isChecked: Boolean = false,
+ val ruleName: String = "",
+ val todayMembersWithTypeColor: List = emptyList(),
+ val isTmpMember: Boolean = false,
+ val isAllChecked: Boolean = false,
+ val membersCnt: Int = 0,
+ val typeColors: List = emptyList(),
+ val categoryIcon: String = ""
+)
diff --git a/domain/src/main/java/com/hous/domain/model/TempManagerInfo.kt b/domain/src/main/java/com/hous/domain/model/TempManagerInfo.kt
new file mode 100644
index 00000000..a23a2d9b
--- /dev/null
+++ b/domain/src/main/java/com/hous/domain/model/TempManagerInfo.kt
@@ -0,0 +1,6 @@
+package com.hous.domain.model
+
+data class TempManagerInfo(
+ val id: String = "",
+ val homies: List = emptyList()
+)
diff --git a/domain/src/main/java/com/hous/domain/model/rules/RulesTableInfo.kt b/domain/src/main/java/com/hous/domain/model/rules/RulesTableInfo.kt
new file mode 100644
index 00000000..5e73cc02
--- /dev/null
+++ b/domain/src/main/java/com/hous/domain/model/rules/RulesTableInfo.kt
@@ -0,0 +1,8 @@
+package com.hous.domain.model.rules
+
+import com.hous.domain.model.RuleInfo
+
+data class RulesTableInfo(
+ val keyRules: List,
+ val rules: List
+)
diff --git a/domain/src/main/java/com/hous/domain/model/rules/RulesTodayInfo.kt b/domain/src/main/java/com/hous/domain/model/rules/RulesTodayInfo.kt
new file mode 100644
index 00000000..c2adf22e
--- /dev/null
+++ b/domain/src/main/java/com/hous/domain/model/rules/RulesTodayInfo.kt
@@ -0,0 +1,9 @@
+package com.hous.domain.model.rules
+
+import com.hous.domain.model.CategoryInfo
+import com.hous.domain.model.RuleInfo
+
+data class RulesTodayInfo(
+ val homeRuleCategories: List = emptyList(),
+ val todayTodoRules: List = emptyList()
+)
diff --git a/domain/src/main/java/com/hous/domain/repository/RulesTodayRepository.kt b/domain/src/main/java/com/hous/domain/repository/RulesTodayRepository.kt
new file mode 100644
index 00000000..58abfcd2
--- /dev/null
+++ b/domain/src/main/java/com/hous/domain/repository/RulesTodayRepository.kt
@@ -0,0 +1,34 @@
+package com.hous.data.repository
+
+import com.hous.domain.model.RuleInfo
+import com.hous.domain.model.TempManagerInfo
+import com.hous.domain.model.rules.RulesTableInfo
+import com.hous.domain.model.rules.RulesTodayInfo
+
+interface RulesTodayRepository {
+ suspend fun getTodayTodayInfoList(roomId: String): RulesTodayInfo?
+
+ suspend fun getTempManagerInfoList(
+ roomId: String,
+ rulesId: String
+ ): TempManagerInfo?
+
+ suspend fun putTempManagerInfoList(
+ roomId: String,
+ ruleId: String,
+ tmpRuleMembers: List
+ ): Any?
+
+ suspend fun getMyTodoInfoList(roomId: String): List?
+
+ suspend fun putMyToDoCheckLust(
+ roomId: String,
+ ruleId: String,
+ isCheck: Boolean
+ )
+
+ suspend fun getRuleTableInfoList(
+ roomId: String,
+ categoryId: String
+ ): RulesTableInfo?
+}
diff --git a/gradlew b/gradlew
old mode 100644
new mode 100755