fix: 工作线程显示悬浮窗造成的崩溃问题
This commit is contained in:
@ -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();
|
||||
|
||||
Reference in New Issue
Block a user