diff --git a/app/src/main/java/com/github/libretube/adapters/WatchHistoryAdapter.kt b/app/src/main/java/com/github/libretube/adapters/WatchHistoryAdapter.kt index 8da51363e..e5bbf67e7 100644 --- a/app/src/main/java/com/github/libretube/adapters/WatchHistoryAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/WatchHistoryAdapter.kt @@ -43,7 +43,7 @@ class WatchHistoryAdapter( deleteBTN.setOnClickListener { PreferenceHelper.removeFromWatchHistory(video.videoId!!) watchHistory.removeAt(position) - notifyItemRemoved(position) + notifyDataSetChanged() } root.setOnClickListener { diff --git a/app/src/main/java/com/github/libretube/extensions/SetWatchProgressLength.kt b/app/src/main/java/com/github/libretube/extensions/SetWatchProgressLength.kt index 419bec336..380ad0fc7 100644 --- a/app/src/main/java/com/github/libretube/extensions/SetWatchProgressLength.kt +++ b/app/src/main/java/com/github/libretube/extensions/SetWatchProgressLength.kt @@ -19,7 +19,7 @@ fun View?.setWatchProgressLength(videoId: String, duration: Long) { positions.forEach { if (it.videoId == videoId) { val fullWidth = (parent as LinearLayout).width - newWidth = (fullWidth * (it.position / (duration))) / 1000 + if (duration != 0L) newWidth = (fullWidth * (it.position / (duration))) / 1000 return@forEach } } diff --git a/app/src/main/java/com/github/libretube/preferences/PreferenceHelper.kt b/app/src/main/java/com/github/libretube/preferences/PreferenceHelper.kt index 346ff1204..950753649 100644 --- a/app/src/main/java/com/github/libretube/preferences/PreferenceHelper.kt +++ b/app/src/main/java/com/github/libretube/preferences/PreferenceHelper.kt @@ -3,6 +3,7 @@ package com.github.libretube.preferences import android.content.Context import android.content.SharedPreferences import androidx.preference.PreferenceManager +import com.fasterxml.jackson.core.type.TypeReference import com.fasterxml.jackson.databind.ObjectMapper import com.github.libretube.obj.CustomInstance import com.github.libretube.obj.Streams @@ -86,8 +87,9 @@ object PreferenceHelper { fun getSearchHistory(): List { return try { - val set: Set = settings.getStringSet("search_history", LinkedHashSet())!! - set.toList() + val json = settings.getString("search_history", "")!! + val type = object : TypeReference>(){} + return mapper.readValue(json, type) } catch (e: Exception) { emptyList() } @@ -118,8 +120,8 @@ object PreferenceHelper { } private fun updateSearchHistory(historyList: List) { - val set: Set = LinkedHashSet(historyList) - editor.putStringSet("search_history", set).apply() + val json = mapper.writeValueAsString(historyList) + editor.putString("search_history", json).apply() } fun addToWatchHistory(videoId: String, streams: Streams) {