mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 00:10:32 +05:30
Search history almost works
This commit is contained in:
parent
8149e69210
commit
34b53d0b17
@ -15,6 +15,7 @@ import android.widget.ArrayAdapter
|
|||||||
import android.widget.AutoCompleteTextView
|
import android.widget.AutoCompleteTextView
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import android.widget.TextView.*
|
import android.widget.TextView.*
|
||||||
|
import android.widget.Toast
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
@ -189,6 +190,7 @@ class SearchFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (splited_history.size > 10) {
|
if (splited_history.size > 10) {
|
||||||
splited_history = splited_history.takeLast(10)
|
splited_history = splited_history.takeLast(10)
|
||||||
}
|
}
|
||||||
@ -202,7 +204,6 @@ class SearchFragment : Fragment() {
|
|||||||
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext())
|
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext())
|
||||||
var history = sharedPreferences.getString("search_history", "")
|
var history = sharedPreferences.getString("search_history", "")
|
||||||
var splited_history = history!!.split("|")
|
var splited_history = history!!.split("|")
|
||||||
|
|
||||||
return splited_history
|
return splited_history
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.github.libretube.adapters
|
package com.github.libretube.adapters
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
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
|
||||||
@ -10,10 +11,11 @@ import androidx.recyclerview.widget.RecyclerView
|
|||||||
import com.github.libretube.R
|
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>) :
|
||||||
RecyclerView.Adapter<SearchHistoryViewHolder>() {
|
RecyclerView.Adapter<SearchHistoryViewHolder>() {
|
||||||
override fun getItemCount(): Int {
|
override fun getItemCount(): Int {
|
||||||
return historyList.size
|
return historyList.size -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -24,7 +26,7 @@ class SearchHistoryAdapter(private val context: Context, private val historyList
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: SearchHistoryViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: SearchHistoryViewHolder, position: Int) {
|
||||||
val history = historyList[position]
|
val history = historyList[position+1]
|
||||||
holder.v.findViewById<TextView>(R.id.history_text).text = history
|
holder.v.findViewById<TextView>(R.id.history_text).text = history
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user