mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-28 16:00:31 +05:30
Fixed Search Items repeating lol
This commit is contained in:
parent
5207486c36
commit
ead1999b99
@ -27,6 +27,7 @@ import com.github.libretube.adapters.SearchHistoryAdapter
|
|||||||
import kotlinx.coroutines.GlobalScope
|
import kotlinx.coroutines.GlobalScope
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import org.chromium.base.ThreadUtils.runOnUiThread
|
||||||
import retrofit2.HttpException
|
import retrofit2.HttpException
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
|
||||||
@ -37,6 +38,7 @@ class SearchFragment : Fragment() {
|
|||||||
private var nextPage : String? = null
|
private var nextPage : String? = null
|
||||||
private lateinit var searchRecView : RecyclerView
|
private lateinit var searchRecView : RecyclerView
|
||||||
private var searchAdapter : SearchAdapter? = null
|
private var searchAdapter : SearchAdapter? = null
|
||||||
|
private var isLoading : Boolean = false
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
@ -207,8 +209,14 @@ class SearchFragment : Fragment() {
|
|||||||
|
|
||||||
private fun fetchNextSearchItems(query: String){
|
private fun fetchNextSearchItems(query: String){
|
||||||
lifecycleScope.launchWhenCreated {
|
lifecycleScope.launchWhenCreated {
|
||||||
|
if (!isLoading) {
|
||||||
|
isLoading = true
|
||||||
val response = try {
|
val response = try {
|
||||||
RetrofitInstance.api.getSearchResultsNextPage(query!!, apiSearchFilter, nextPage!!)
|
RetrofitInstance.api.getSearchResultsNextPage(
|
||||||
|
query!!,
|
||||||
|
apiSearchFilter,
|
||||||
|
nextPage!!
|
||||||
|
)
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
println(e)
|
println(e)
|
||||||
Log.e(TAG, "IOException, you might not have internet connection")
|
Log.e(TAG, "IOException, you might not have internet connection")
|
||||||
@ -219,6 +227,8 @@ class SearchFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
nextPage = response.nextpage
|
nextPage = response.nextpage
|
||||||
searchAdapter?.updateItems(response.items!!)
|
searchAdapter?.updateItems(response.items!!)
|
||||||
|
isLoading = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user