Skip to content
This repository was archived by the owner on Feb 17, 2020. It is now read-only.

Commit a8751c5

Browse files
committed
Cleanup SearchRecyclerView code
1 parent 33f98f4 commit a8751c5

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

app/src/main/java/net/squanchy/search/view/SearchRecyclerView.kt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import net.squanchy.schedule.domain.view.Event
1212
import net.squanchy.search.SearchResult
1313
import net.squanchy.speaker.domain.view.Speaker
1414
import net.squanchy.support.unwrapToActivityContext
15+
import net.squanchy.support.view.setAdapterIfNone
1516
import net.squanchy.support.widget.CardLayout
1617

1718
class SearchRecyclerView @JvmOverloads constructor(
@@ -33,20 +34,16 @@ class SearchRecyclerView @JvmOverloads constructor(
3334
addItemDecoration(CardOnlySpacingItemDecorator(horizontalSpacing, verticalSpacing))
3435

3536
adapter = SearchAdapter(context.unwrapToActivityContext())
36-
setAdapter(adapter)
3737
clipToPadding = false
3838
}
3939

4040
fun updateWith(searchResult: SearchResult.Success, listener: OnSearchResultClickListener) {
41-
if (getAdapter() == null) {
42-
super.setAdapter(adapter)
43-
}
41+
setAdapterIfNone(adapter)
4442

4543
adapter.updateWith(searchResult, listener)
4644

47-
val layoutManager = layoutManager as GridLayoutManager
4845
val spanSizeLookup = adapter.createSpanSizeLookup(COLUMNS_COUNT)
49-
layoutManager.spanSizeLookup = spanSizeLookup
46+
(layoutManager as GridLayoutManager).spanSizeLookup = spanSizeLookup
5047
}
5148

5249
interface OnSearchResultClickListener {

0 commit comments

Comments
 (0)