title: Kotlin Coroutines the right way in Android
body: <p>I'm trying to update a list inside the adapter using async, I can see there is too much boilerplate. </p>
  
  <p>Is it the right way to use Kotlin Coroutines?</p>
  
  <p>can this be optimized more?</p>
  
  <pre><code>fun loadListOfMediaInAsync() = async(CommonPool) {
          try {
              //Long running task 
              adapter.listOfMediaItems.addAll(resources.getAllTracks())
              runOnUiThread {
                  adapter.notifyDataSetChanged()
                  progress.dismiss()
              }
          } catch (e: Exception) {
              e.printStackTrace()
              runOnUiThread {progress.dismiss()}
          } catch (o: OutOfMemoryError) {
              o.printStackTrace()
              runOnUiThread {progress.dismiss()}
          }
      }
  </code></pre>