From 2891214eac245b3dc1a0f1d608f4bedcef35862c Mon Sep 17 00:00:00 2001 From: Ryan Harg Date: Sun, 12 Sep 2021 09:16:11 +0200 Subject: [PATCH] #28: Create adapter after repo initialization --- .../ffa/activities/SearchActivity.kt | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/audio/funkwhale/ffa/activities/SearchActivity.kt b/app/src/main/java/audio/funkwhale/ffa/activities/SearchActivity.kt index 7f1a9e8..e0fc040 100644 --- a/app/src/main/java/audio/funkwhale/ffa/activities/SearchActivity.kt +++ b/app/src/main/java/audio/funkwhale/ffa/activities/SearchActivity.kt @@ -52,17 +52,6 @@ class SearchActivity : AppCompatActivity() { setContentView(binding.root) - adapter = - SearchAdapter( - layoutInflater, - this, - SearchResultClickListener(), - FavoriteListener(favoritesRepository) - ).also { - binding.results.layoutManager = LinearLayoutManager(this) - binding.results.adapter = it - } - binding.search.requestFocus() } @@ -97,6 +86,17 @@ class SearchActivity : AppCompatActivity() { tracksRepository = TracksSearchRepository(this@SearchActivity, "") favoritesRepository = FavoritesRepository(this@SearchActivity) + adapter = + SearchAdapter( + layoutInflater, + this, + SearchResultClickListener(), + FavoriteListener(favoritesRepository) + ).also { + binding.results.layoutManager = LinearLayoutManager(this) + binding.results.adapter = it + } + binding.search.setOnQueryTextListener(object : SearchView.OnQueryTextListener { override fun onQueryTextSubmit(rawQuery: String?): Boolean {