mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-15 06:40:30 +05:30
remove bad performing notifydatasetchanged
This commit is contained in:
parent
8f5de822d1
commit
ba21ebb99e
@ -38,8 +38,9 @@ class PlaylistAdapter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun updateItems(newItems: List<StreamItem>) {
|
fun updateItems(newItems: List<StreamItem>) {
|
||||||
|
val oldSize = videoFeed.size
|
||||||
videoFeed.addAll(newItems)
|
videoFeed.addAll(newItems)
|
||||||
notifyDataSetChanged()
|
notifyItemRangeInserted(oldSize, videoFeed.size)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PlaylistViewHolder {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PlaylistViewHolder {
|
||||||
|
@ -34,8 +34,9 @@ class PlaylistsAdapter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun updateItems(newItems: List<Playlists>) {
|
fun updateItems(newItems: List<Playlists>) {
|
||||||
|
val oldSize = playlists.size
|
||||||
playlists.addAll(newItems)
|
playlists.addAll(newItems)
|
||||||
notifyDataSetChanged()
|
notifyItemRangeInserted(oldSize, playlists.size)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PlaylistsViewHolder {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PlaylistsViewHolder {
|
||||||
@ -102,7 +103,9 @@ class PlaylistsAdapter(
|
|||||||
try {
|
try {
|
||||||
if (response.message == "ok") {
|
if (response.message == "ok") {
|
||||||
playlists.removeAt(position)
|
playlists.removeAt(position)
|
||||||
activity.runOnUiThread { notifyDataSetChanged() }
|
activity.runOnUiThread {
|
||||||
|
notifyItemRemoved(position)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e(TAG(), e.toString())
|
Log.e(TAG(), e.toString())
|
||||||
|
@ -30,13 +30,14 @@ class SearchHistoryAdapter(
|
|||||||
historyText.text = historyQuery
|
historyText.text = historyQuery
|
||||||
|
|
||||||
deleteHistory.setOnClickListener {
|
deleteHistory.setOnClickListener {
|
||||||
|
val itemIndex = historyList.indexOf(historyQuery)
|
||||||
historyList -= historyQuery
|
historyList -= historyQuery
|
||||||
Thread {
|
Thread {
|
||||||
Database.searchHistoryDao().delete(
|
Database.searchHistoryDao().delete(
|
||||||
SearchHistoryItem(query = historyQuery)
|
SearchHistoryItem(query = historyQuery)
|
||||||
)
|
)
|
||||||
}.start()
|
}.start()
|
||||||
notifyDataSetChanged()
|
notifyItemRemoved(itemIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
root.setOnClickListener {
|
root.setOnClickListener {
|
||||||
|
@ -34,8 +34,9 @@ class TrendingAdapter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun updateItems() {
|
fun updateItems() {
|
||||||
|
val oldSize = index
|
||||||
index += 10
|
index += 10
|
||||||
notifyDataSetChanged()
|
notifyItemRangeInserted(oldSize, index)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SubscriptionViewHolder {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SubscriptionViewHolder {
|
||||||
|
@ -22,7 +22,7 @@ class WatchHistoryAdapter(
|
|||||||
fun removeFromWatchHistory(position: Int) {
|
fun removeFromWatchHistory(position: Int) {
|
||||||
DatabaseHelper.removeFromWatchHistory(position)
|
DatabaseHelper.removeFromWatchHistory(position)
|
||||||
watchHistory.removeAt(position)
|
watchHistory.removeAt(position)
|
||||||
notifyDataSetChanged()
|
notifyItemRemoved(position)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): WatchHistoryViewHolder {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): WatchHistoryViewHolder {
|
||||||
|
Loading…
Reference in New Issue
Block a user