mirror of
https://github.com/antebudimir/tempus.git
synced 2025-12-31 17:43:32 +00:00
fix: Prevent externalAudioReader from hogging the main thread
This commit is contained in:
parent
1357c5c062
commit
620fba0a14
12 changed files with 242 additions and 90 deletions
|
|
@ -4,6 +4,7 @@ import android.net.Uri;
|
|||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.OptIn;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.media3.common.MediaItem;
|
||||
import androidx.media3.common.MediaMetadata;
|
||||
import androidx.media3.common.MimeTypes;
|
||||
|
|
@ -240,4 +241,11 @@ public class MappingUtil {
|
|||
Download download = new DownloadRepository().getDownload(id);
|
||||
return download != null && !download.getDownloadUri().isEmpty() ? Uri.parse(download.getDownloadUri()) : MusicUtil.getDownloadUri(id);
|
||||
}
|
||||
|
||||
public static void observeExternalAudioRefresh(LifecycleOwner owner, Runnable onRefresh) {
|
||||
if (owner == null || onRefresh == null) {
|
||||
return;
|
||||
}
|
||||
ExternalAudioReader.getRefreshEvents().observe(owner, event -> onRefresh.run());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue