Updated handling queries so first query is always instant
This commit is contained in:
parent
784a7a7f24
commit
0f1f43057e
@ -17,10 +17,7 @@ interface Queryable {
|
|||||||
override val queryHandler = Handler(Looper.getMainLooper())
|
override val queryHandler = Handler(Looper.getMainLooper())
|
||||||
override val queryRunnable = Runnable { TODO() }
|
override val queryRunnable = Runnable { TODO() }
|
||||||
|
|
||||||
override fun submitQuery() {
|
override fun submitQuery() {}
|
||||||
queryHandler.removeCallbacks(queryRunnable)
|
|
||||||
queryHandler.postDelayed(queryRunnable, queryDelay)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -84,9 +84,13 @@ class HideViewModel(
|
|||||||
// ---
|
// ---
|
||||||
|
|
||||||
override fun submitQuery() {
|
override fun submitQuery() {
|
||||||
|
if (!queryHandler.hasCallbacks(queryRunnable)) {
|
||||||
|
queryHandler.post(queryRunnable)
|
||||||
|
} else {
|
||||||
queryHandler.removeCallbacks(queryRunnable)
|
queryHandler.removeCallbacks(queryRunnable)
|
||||||
queryHandler.postDelayed(queryRunnable, queryDelay)
|
queryHandler.postDelayed(queryRunnable, queryDelay)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun query(
|
private fun query(
|
||||||
query: String = this.query,
|
query: String = this.query,
|
||||||
|
@ -166,9 +166,13 @@ class ModuleViewModel(
|
|||||||
// ---
|
// ---
|
||||||
|
|
||||||
override fun submitQuery() {
|
override fun submitQuery() {
|
||||||
|
if (!queryHandler.hasCallbacks(queryRunnable)) {
|
||||||
|
queryHandler.post(queryRunnable)
|
||||||
|
} else {
|
||||||
queryHandler.removeCallbacks(queryRunnable)
|
queryHandler.removeCallbacks(queryRunnable)
|
||||||
queryHandler.postDelayed(queryRunnable, queryDelay)
|
queryHandler.postDelayed(queryRunnable, queryDelay)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun queryInternal(query: String, offset: Int): Single<List<RepoItem>> {
|
private fun queryInternal(query: String, offset: Int): Single<List<RepoItem>> {
|
||||||
if (query.isBlank()) {
|
if (query.isBlank()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user