From cb0e77d2042c5cf7f3a4e734fe900a155effc1bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=BE=E7=A5=A5=E4=BF=8A?= Date: Thu, 15 Aug 2024 14:09:06 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=B7=A5=E4=BD=9C=E7=BA=BF=E7=A8=8B?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E6=82=AC=E6=B5=AE=E7=AA=97=E9=80=A0=E6=88=90?= =?UTF-8?q?=E7=9A=84=E5=B4=A9=E6=BA=83=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/gh/ndownload/NDownloadService.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/src/main/java/com/gh/ndownload/NDownloadService.java b/app/src/main/java/com/gh/ndownload/NDownloadService.java index 28750eabcf..4bdfbe9dc7 100644 --- a/app/src/main/java/com/gh/ndownload/NDownloadService.java +++ b/app/src/main/java/com/gh/ndownload/NDownloadService.java @@ -14,9 +14,11 @@ import android.text.TextUtils; import androidx.annotation.Nullable; import androidx.core.app.NotificationCompat; +import com.blankj.utilcode.util.ThreadUtils; import com.gh.download.DownloadManager; import com.gh.gamecenter.SplashScreenActivity; import com.gh.gamecenter.common.base.GlobalActivityManager; +import com.gh.gamecenter.core.AppExecutor; import com.gh.ndownload.suspendwindow.NDownloadDrawOverlayPermissionWindowController; import com.gh.ndownload.suspendwindow.NDownloadSuspendWindowController; import com.gh.ndownload.suspendwindow.utils.NDownloadSuspendWindowHelper; @@ -282,6 +284,14 @@ public class NDownloadService extends Service { } private void showDownloadSuspendWindowIfNeeded(DownloadEntity entry) { + if (ThreadUtils.isMainThread()) { + showDownloadSuspendWindowIfNeededInner(entry); + } else { + AppExecutor.getUiExecutor().execute(() -> showDownloadSuspendWindowIfNeededInner(entry)); + } + } + + private void showDownloadSuspendWindowIfNeededInner(DownloadEntity entry) { if (!NDownloadSuspendWindowHelper.shouldSkipDownloadEntity(getApplicationContext(), entry)) { if (NDownloadSuspendWindowHelper.canDrawOverLayer(getApplicationContext())) {// 已开启悬浮窗权限,直接显示悬浮窗 showDownloadSuspendWindow();