Skip to content

Commit

Permalink
알림 공지사항 데이터 DTO nullSafe 처리 (#56)
Browse files Browse the repository at this point in the history
* 🔨 DTO 수정 반영

* 🔨 알림 공지 데이터 pubDate, url nullSafe 처리
  • Loading branch information
GyeongminKimGyeongminKim authored Oct 14, 2024
1 parent 52768b4 commit e85fea9
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,20 @@ import com.google.gson.annotations.SerializedName
data class AlarmDTO(
@SerializedName("id")
val id: Int,
@SerializedName("categoryId")
val categoryId: Int,
@SerializedName("marked")
val marked: Boolean,
@SerializedName("noticeTypeEnglish")
val noticeTypeEnglish: String,
@SerializedName("noticeTypeKorean")
val noticeTypeKorean: String,
@SerializedName("pubDate")
val pubDate: String,
val pubDate: String?,
@SerializedName("title")
val title: String,
@SerializedName("url")
val url: String,
val url: String?,
@SerializedName("viewed")
val viewed: Boolean
)
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ class AlarmRepositoryImpl @Inject constructor(
data?.map {
Alarm(
id = it.id,
categoryId = it.categoryId,
title = it.title,
noticeTypeKorean = it.noticeTypeKorean,
noticeTypeEnglish = it.noticeTypeEnglish,
viewed = it.viewed,
pubDate = it.pubDate,
url = it.url,
pubDate = it.pubDate?:"",
url = it.url?:"https://www.mju.ac.kr/mjukr/index.do",
marked = it.marked
)
} ?: emptyList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.neverland.domain.model.alarm

data class Alarm (
val id: Int,
val categoryId: Int,
val marked: Boolean,
val noticeTypeEnglish: String,
val noticeTypeKorean: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ class AlarmNoticeFragment : BaseFragment<FragmentAlarmNoticeBinding>() {
}?: NoticeType.NORMAL_NOTICE
LoggerUtil.d(item.first.noticeTypeEnglish)
if (item.second) {
alarmNoticeViewModel.postBookmark(noticeType, item.first.id)
alarmNoticeViewModel.postBookmark(noticeType, item.first.categoryId)
} else {
alarmNoticeViewModel.deleteBookmark(noticeType, item.first.id)
alarmNoticeViewModel.deleteBookmark(noticeType, item.first.categoryId)
}
}
})
Expand Down Expand Up @@ -91,7 +91,7 @@ class AlarmNoticeFragment : BaseFragment<FragmentAlarmNoticeBinding>() {
}
is UiState.Error -> {
// Handle error state
LoggerUtil.d(state.exception.message.toString())
LoggerUtil.e("$keyword ${state.exception.message}")
}
UiState.Empty -> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class AlarmNoticeAdapter : ListAdapter<Alarm, AlarmNoticeAdapter.NoticeViewHolde

class DiffCallback : DiffUtil.ItemCallback<Alarm>() {
override fun areItemsTheSame(oldItem: Alarm, newItem: Alarm): Boolean {
return oldItem.url == newItem.url
return oldItem.id == newItem.id
}

override fun areContentsTheSame(oldItem: Alarm, newItem: Alarm): Boolean {
Expand Down

0 comments on commit e85fea9

Please sign in to comment.