Skip to content

Commit 97e7272

Browse files
committed
Removed badly hacked default playlist thumbnail icon
The defaults should be supplied to the image loading software not the database library. This would also break when we shrink resources as that would rename the resources. Signed-off-by: Aayush Gupta <[email protected]>
1 parent 7c76791 commit 97e7272

File tree

3 files changed

+8
-35
lines changed

3 files changed

+8
-35
lines changed

app/src/main/java/org/schabi/newpipe/database/playlist/dao/PlaylistStreamDAO.kt

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import org.schabi.newpipe.database.BasicDAO
1515
import org.schabi.newpipe.database.playlist.PlaylistDuplicatesEntry
1616
import org.schabi.newpipe.database.playlist.PlaylistMetadataEntry
1717
import org.schabi.newpipe.database.playlist.PlaylistStreamEntry
18-
import org.schabi.newpipe.database.playlist.model.PlaylistEntity.Companion.DEFAULT_THUMBNAIL
1918
import org.schabi.newpipe.database.playlist.model.PlaylistEntity.Companion.DEFAULT_THUMBNAIL_ID
2019
import org.schabi.newpipe.database.playlist.model.PlaylistStreamEntity
2120

@@ -73,11 +72,7 @@ interface PlaylistStreamDAO : BasicDAO<PlaylistStreamEntity> {
7372
@Query(
7473
"""
7574
SELECT uid, name, is_thumbnail_permanent, thumbnail_stream_id, display_index,
76-
77-
CASE WHEN thumbnail_stream_id = $DEFAULT_THUMBNAIL_ID
78-
THEN :defaultThumbnail
79-
ELSE (SELECT thumbnail_url FROM streams WHERE streams.uid = thumbnail_stream_id)
80-
END AS thumbnail_url,
75+
(SELECT thumbnail_url FROM streams WHERE streams.uid = thumbnail_stream_id) AS thumbnail_url,
8176
8277
COALESCE(COUNT(playlist_id), 0) AS streamCount FROM playlists
8378
@@ -88,12 +83,7 @@ interface PlaylistStreamDAO : BasicDAO<PlaylistStreamEntity> {
8883
ORDER BY display_index
8984
"""
9085
)
91-
fun getPlaylistMetadata(defaultThumbnail: String): Flowable<MutableList<PlaylistMetadataEntry>>
92-
93-
// TODO: Remove on migrating classes to Kotlin
94-
fun getPlaylistMetadata(): Flowable<MutableList<PlaylistMetadataEntry>> {
95-
return getPlaylistMetadata(DEFAULT_THUMBNAIL)
96-
}
86+
fun getPlaylistMetadata(): Flowable<MutableList<PlaylistMetadataEntry>>
9787

9888
@RewriteQueriesToDropUnusedColumns
9989
@Transaction
@@ -118,11 +108,7 @@ interface PlaylistStreamDAO : BasicDAO<PlaylistStreamEntity> {
118108
@Query(
119109
"""
120110
SELECT playlists.uid, name, is_thumbnail_permanent, thumbnail_stream_id, display_index,
121-
122-
CASE WHEN thumbnail_stream_id = $DEFAULT_THUMBNAIL_ID
123-
THEN :defaultThumbnail
124-
ELSE (SELECT thumbnail_url FROM streams WHERE streams.uid = thumbnail_stream_id )
125-
END AS thumbnail_url,
111+
(SELECT thumbnail_url FROM streams WHERE streams.uid = thumbnail_stream_id) AS thumbnail_url,
126112
127113
COALESCE(COUNT(playlist_id), 0) AS streamCount,
128114
COALESCE(SUM(url = :streamUrl), 0) AS timesStreamIsContained FROM playlists
@@ -137,15 +123,5 @@ interface PlaylistStreamDAO : BasicDAO<PlaylistStreamEntity> {
137123
ORDER BY display_index, name
138124
"""
139125
)
140-
fun getPlaylistDuplicatesMetadata(
141-
streamUrl: String,
142-
defaultThumbnail: String
143-
): Flowable<MutableList<PlaylistDuplicatesEntry>>
144-
145-
// TODO: Remove on migrating classes to Kotlin
146-
fun getPlaylistDuplicatesMetadata(
147-
streamUrl: String
148-
): Flowable<MutableList<PlaylistDuplicatesEntry>> {
149-
return getPlaylistDuplicatesMetadata(streamUrl, DEFAULT_THUMBNAIL)
150-
}
126+
fun getPlaylistDuplicatesMetadata(streamUrl: String): Flowable<MutableList<PlaylistDuplicatesEntry>>
151127
}

app/src/main/java/org/schabi/newpipe/database/playlist/model/PlaylistEntity.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import androidx.room.ColumnInfo
1010
import androidx.room.Entity
1111
import androidx.room.Ignore
1212
import androidx.room.PrimaryKey
13-
import org.schabi.newpipe.R
1413
import org.schabi.newpipe.database.playlist.PlaylistMetadataEntry
1514

1615
@Entity(tableName = PlaylistEntity.Companion.PLAYLIST_TABLE)
@@ -42,9 +41,6 @@ data class PlaylistEntity @JvmOverloads constructor(
4241
)
4342

4443
companion object {
45-
@JvmField
46-
val DEFAULT_THUMBNAIL = "drawable://" + R.drawable.placeholder_thumbnail_playlist
47-
4844
const val DEFAULT_THUMBNAIL_ID = -1L
4945

5046
const val PLAYLIST_TABLE = "playlists"

app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistAppendDialog.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package org.schabi.newpipe.local.dialog;
22

3+
import static org.schabi.newpipe.database.playlist.model.PlaylistEntity.DEFAULT_THUMBNAIL_ID;
4+
35
import android.os.Bundle;
46
import android.view.LayoutInflater;
57
import android.view.View;
@@ -14,7 +16,6 @@
1416

1517
import org.schabi.newpipe.NewPipeDatabase;
1618
import org.schabi.newpipe.R;
17-
import org.schabi.newpipe.database.playlist.model.PlaylistEntity;
1819
import org.schabi.newpipe.database.playlist.PlaylistDuplicatesEntry;
1920
import org.schabi.newpipe.database.stream.model.StreamEntity;
2021
import org.schabi.newpipe.local.LocalItemListAdapter;
@@ -160,8 +161,8 @@ private void onPlaylistSelected(@NonNull final LocalPlaylistManager manager,
160161
.subscribe(ignored -> {
161162
successToast.show();
162163

163-
if (playlist.getThumbnailUrl() != null
164-
&& playlist.getThumbnailUrl().equals(PlaylistEntity.DEFAULT_THUMBNAIL)
164+
if (playlist.getThumbnailStreamId() != null
165+
&& playlist.getThumbnailStreamId() == DEFAULT_THUMBNAIL_ID
165166
) {
166167
playlistDisposables.add(manager
167168
.changePlaylistThumbnail(playlist.getUid(), streams.get(0).getUid(),

0 commit comments

Comments
 (0)