Skip to content

Commit

Permalink
[AN] feat: 채팅 전체 리스트 refresh 기능 구현 (#346)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaeun5744 authored Aug 9, 2024
1 parent 3b70910 commit e956d28
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ class ChatListFragment :
viewModel.chats.observe(viewLifecycleOwner) { chats ->
adapter.submitList(chats)
}
swipeEvent()
}

private fun swipeEvent() {
binding.swipelayoutChatListRefresh.setOnRefreshListener {
viewModel.getChats()
binding.swipelayoutChatListRefresh.isRefreshing = false
}
}

override fun navigateToChat(chatId: Long) {
Expand Down
51 changes: 29 additions & 22 deletions android/app/src/main/res/layout/fragment_chat_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,41 @@
<data>

</data>

<androidx.coordinatorlayout.widget.CoordinatorLayout
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/swipelayout_chat_list_refresh"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">

<com.google.android.material.appbar.AppBarLayout
android:layout_height="match_parent">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/rect_gray03_botline_bot1">
android:layout_height="match_parent"
android:background="@color/white">

<com.google.android.material.appbar.MaterialToolbar
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:title="@string/chat_list_title"
app:titleMarginStart="20dp"
app:titleTextAppearance="@style/Theme.AppCompat.TextView.SemiBold.Black.Size18">
android:background="@drawable/rect_gray03_botline_bot1">

</com.google.android.material.appbar.MaterialToolbar>
</com.google.android.material.appbar.AppBarLayout>
<com.google.android.material.appbar.MaterialToolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:title="@string/chat_list_title"
app:titleMarginStart="20dp"
app:titleTextAppearance="@style/Theme.AppCompat.TextView.SemiBold.Black.Size18">

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rcv_chat_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
tools:listitem="@layout/item_chat_list" />
</com.google.android.material.appbar.MaterialToolbar>
</com.google.android.material.appbar.AppBarLayout>

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rcv_chat_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
tools:listitem="@layout/item_chat_list" />

</androidx.coordinatorlayout.widget.CoordinatorLayout>


</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

</androidx.coordinatorlayout.widget.CoordinatorLayout>
</layout>

0 comments on commit e956d28

Please sign in to comment.