mirror of
https://github.com/TeamNewPipe/NewPipe.git
synced 2025-12-05 01:10:43 +00:00
Compare commits
2 Commits
7c76791db3
...
4826e5b3c5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4826e5b3c5 | ||
|
|
97e7272151 |
@@ -7,6 +7,7 @@
|
||||
package org.schabi.newpipe.database.playlist
|
||||
|
||||
import androidx.room.ColumnInfo
|
||||
import org.schabi.newpipe.database.playlist.model.PlaylistEntity
|
||||
|
||||
/**
|
||||
* This class adds a field to [PlaylistMetadataEntry] that contains an integer representing
|
||||
@@ -15,12 +16,25 @@ import androidx.room.ColumnInfo
|
||||
* @see org.schabi.newpipe.local.playlist.LocalPlaylistManager.getPlaylistDuplicates
|
||||
*/
|
||||
data class PlaylistDuplicatesEntry(
|
||||
@ColumnInfo(name = PlaylistEntity.PLAYLIST_ID)
|
||||
override val uid: Long,
|
||||
|
||||
@ColumnInfo(name = PlaylistEntity.PLAYLIST_THUMBNAIL_URL)
|
||||
override val thumbnailUrl: String?,
|
||||
|
||||
@ColumnInfo(name = PlaylistEntity.PLAYLIST_THUMBNAIL_PERMANENT)
|
||||
override val isThumbnailPermanent: Boolean?,
|
||||
|
||||
@ColumnInfo(name = PlaylistEntity.PLAYLIST_THUMBNAIL_STREAM_ID)
|
||||
override val thumbnailStreamId: Long?,
|
||||
|
||||
@ColumnInfo(name = PlaylistEntity.PLAYLIST_DISPLAY_INDEX)
|
||||
override var displayIndex: Long?,
|
||||
|
||||
@ColumnInfo(name = PLAYLIST_STREAM_COUNT)
|
||||
override val streamCount: Long,
|
||||
|
||||
@ColumnInfo(name = PlaylistEntity.PLAYLIST_NAME)
|
||||
override val orderingName: String?,
|
||||
|
||||
@ColumnInfo(name = PLAYLIST_TIMES_STREAM_IS_CONTAINED)
|
||||
|
||||
@@ -15,7 +15,6 @@ import org.schabi.newpipe.database.BasicDAO
|
||||
import org.schabi.newpipe.database.playlist.PlaylistDuplicatesEntry
|
||||
import org.schabi.newpipe.database.playlist.PlaylistMetadataEntry
|
||||
import org.schabi.newpipe.database.playlist.PlaylistStreamEntry
|
||||
import org.schabi.newpipe.database.playlist.model.PlaylistEntity.Companion.DEFAULT_THUMBNAIL
|
||||
import org.schabi.newpipe.database.playlist.model.PlaylistEntity.Companion.DEFAULT_THUMBNAIL_ID
|
||||
import org.schabi.newpipe.database.playlist.model.PlaylistStreamEntity
|
||||
|
||||
@@ -73,11 +72,7 @@ interface PlaylistStreamDAO : BasicDAO<PlaylistStreamEntity> {
|
||||
@Query(
|
||||
"""
|
||||
SELECT uid, name, is_thumbnail_permanent, thumbnail_stream_id, display_index,
|
||||
|
||||
CASE WHEN thumbnail_stream_id = $DEFAULT_THUMBNAIL_ID
|
||||
THEN :defaultThumbnail
|
||||
ELSE (SELECT thumbnail_url FROM streams WHERE streams.uid = thumbnail_stream_id)
|
||||
END AS thumbnail_url,
|
||||
(SELECT thumbnail_url FROM streams WHERE streams.uid = thumbnail_stream_id) AS thumbnail_url,
|
||||
|
||||
COALESCE(COUNT(playlist_id), 0) AS streamCount FROM playlists
|
||||
|
||||
@@ -88,12 +83,7 @@ interface PlaylistStreamDAO : BasicDAO<PlaylistStreamEntity> {
|
||||
ORDER BY display_index
|
||||
"""
|
||||
)
|
||||
fun getPlaylistMetadata(defaultThumbnail: String): Flowable<MutableList<PlaylistMetadataEntry>>
|
||||
|
||||
// TODO: Remove on migrating classes to Kotlin
|
||||
fun getPlaylistMetadata(): Flowable<MutableList<PlaylistMetadataEntry>> {
|
||||
return getPlaylistMetadata(DEFAULT_THUMBNAIL)
|
||||
}
|
||||
fun getPlaylistMetadata(): Flowable<MutableList<PlaylistMetadataEntry>>
|
||||
|
||||
@RewriteQueriesToDropUnusedColumns
|
||||
@Transaction
|
||||
@@ -113,16 +103,11 @@ interface PlaylistStreamDAO : BasicDAO<PlaylistStreamEntity> {
|
||||
)
|
||||
fun getStreamsWithoutDuplicates(playlistId: Long): Flowable<MutableList<PlaylistStreamEntry>>
|
||||
|
||||
@RewriteQueriesToDropUnusedColumns
|
||||
@Transaction
|
||||
@Query(
|
||||
"""
|
||||
SELECT playlists.uid, name, is_thumbnail_permanent, thumbnail_stream_id, display_index,
|
||||
|
||||
CASE WHEN thumbnail_stream_id = $DEFAULT_THUMBNAIL_ID
|
||||
THEN :defaultThumbnail
|
||||
ELSE (SELECT thumbnail_url FROM streams WHERE streams.uid = thumbnail_stream_id )
|
||||
END AS thumbnail_url,
|
||||
(SELECT thumbnail_url FROM streams WHERE streams.uid = thumbnail_stream_id) AS thumbnail_url,
|
||||
|
||||
COALESCE(COUNT(playlist_id), 0) AS streamCount,
|
||||
COALESCE(SUM(url = :streamUrl), 0) AS timesStreamIsContained FROM playlists
|
||||
@@ -137,15 +122,5 @@ interface PlaylistStreamDAO : BasicDAO<PlaylistStreamEntity> {
|
||||
ORDER BY display_index, name
|
||||
"""
|
||||
)
|
||||
fun getPlaylistDuplicatesMetadata(
|
||||
streamUrl: String,
|
||||
defaultThumbnail: String
|
||||
): Flowable<MutableList<PlaylistDuplicatesEntry>>
|
||||
|
||||
// TODO: Remove on migrating classes to Kotlin
|
||||
fun getPlaylistDuplicatesMetadata(
|
||||
streamUrl: String
|
||||
): Flowable<MutableList<PlaylistDuplicatesEntry>> {
|
||||
return getPlaylistDuplicatesMetadata(streamUrl, DEFAULT_THUMBNAIL)
|
||||
}
|
||||
fun getPlaylistDuplicatesMetadata(streamUrl: String): Flowable<MutableList<PlaylistDuplicatesEntry>>
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.Ignore
|
||||
import androidx.room.PrimaryKey
|
||||
import org.schabi.newpipe.R
|
||||
import org.schabi.newpipe.database.playlist.PlaylistMetadataEntry
|
||||
|
||||
@Entity(tableName = PlaylistEntity.Companion.PLAYLIST_TABLE)
|
||||
@@ -42,9 +41,6 @@ data class PlaylistEntity @JvmOverloads constructor(
|
||||
)
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
val DEFAULT_THUMBNAIL = "drawable://" + R.drawable.placeholder_thumbnail_playlist
|
||||
|
||||
const val DEFAULT_THUMBNAIL_ID = -1L
|
||||
|
||||
const val PLAYLIST_TABLE = "playlists"
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.schabi.newpipe.local.dialog;
|
||||
|
||||
import static org.schabi.newpipe.database.playlist.model.PlaylistEntity.DEFAULT_THUMBNAIL_ID;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -14,7 +16,6 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import org.schabi.newpipe.NewPipeDatabase;
|
||||
import org.schabi.newpipe.R;
|
||||
import org.schabi.newpipe.database.playlist.model.PlaylistEntity;
|
||||
import org.schabi.newpipe.database.playlist.PlaylistDuplicatesEntry;
|
||||
import org.schabi.newpipe.database.stream.model.StreamEntity;
|
||||
import org.schabi.newpipe.local.LocalItemListAdapter;
|
||||
@@ -160,8 +161,8 @@ public final class PlaylistAppendDialog extends PlaylistDialog {
|
||||
.subscribe(ignored -> {
|
||||
successToast.show();
|
||||
|
||||
if (playlist.getThumbnailUrl() != null
|
||||
&& playlist.getThumbnailUrl().equals(PlaylistEntity.DEFAULT_THUMBNAIL)
|
||||
if (playlist.getThumbnailStreamId() != null
|
||||
&& playlist.getThumbnailStreamId() == DEFAULT_THUMBNAIL_ID
|
||||
) {
|
||||
playlistDisposables.add(manager
|
||||
.changePlaylistThumbnail(playlist.getUid(), streams.get(0).getUid(),
|
||||
|
||||
Reference in New Issue
Block a user