Skip to content

Instantly share code, notes, and snippets.

@brainail
Last active September 17, 2017 11:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brainail/23e55fe38e83c5dcdc68200033007dc5 to your computer and use it in GitHub Desktop.
Save brainail/23e55fe38e83c5dcdc68200033007dc5 to your computer and use it in GitHub Desktop.
The main activity where we display our list
class KitsuMainActivity : AppCompatActivity() {
private val viewModel by lazy { ViewModelProviders.of(this).get(KitsuViewModel::class.java) }
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
initFlysearch(savedInstanceState)
searchForResults("Android")
}
private fun initKitsu() {
val kitsuAdapter = KitsuPagedListAdapter()
searchResultsRecyclerView.adapter = kitsuAdapter
viewModel.allKitsu.observe(this, Observer(kitsuAdapter::setList))
}
private fun searchForResults(queryFilter: String) {
viewModel.setQueryFilter(queryFilter)
initKitsu()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment