mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-28 03:46:00 +01:00
Unified executor model
This commit is contained in:
@@ -14,7 +14,6 @@ import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.lifecycle.OnLifecycleEvent;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -22,8 +21,6 @@ public class MediaPlayerHelper {
|
||||
static final int DEFAULT_SOUND_DURATION = 30; // seconds
|
||||
static final int DEFAULT_ALARM_DURATION = 30; // seconds
|
||||
|
||||
private static final ExecutorService executor = Helper.getBackgroundExecutor(1, "media");
|
||||
|
||||
static void queue(Context context, String uri) {
|
||||
try {
|
||||
queue(context, Uri.parse(uri), false, DEFAULT_SOUND_DURATION);
|
||||
@@ -35,7 +32,7 @@ public class MediaPlayerHelper {
|
||||
static void queue(Context context, Uri uri, boolean alarm, int duration) {
|
||||
Log.i("Queuing sound=" + uri);
|
||||
|
||||
executor.submit(new Runnable() {
|
||||
Helper.getSerialExecutor().submit(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
@@ -114,7 +111,7 @@ public class MediaPlayerHelper {
|
||||
try {
|
||||
if (owner.getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) {
|
||||
if (!registered) {
|
||||
am.addOnModeChangedListener(executor, listener);
|
||||
am.addOnModeChangedListener(Helper.getParallelExecutor(), listener);
|
||||
registered = true;
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user