From e3aa9263e69dd1f85baa552a437bfc5a10623d4a Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 13 Jun 2020 16:46:12 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../legado/app/ui/book/changesource/ChangeSourceViewModel.kt | 5 +++-- .../java/io/legado/app/ui/book/search/SearchViewModel.kt | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt index 605822af8..da58200c5 100644 --- a/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceViewModel.kt @@ -62,13 +62,14 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio @Synchronized private fun upAdapter() { - if (System.currentTimeMillis() > postTime + 500) { + if (System.currentTimeMillis() >= postTime + 500) { handler.removeCallbacks(sendRunnable) postTime = System.currentTimeMillis() val books = searchBooks.toList() searchBooksLiveData.postValue(books.sortedBy { it.originOrder }) } else { - handler.postDelayed(sendRunnable, 500) + handler.removeCallbacks(sendRunnable) + handler.postDelayed(sendRunnable, 500 - System.currentTimeMillis() + postTime) } } diff --git a/app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt b/app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt index 5e7f60026..318937697 100644 --- a/app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/search/SearchViewModel.kt @@ -42,12 +42,13 @@ class SearchViewModel(application: Application) : BaseViewModel(application), @Synchronized private fun upAdapter() { - if (System.currentTimeMillis() > postTime + 500) { + if (System.currentTimeMillis() >= postTime + 500) { handler.removeCallbacks(sendRunnable) postTime = System.currentTimeMillis() searchBookLiveData.postValue(searchBooks) } else { - handler.postDelayed(sendRunnable, 500) + handler.removeCallbacks(sendRunnable) + handler.postDelayed(sendRunnable, 500 - System.currentTimeMillis() + postTime) } }