Refresh on Filter Changed

This commit is contained in:
Bnyro 2022-05-15 11:07:56 +02:00
parent 71f5becc08
commit d04b1bb085

View File

@ -16,7 +16,6 @@ import android.widget.ArrayAdapter
import android.widget.AutoCompleteTextView import android.widget.AutoCompleteTextView
import android.widget.ImageView import android.widget.ImageView
import android.widget.TextView.* import android.widget.TextView.*
import android.widget.Toast
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
@ -29,7 +28,6 @@ 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
@ -71,10 +69,11 @@ class SearchFragment : Fragment() {
AlertDialog.Builder(view.context) AlertDialog.Builder(view.context)
.setTitle(getString(R.string.choose_filter)) .setTitle(getString(R.string.choose_filter))
.setSingleChoiceItems(options, selectedFilter, DialogInterface.OnClickListener { .setSingleChoiceItems(options, selectedFilter, DialogInterface.OnClickListener {
dialog, id -> tempSelectedItem = id _, id -> tempSelectedItem = id
}) })
.setPositiveButton(getString(R.string.okay), DialogInterface.OnClickListener { .setPositiveButton(getString(R.string.okay), DialogInterface.OnClickListener {
dialog, id -> selectedFilter = tempSelectedItem _, _ -> selectedFilter = tempSelectedItem
fetchSearch(autoTextView.text.toString(), recyclerView)
}) })
.setNegativeButton(getString(R.string.cancel), null) .setNegativeButton(getString(R.string.cancel), null)
.create() .create()
@ -117,7 +116,7 @@ class SearchFragment : Fragment() {
GlobalScope.launch { GlobalScope.launch {
fetchSuggestions(s.toString(), autoTextView) fetchSuggestions(s.toString(), autoTextView)
delay(3000) delay(1000)
addtohistory(s.toString()) addtohistory(s.toString())
fetchSearch(s.toString(), recyclerView) fetchSearch(s.toString(), recyclerView)
} }