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
This commit is contained in:
parent
ca4c6efdb7
commit
64603cba8d
@ -38,7 +38,7 @@ import com.google.common.util.concurrent.ListenableFuture
|
||||
class MainActivity : AppCompatActivity() {
|
||||
private lateinit var browserFuture: ListenableFuture<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 mediaListView: ListView
|
||||
|
Loading…
x
Reference in New Issue
Block a user