This repository was archived by the owner on Feb 17, 2020. It is now read-only.
File tree Expand file tree Collapse file tree
app/src/main/java/net/squanchy/search/view Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import net.squanchy.schedule.domain.view.Event
1212import net.squanchy.search.SearchResult
1313import net.squanchy.speaker.domain.view.Speaker
1414import net.squanchy.support.unwrapToActivityContext
15+ import net.squanchy.support.view.setAdapterIfNone
1516import net.squanchy.support.widget.CardLayout
1617
1718class 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 {
You can’t perform that action at this time.
0 commit comments