Skip to content

Commit 9e423f2

Browse files
committed
🐛 그룹 상세페이지에서 홈으로 가면 앱이 crash되는 버그 수정
1 parent a55aa5b commit 9e423f2

File tree

8 files changed

+75
-7
lines changed

8 files changed

+75
-7
lines changed
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
package com.whyranoid.domain.model
22

3-
import java.io.Serializable
4-
53
data class GroupInfo(
64
val name: String,
75
val groupId: String,
86
val introduce: String,
97
val rules: List<Rule>,
108
val headCount: Int,
119
val leader: User
12-
) : Serializable
10+
)

presentation/src/main/java/com/whyranoid/presentation/community/CommunityFragment.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ internal class CommunityFragment :
6868
}
6969

7070
override fun onDestroyView() {
71-
7271
// 뷰페이저 메모리 누수 해결
7372
binding.viewPager.adapter = null
7473

presentation/src/main/java/com/whyranoid/presentation/community/CommunityItemFragment.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import androidx.navigation.fragment.findNavController
1010
import com.whyranoid.presentation.R
1111
import com.whyranoid.presentation.base.BaseFragment
1212
import com.whyranoid.presentation.databinding.FragmentCommunityItemBinding
13+
import com.whyranoid.presentation.model.toGroupInfoUiModel
1314
import com.whyranoid.presentation.util.repeatWhenUiStarted
1415
import dagger.hilt.android.AndroidEntryPoint
1516
import kotlinx.coroutines.launch
@@ -63,7 +64,7 @@ internal class CommunityItemFragment :
6364
when (event) {
6465
is Event.CategoryItemClick -> {
6566
val action =
66-
CommunityFragmentDirections.actionCommunityFragmentToGroupDetailFragment(event.groupInfo)
67+
CommunityFragmentDirections.actionCommunityFragmentToGroupDetailFragment(event.groupInfo.toGroupInfoUiModel())
6768
findNavController().navigate(action)
6869
}
6970
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.whyranoid.presentation.model
2+
3+
import android.os.Parcelable
4+
import com.whyranoid.domain.model.GroupInfo
5+
import kotlinx.parcelize.Parcelize
6+
7+
@Parcelize
8+
data class GroupInfoUiModel(
9+
val name: String,
10+
val groupId: String,
11+
val introduce: String,
12+
val rules: List<RuleUiModel>,
13+
val headCount: Int,
14+
val leader: UserUiModel
15+
) : Parcelable
16+
17+
fun GroupInfo.toGroupInfoUiModel() =
18+
GroupInfoUiModel(
19+
name = this.name,
20+
groupId = this.groupId,
21+
introduce = this.introduce,
22+
rules = this.rules.map { rule ->
23+
rule.toRuleUiModel()
24+
},
25+
headCount = this.headCount,
26+
leader = this.leader.toUserUiModel()
27+
)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.whyranoid.presentation.model
2+
3+
import android.os.Parcelable
4+
import com.whyranoid.domain.model.DayOfWeek
5+
import com.whyranoid.domain.model.Rule
6+
import kotlinx.parcelize.Parcelize
7+
8+
@Parcelize
9+
data class RuleUiModel(
10+
val dayOfWeek: DayOfWeek,
11+
val hour: Int,
12+
val minute: Int
13+
) : Parcelable {
14+
override fun toString(): String {
15+
return "${dayOfWeek.dayResId}-$hour-$minute"
16+
}
17+
}
18+
19+
fun Rule.toRuleUiModel() =
20+
RuleUiModel(
21+
dayOfWeek = this.dayOfWeek,
22+
hour = this.hour,
23+
minute = this.minute
24+
)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.whyranoid.presentation.model
2+
3+
import android.os.Parcelable
4+
import com.whyranoid.domain.model.User
5+
import kotlinx.parcelize.Parcelize
6+
7+
@Parcelize
8+
data class UserUiModel(
9+
val uid: String,
10+
val name: String?,
11+
val profileUrl: String?
12+
) : Parcelable
13+
14+
fun User.toUserUiModel() =
15+
UserUiModel(
16+
uid = this.uid,
17+
name = this.name,
18+
profileUrl = this.profileUrl
19+
)

presentation/src/main/res/layout/fragment_group_detail.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
<variable
1515
name="groupInfo"
16-
type="com.whyranoid.domain.model.GroupInfo" />
16+
type="com.whyranoid.presentation.model.GroupInfoUiModel" />
1717

1818
<variable
1919
name="viewModel"

presentation/src/main/res/navigation/navigation_graph.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
tools:layout="@layout/fragment_group_detail">
5353
<argument
5454
android:name="groupInfo"
55-
app:argType="com.whyranoid.domain.model.GroupInfo" />
55+
app:argType="com.whyranoid.presentation.model.GroupInfoUiModel" />
5656
</fragment>
5757

5858
</navigation>

0 commit comments

Comments
 (0)