mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 00:10:32 +05:30
Added search history action
This commit is contained in:
parent
34b53d0b17
commit
5b1f16fe97
@ -53,6 +53,8 @@ class SearchFragment : Fragment() {
|
|||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
val recyclerView = view.findViewById<RecyclerView>(R.id.search_recycler)
|
val recyclerView = view.findViewById<RecyclerView>(R.id.search_recycler)
|
||||||
|
|
||||||
|
val autoTextView = view.findViewById<AutoCompleteTextView>(R.id.autoCompleteTextView)
|
||||||
|
|
||||||
val historyRecycler = view.findViewById<RecyclerView>(R.id.history_recycler)
|
val historyRecycler = view.findViewById<RecyclerView>(R.id.history_recycler)
|
||||||
val history_tv = view.findViewById<TextView>(R.id.tv_history)
|
val history_tv = view.findViewById<TextView>(R.id.tv_history)
|
||||||
|
|
||||||
@ -64,10 +66,9 @@ class SearchFragment : Fragment() {
|
|||||||
history_tv.visibility = VISIBLE
|
history_tv.visibility = VISIBLE
|
||||||
|
|
||||||
historyRecycler.layoutManager = LinearLayoutManager(view.context)
|
historyRecycler.layoutManager = LinearLayoutManager(view.context)
|
||||||
historyRecycler.adapter = SearchHistoryAdapter(requireContext(),getHistory())
|
historyRecycler.adapter = SearchHistoryAdapter(requireContext(),getHistory(),autoTextView)
|
||||||
|
|
||||||
recyclerView.layoutManager = GridLayoutManager(view.context, 1)
|
recyclerView.layoutManager = GridLayoutManager(view.context, 1)
|
||||||
val autoTextView = view.findViewById<AutoCompleteTextView>(R.id.autoCompleteTextView)
|
|
||||||
autoTextView.requestFocus()
|
autoTextView.requestFocus()
|
||||||
val imm =
|
val imm =
|
||||||
requireContext().getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
requireContext().getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||||
@ -105,7 +106,7 @@ class SearchFragment : Fragment() {
|
|||||||
recyclerView.visibility = GONE
|
recyclerView.visibility = GONE
|
||||||
historyRecycler.visibility = VISIBLE
|
historyRecycler.visibility = VISIBLE
|
||||||
history_tv.visibility = VISIBLE
|
history_tv.visibility = VISIBLE
|
||||||
historyRecycler.adapter = SearchHistoryAdapter(requireContext(),getHistory())
|
historyRecycler.adapter = SearchHistoryAdapter(requireContext(),getHistory(),autoTextView)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import android.util.Log
|
|||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import android.widget.AutoCompleteTextView
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
@ -12,7 +13,7 @@ import com.github.libretube.R
|
|||||||
import com.google.android.material.imageview.ShapeableImageView
|
import com.google.android.material.imageview.ShapeableImageView
|
||||||
|
|
||||||
|
|
||||||
class SearchHistoryAdapter(private val context: Context, private val historyList: List<String>) :
|
class SearchHistoryAdapter(private val context: Context, private val historyList: List<String> , private val editText : AutoCompleteTextView) :
|
||||||
RecyclerView.Adapter<SearchHistoryViewHolder>() {
|
RecyclerView.Adapter<SearchHistoryViewHolder>() {
|
||||||
override fun getItemCount(): Int {
|
override fun getItemCount(): Int {
|
||||||
return historyList.size -1
|
return historyList.size -1
|
||||||
@ -40,6 +41,10 @@ class SearchHistoryAdapter(private val context: Context, private val historyList
|
|||||||
.apply()
|
.apply()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
holder.v.setOnClickListener {
|
||||||
|
editText.setText(history)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user