Fix DownloadService foreground notification #50
This commit is contained in:
@@ -10,6 +10,8 @@ import android.os.PowerManager
|
||||
import android.widget.Toast
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlin.collections.set
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.mapLatest
|
||||
@@ -33,8 +35,6 @@ import org.koitharu.kotatsu.utils.ext.connectivityManager
|
||||
import org.koitharu.kotatsu.utils.ext.throttle
|
||||
import org.koitharu.kotatsu.utils.ext.toArraySet
|
||||
import org.koitharu.kotatsu.utils.progress.ProgressJob
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlin.collections.set
|
||||
|
||||
class DownloadService : BaseService() {
|
||||
|
||||
@@ -70,7 +70,6 @@ class DownloadService : BaseService() {
|
||||
return if (manga != null) {
|
||||
jobs[startId] = downloadManga(startId, manga, chapters)
|
||||
jobCount.value = jobs.size
|
||||
Toast.makeText(this, R.string.manga_downloading_, Toast.LENGTH_SHORT).show()
|
||||
START_REDELIVER_INTENT
|
||||
} else {
|
||||
stopSelf(startId)
|
||||
@@ -184,6 +183,7 @@ class DownloadService : BaseService() {
|
||||
intent.putExtra(EXTRA_CHAPTERS_IDS, chaptersIds.toLongArray())
|
||||
}
|
||||
ContextCompat.startForegroundService(context, intent)
|
||||
Toast.makeText(context, R.string.manga_downloading_, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,9 +24,10 @@ class ForegroundNotificationSwitcher(
|
||||
@Synchronized
|
||||
fun notify(startId: Int, notification: Notification) {
|
||||
if (notifications.isEmpty()) {
|
||||
handler.postDelayed(StartForegroundRunnable(startId, notification), DEFAULT_DELAY)
|
||||
StartForegroundRunnable(startId, notification)
|
||||
} else {
|
||||
notificationManager.notify(startId, notification)
|
||||
}
|
||||
notificationManager.notify(startId, notification)
|
||||
notifications[startId] = notification
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user