Fix ANR when leaving MediaPreviewActivity.

This commit is contained in:
Cody Henthorne
2021-06-16 13:30:46 -04:00
parent e5c9dddb5a
commit 8be659c1c8
2 changed files with 13 additions and 6 deletions

View File

@@ -8,6 +8,8 @@ import androidx.lifecycle.DefaultLifecycleObserver;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleOwner;
import org.signal.core.util.concurrent.SignalExecutors;
/**
* Wraps a {@link Cursor} that will be closed automatically when the {@link Lifecycle.Event}.ON_DESTROY
* is fired from the lifecycle this object is observing.
@@ -22,4 +24,9 @@ public class LifecycleCursorWrapper extends CursorWrapper implements DefaultLife
public void onDestroy(@NonNull LifecycleOwner owner) {
close();
}
@Override
public void close() {
SignalExecutors.BOUNDED.execute(super::close);
}
}