Skip to content

Commit a2c1b97

Browse files
committed
feat : Recyclerview 바인딩 어댑터 제네릭으로 변경
1 parent dc4ab8a commit a2c1b97

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed
Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
package com.stop.bindingadapter
22

33
import androidx.databinding.BindingAdapter
4+
import androidx.recyclerview.widget.ListAdapter
45
import androidx.recyclerview.widget.RecyclerView
5-
import com.stop.domain.model.nearplace.Place
6-
import com.stop.ui.placesearch.NearPlaceAdapter
76

8-
@BindingAdapter("places")
9-
fun RecyclerView.setPlaces(places: List<Place>?) {
10-
this.adapter?.run {
11-
if(this is NearPlaceAdapter){
12-
this.submitList(places)
13-
}
7+
@BindingAdapter("items")
8+
fun <T> RecyclerView.submitItems(items: List<T>?) {
9+
if (this.adapter is ListAdapter<*, *>) {
10+
(this.adapter as ListAdapter<T, *>).submitList(items)
1411
}
1512
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
app:layout_constraintEnd_toEndOf="@id/guide_line_end"
103103
app:layout_constraintStart_toStartOf="@id/guide_line_start"
104104
app:layout_constraintTop_toBottomOf="@id/text_view_current_location"
105-
app:places="@{viewModel.nearPlaceList}" />
105+
app:items="@{viewModel.nearPlaceList}" />
106106

107107

108108
</androidx.constraintlayout.widget.ConstraintLayout>

0 commit comments

Comments
 (0)