mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 14:20:30 +05:30
commit
7683d0cb1b
@ -11,7 +11,6 @@ import android.view.ViewGroup
|
|||||||
import android.view.WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN
|
import android.view.WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN
|
||||||
import android.view.inputmethod.EditorInfo
|
import android.view.inputmethod.EditorInfo
|
||||||
import android.view.inputmethod.InputMethodManager
|
import android.view.inputmethod.InputMethodManager
|
||||||
import android.widget.EditText
|
|
||||||
import android.widget.TextView.GONE
|
import android.widget.TextView.GONE
|
||||||
import android.widget.TextView.OnEditorActionListener
|
import android.widget.TextView.OnEditorActionListener
|
||||||
import android.widget.TextView.VISIBLE
|
import android.widget.TextView.VISIBLE
|
||||||
@ -128,7 +127,7 @@ class SearchFragment : Fragment() {
|
|||||||
fetchNextSearchItems(binding.autoCompleteTextView.text.toString())
|
fetchNextSearchItems(binding.autoCompleteTextView.text.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fetchSuggestions(s.toString(), binding.autoCompleteTextView)
|
fetchSuggestions(s.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,7 +152,7 @@ class SearchFragment : Fragment() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun fetchSuggestions(query: String, autoTextView: EditText) {
|
private fun fetchSuggestions(query: String) {
|
||||||
fun run() {
|
fun run() {
|
||||||
lifecycleScope.launchWhenCreated {
|
lifecycleScope.launchWhenCreated {
|
||||||
binding.searchRecycler.visibility = GONE
|
binding.searchRecycler.visibility = GONE
|
||||||
@ -168,9 +167,16 @@ class SearchFragment : Fragment() {
|
|||||||
Log.e(TAG, "HttpException, unexpected response")
|
Log.e(TAG, "HttpException, unexpected response")
|
||||||
return@launchWhenCreated
|
return@launchWhenCreated
|
||||||
}
|
}
|
||||||
val suggestionsAdapter =
|
// only load the suggestions if the input field didn't get cleared yet
|
||||||
SearchSuggestionsAdapter(response, autoTextView, this@SearchFragment)
|
if (binding.autoCompleteTextView.text.toString() != "") {
|
||||||
binding.historyRecycler.adapter = suggestionsAdapter
|
val suggestionsAdapter =
|
||||||
|
SearchSuggestionsAdapter(
|
||||||
|
response,
|
||||||
|
binding.autoCompleteTextView,
|
||||||
|
this@SearchFragment
|
||||||
|
)
|
||||||
|
binding.historyRecycler.adapter = suggestionsAdapter
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!isFetchingSearch) run()
|
if (!isFetchingSearch) run()
|
||||||
|
Loading…
Reference in New Issue
Block a user