Skip to content

Commit

Permalink
fix: Add awaitClose() to placeSelectionEvents()
Browse files Browse the repository at this point in the history
Change-Id: I3c53e5e6354c66c31ccd7670891646adda6d3a66
  • Loading branch information
arriolac committed Jul 14, 2020
1 parent 155ca30 commit 0f56d22
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class PlacesSearchDemoActivity : AppCompatActivity() {
val linearLayoutManager = LinearLayoutManager(this)
findViewById<RecyclerView>(R.id.recycler_view).apply {
layoutManager = linearLayoutManager
adapter = adapter
adapter = this@PlacesSearchDemoActivity.adapter
addItemDecoration(
DividerItemDecoration(
this@PlacesSearchDemoActivity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.google.android.libraries.places.api.model.Place
import com.google.android.libraries.places.widget.AutocompleteSupportFragment
import com.google.android.libraries.places.widget.listener.PlaceSelectionListener
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.callbackFlow

Expand All @@ -26,4 +27,5 @@ fun AutocompleteSupportFragment.placeSelectionEvents() : Flow<PlaceSelectionResu
offer(PlaceSelectionError(status))
}
})
awaitClose { this@placeSelectionEvents.setOnPlaceSelectedListener(null) }
}

0 comments on commit 0f56d22

Please sign in to comment.