title: How to wait the end of a firebase call in Kotlin (Android)
body: <p>In an android application, i'm trying to do a firebase call that fills an ArrayAdapter in order to show a list of ships.
  When i'm using a local ArrayList, it works, but my firebase call doesn't work properly.
  Because that firebase call is asynchronous, android shows me the application before ending the firebase call, so my ArrayAdapter is empty and my layout is empty too.
  I tryed to use a Coroutine method i've seen online but i doesn't seem to work.
  Can someone help me ?
  Here is my source code :</p>
  
  <p>MainActivity :</p>
  
  <pre><code>    override fun onCreate(savedInstanceState: Bundle?){
          super.onCreate(savedInstanceState)
          setContentView(R.layout.activity_main)
          var containerShips : List&lt;Containership&gt; = listOf()
          val db = Database()
  
          runBlocking {
              containerShips = db.getAllContainerships()
          }
  
  
  
  
          val arrayAdapter = ArrayAdapter(this, android.R.layout.simple_list_item_1, containerShips)
  
          val listShipDetails = findViewById&lt;ListView&gt;(R.id.listShipDetails)
  
          listShipDetails.adapter = arrayAdapter
  
      }
  </code></pre>
  
  <p>Database:</p>
  
  <pre><code>   suspend fun getAllContainerships() : List&lt;Containership&gt; {
          val list : MutableList&lt;Containership&gt; = mutableListOf()
          val job = GlobalScope.launch {
              db.collection("Containership").get().addOnSuccessListener { result -&gt;
                  for (containership in result) {
                      list.add(containership.toObject(Containership::class.java))
                      println(containership.toObject(Containership::class.java))
                  }
              }
          }
          job.join()
          return list
      }
  
  </code></pre>
  
  <p>Thanks for your help !</p>