mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-01-06 01:20:29 +05:30
commit
3b3ca61df7
@ -43,7 +43,7 @@ class WatchHistoryAdapter(
|
|||||||
deleteBTN.setOnClickListener {
|
deleteBTN.setOnClickListener {
|
||||||
PreferenceHelper.removeFromWatchHistory(video.videoId!!)
|
PreferenceHelper.removeFromWatchHistory(video.videoId!!)
|
||||||
watchHistory.removeAt(position)
|
watchHistory.removeAt(position)
|
||||||
notifyItemRemoved(position)
|
notifyDataSetChanged()
|
||||||
}
|
}
|
||||||
|
|
||||||
root.setOnClickListener {
|
root.setOnClickListener {
|
||||||
|
@ -19,7 +19,7 @@ fun View?.setWatchProgressLength(videoId: String, duration: Long) {
|
|||||||
positions.forEach {
|
positions.forEach {
|
||||||
if (it.videoId == videoId) {
|
if (it.videoId == videoId) {
|
||||||
val fullWidth = (parent as LinearLayout).width
|
val fullWidth = (parent as LinearLayout).width
|
||||||
newWidth = (fullWidth * (it.position / (duration))) / 1000
|
if (duration != 0L) newWidth = (fullWidth * (it.position / (duration))) / 1000
|
||||||
return@forEach
|
return@forEach
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package com.github.libretube.preferences
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
|
import com.fasterxml.jackson.core.type.TypeReference
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper
|
import com.fasterxml.jackson.databind.ObjectMapper
|
||||||
import com.github.libretube.obj.CustomInstance
|
import com.github.libretube.obj.CustomInstance
|
||||||
import com.github.libretube.obj.Streams
|
import com.github.libretube.obj.Streams
|
||||||
@ -86,8 +87,9 @@ object PreferenceHelper {
|
|||||||
|
|
||||||
fun getSearchHistory(): List<String> {
|
fun getSearchHistory(): List<String> {
|
||||||
return try {
|
return try {
|
||||||
val set: Set<String> = settings.getStringSet("search_history", LinkedHashSet())!!
|
val json = settings.getString("search_history", "")!!
|
||||||
set.toList()
|
val type = object : TypeReference<List<String>>(){}
|
||||||
|
return mapper.readValue(json, type)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
emptyList()
|
emptyList()
|
||||||
}
|
}
|
||||||
@ -118,8 +120,8 @@ object PreferenceHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun updateSearchHistory(historyList: List<String>) {
|
private fun updateSearchHistory(historyList: List<String>) {
|
||||||
val set: Set<String> = LinkedHashSet(historyList)
|
val json = mapper.writeValueAsString(historyList)
|
||||||
editor.putStringSet("search_history", set).apply()
|
editor.putString("search_history", json).apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addToWatchHistory(videoId: String, streams: Streams) {
|
fun addToWatchHistory(videoId: String, streams: Streams) {
|
||||||
|
Loading…
Reference in New Issue
Block a user