Skip to content

Commit

Permalink
[FEAT] 읽음여부 표시
Browse files Browse the repository at this point in the history
  • Loading branch information
kim0hoon committed Sep 15, 2023
1 parent b4e9bc9 commit e22de39
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ class NotificationViewModel @AssistedInject constructor(
_notificationLiveData.value =
ModelState.Loading(prevData.copy(isRefreshable = true))
notificationMutex.unlock()
notificationHorizontalScrollPositionMap.clear()
requestNotifications(accessToken = accessToken)
},
)
Expand Down Expand Up @@ -352,8 +353,8 @@ private fun getMockNotifications(nextId: Int?, pageSize: Int = 10) = ApiResult.s
private val mockNotifications = List(187) {
NotificationDto(
id = it,
type = "FAMILY_REQUEST",
status = "UNREAD",
type = "FAMILY_REQUEST_COMPLETE",
status = if (it % 2 == 0) "READ" else "UNREAD",
title = "title$it",
message = "message$it",
sender = NotificationDto.Sender(id = it, nickName = "nickName$it", null),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,9 @@ abstract class BaseNotificationListFragment : BaseFragment<FragmentNotificationL

private fun initNotificationObserver() {
notificationViewModel.notificationLiveData.observe(viewLifecycleOwner) {
val layoutManager =
(binding.rvNotifications.layoutManager as? LinearLayoutManager) ?: return@observe
val adapter =
(binding.rvNotifications.adapter as? BindableItemAdapter) ?: return@observe
val items = mutableListOf<BindableItem<*>>()
var updateCallback: (() -> Unit)? = null
binding.srlNotifications.isEnabled = it.data?.isRefreshable ?: false
when (it) {
is ModelState.Loading -> {
Expand All @@ -128,19 +125,14 @@ abstract class BaseNotificationListFragment : BaseFragment<FragmentNotificationL
is ModelState.Success -> {
items.addAll(createNotificationItems(data = it.data.items))
binding.srlNotifications.isRefreshing = false
if (notificationViewModel.isRefreshed) {
updateCallback = {
layoutManager.scrollToPositionWithOffset(1, 0)
}
}
}

is ModelState.Error -> {
//TODO 에러처리
}
}

adapter.updateItem(item = items, commitCallback = updateCallback)
adapter.updateItem(item = items)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class NotificationItem(
ivBtnRemoveNotification.setOnClickListener {
clickListener.onClickDeleteNotification(id = model.id)
}

ivIconUnRead.isVisible = model.statusType == NotificationStatusType.UNREAD
bindBtnLayout(binding = binding)
bindProfile(binding = binding)
bindHorizontalScroll(binding = binding)
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/layout/item_notification.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@
app:layout_constraintTop_toTopOf="@id/tvTitle"
tools:text="방금 전" />

<ImageView
android:id="@+id/ivIconUnRead"
android:layout_width="6dp"
android:layout_height="6dp"
android:background="@drawable/shape_oval_error_500"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/tvContent"
android:layout_width="0dp"
Expand Down

0 comments on commit e22de39

Please sign in to comment.