mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-28 16:00:31 +05:30
Merge pull request #2332 from Bnyro/master
update bookmarked playlist thumbnails when changed
This commit is contained in:
commit
6de466d175
@ -5,6 +5,7 @@ import androidx.room.Delete
|
|||||||
import androidx.room.Insert
|
import androidx.room.Insert
|
||||||
import androidx.room.OnConflictStrategy
|
import androidx.room.OnConflictStrategy
|
||||||
import androidx.room.Query
|
import androidx.room.Query
|
||||||
|
import androidx.room.Update
|
||||||
import com.github.libretube.db.obj.PlaylistBookmark
|
import com.github.libretube.db.obj.PlaylistBookmark
|
||||||
|
|
||||||
@Dao
|
@Dao
|
||||||
@ -21,6 +22,9 @@ interface PlaylistBookmarkDao {
|
|||||||
@Delete
|
@Delete
|
||||||
fun delete(playlistBookmark: PlaylistBookmark)
|
fun delete(playlistBookmark: PlaylistBookmark)
|
||||||
|
|
||||||
|
@Update
|
||||||
|
fun update(playlistBookmark: PlaylistBookmark)
|
||||||
|
|
||||||
@Query("DELETE FROM playlistBookmark WHERE playlistId = :playlistId")
|
@Query("DELETE FROM playlistBookmark WHERE playlistId = :playlistId")
|
||||||
fun deleteById(playlistId: String)
|
fun deleteById(playlistId: String)
|
||||||
|
|
||||||
|
@ -95,7 +95,9 @@ class MainActivity : BaseActivity() {
|
|||||||
// sets the navigation bar color to the previously calculated color
|
// sets the navigation bar color to the previously calculated color
|
||||||
window.navigationBarColor = if (binding.bottomNav.menu.size() > 0) {
|
window.navigationBarColor = if (binding.bottomNav.menu.size() > 0) {
|
||||||
SurfaceColors.getColorForElevation(this, 10F)
|
SurfaceColors.getColorForElevation(this, 10F)
|
||||||
} else ThemeHelper.getThemeColor(this, android.R.attr.colorBackground)
|
} else {
|
||||||
|
ThemeHelper.getThemeColor(this, android.R.attr.colorBackground)
|
||||||
|
}
|
||||||
|
|
||||||
// set default tab as start fragment
|
// set default tab as start fragment
|
||||||
navController.graph.setStartDestination(startFragmentId)
|
navController.graph.setStartDestination(startFragmentId)
|
||||||
|
@ -241,6 +241,18 @@ class PlaylistFragment : BaseFragment() {
|
|||||||
val itemTouchHelper = ItemTouchHelper(itemTouchCallback)
|
val itemTouchHelper = ItemTouchHelper(itemTouchCallback)
|
||||||
itemTouchHelper.attachToRecyclerView(binding.playlistRecView)
|
itemTouchHelper.attachToRecyclerView(binding.playlistRecView)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// update the playlist thumbnail if bookmarked
|
||||||
|
val playlistBookmark = DatabaseHolder.Database.playlistBookmarkDao().getAll()
|
||||||
|
.firstOrNull { it.playlistId == playlistId }
|
||||||
|
playlistBookmark?.let {
|
||||||
|
if (playlistBookmark.thumbnailUrl != response.thumbnailUrl) {
|
||||||
|
playlistBookmark.thumbnailUrl = response.thumbnailUrl
|
||||||
|
query {
|
||||||
|
DatabaseHolder.Database.playlistBookmarkDao().update(playlistBookmark)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user