override fun onCreate()

in AppSearchSample/app/src/main/java/com/android/example/appsearchsample/MainActivity.kt [56:85]


  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)

    activityBinding = ActivityMainBinding.inflate(layoutInflater)
    setContentView(activityBinding.root)

    initAddNoteButtonListener()
    initNoteListView()

    noteViewModel.queryNotes().observe(
      this,
      {
        notesAdapter.submitList(it)
        activityBinding.progressSpinner.visibility = View.GONE
        if (it.isEmpty()) {
          activityBinding.notesList.visibility = View.GONE
          activityBinding.noNotesMessage.visibility = View.VISIBLE
        } else {
          activityBinding.notesList.visibility = View.VISIBLE
          activityBinding.noNotesMessage.visibility = View.GONE
        }
      }
    )

    noteViewModel.errorMessageLiveData.observe(this, {
      it?.let {
        Toast.makeText(applicationContext, it, LENGTH_LONG).show()
      }
    })
  }