|
|
@ -37,7 +37,7 @@ class CheckSourceService : BaseService() { |
|
|
|
@Synchronized |
|
|
|
@Synchronized |
|
|
|
override fun printCheckSourceMessage(sourceUrl: String, msg: String) { |
|
|
|
override fun printCheckSourceMessage(sourceUrl: String, msg: String) { |
|
|
|
postEvent(EventBus.CHECK_SOURCE_MESSAGE, Pair(sourceUrl, null)) |
|
|
|
postEvent(EventBus.CHECK_SOURCE_MESSAGE, Pair(sourceUrl, null)) |
|
|
|
Log.d(EventBus.CHECK_SOURCE_MESSAGE, "printCheckSourceMessage to post $msg") |
|
|
|
Log.d(EventBus.CHECK_SOURCE_MESSAGE, "printCheckSourceMessage to post $sourceUrl $msg") |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
private val notificationBuilder by lazy { |
|
|
|
private val notificationBuilder by lazy { |
|
|
@ -77,8 +77,6 @@ class CheckSourceService : BaseService() { |
|
|
|
super.onDestroy() |
|
|
|
super.onDestroy() |
|
|
|
tasks.clear() |
|
|
|
tasks.clear() |
|
|
|
searchCoroutine.close() |
|
|
|
searchCoroutine.close() |
|
|
|
Debug.callback = null |
|
|
|
|
|
|
|
Debug.isChecking = false |
|
|
|
|
|
|
|
postEvent(EventBus.CHECK_SOURCE_DONE, 0) |
|
|
|
postEvent(EventBus.CHECK_SOURCE_DONE, 0) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -112,7 +110,6 @@ class CheckSourceService : BaseService() { |
|
|
|
if (index < allIds.size) { |
|
|
|
if (index < allIds.size) { |
|
|
|
val sourceUrl = allIds[index] |
|
|
|
val sourceUrl = allIds[index] |
|
|
|
appDb.bookSourceDao.getBookSource(sourceUrl)?.let { source -> |
|
|
|
appDb.bookSourceDao.getBookSource(sourceUrl)?.let { source -> |
|
|
|
Debug.startChecking(source) |
|
|
|
|
|
|
|
check(source) |
|
|
|
check(source) |
|
|
|
} ?: onNext(sourceUrl, "") |
|
|
|
} ?: onNext(sourceUrl, "") |
|
|
|
} |
|
|
|
} |
|
|
@ -121,6 +118,7 @@ class CheckSourceService : BaseService() { |
|
|
|
|
|
|
|
|
|
|
|
fun check(source: BookSource) { |
|
|
|
fun check(source: BookSource) { |
|
|
|
execute(context = searchCoroutine) { |
|
|
|
execute(context = searchCoroutine) { |
|
|
|
|
|
|
|
Debug.startChecking(source) |
|
|
|
val webBook = WebBook(source) |
|
|
|
val webBook = WebBook(source) |
|
|
|
var books = webBook.searchBookAwait(this, CheckSource.keyword) |
|
|
|
var books = webBook.searchBookAwait(this, CheckSource.keyword) |
|
|
|
if (books.isEmpty()) { |
|
|
|
if (books.isEmpty()) { |
|
|
@ -181,7 +179,7 @@ class CheckSourceService : BaseService() { |
|
|
|
notificationMsg = |
|
|
|
notificationMsg = |
|
|
|
getString(R.string.progress_show, sourceName, checkedIds.size, allIds.size) |
|
|
|
getString(R.string.progress_show, sourceName, checkedIds.size, allIds.size) |
|
|
|
upNotification() |
|
|
|
upNotification() |
|
|
|
if (processIndex >= allIds.size + threadCount - 1) { |
|
|
|
if (processIndex > allIds.size + threadCount - 1) { |
|
|
|
stopSelf() |
|
|
|
stopSelf() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|