Commit 64603cba by michaelkatz Committed by Ian Baker

Added cancellation check for MediaBrowserFuture in demo session app

When app is deployed with device's screen being off, MainActivity's onStart is called swiftly by its onStop. The onStop method cancels the browserFuture task which in turn "completes" the task. Upon task "completion", pushRoot() runs and then throws error as it calls get() a cancelled task.

PiperOrigin-RevId: 492416445
parent ca4c6efd
...@@ -38,7 +38,7 @@ import com.google.common.util.concurrent.ListenableFuture ...@@ -38,7 +38,7 @@ import com.google.common.util.concurrent.ListenableFuture
class MainActivity : AppCompatActivity() { class MainActivity : AppCompatActivity() {
private lateinit var browserFuture: ListenableFuture<MediaBrowser> private lateinit var browserFuture: ListenableFuture<MediaBrowser>
private val browser: MediaBrowser? private val browser: MediaBrowser?
get() = if (browserFuture.isDone) browserFuture.get() else null get() = if (browserFuture.isDone && !browserFuture.isCancelled) browserFuture.get() else null
private lateinit var mediaListAdapter: FolderMediaItemArrayAdapter private lateinit var mediaListAdapter: FolderMediaItemArrayAdapter
private lateinit var mediaListView: ListView private lateinit var mediaListView: ListView
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment