From 9a223532c5becc142afdbc97fedcf44c5d69ca5b Mon Sep 17 00:00:00 2001 From: hlloreda Date: Sun, 6 Dec 2020 23:40:38 +0100 Subject: [PATCH 1/3] [FIX] - Crash while deleting a video from a playlist while refreshing --- .../database/playlist/PlaylistStreamEntry.kt | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/schabi/newpipe/database/playlist/PlaylistStreamEntry.kt b/app/src/main/java/org/schabi/newpipe/database/playlist/PlaylistStreamEntry.kt index d9c892099..28ce176f0 100644 --- a/app/src/main/java/org/schabi/newpipe/database/playlist/PlaylistStreamEntry.kt +++ b/app/src/main/java/org/schabi/newpipe/database/playlist/PlaylistStreamEntry.kt @@ -7,7 +7,6 @@ import org.schabi.newpipe.database.playlist.model.PlaylistStreamEntity import org.schabi.newpipe.database.stream.model.StreamEntity import org.schabi.newpipe.database.stream.model.StreamStateEntity import org.schabi.newpipe.extractor.stream.StreamInfoItem -import kotlin.jvm.Throws class PlaylistStreamEntry( @Embedded @@ -36,4 +35,20 @@ class PlaylistStreamEntry( override fun getLocalItemType(): LocalItem.LocalItemType { return LocalItem.LocalItemType.PLAYLIST_STREAM_ITEM } + + override fun equals(other: Any?): Boolean { + if (other == null || other !is PlaylistStreamEntry || streamEntity != other.streamEntity || + progressTime != other.progressTime || streamId != other.streamId || joinIndex != other.joinIndex + ) return false + + return true + } + + override fun hashCode(): Int { + var result = streamEntity.hashCode() + result = 31 * result + progressTime.hashCode() + result = 31 * result + streamId.hashCode() + result = 31 * result + joinIndex + return result + } } From 5f3eb4871a69aeb6d5502fc48a66d6b2d45a56d5 Mon Sep 17 00:00:00 2001 From: hlloreda Date: Mon, 7 Dec 2020 00:06:56 +0100 Subject: [PATCH 2/3] [IMPORT] - import got deleted --- .../org/schabi/newpipe/database/playlist/PlaylistStreamEntry.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/org/schabi/newpipe/database/playlist/PlaylistStreamEntry.kt b/app/src/main/java/org/schabi/newpipe/database/playlist/PlaylistStreamEntry.kt index 28ce176f0..af741fdc8 100644 --- a/app/src/main/java/org/schabi/newpipe/database/playlist/PlaylistStreamEntry.kt +++ b/app/src/main/java/org/schabi/newpipe/database/playlist/PlaylistStreamEntry.kt @@ -7,6 +7,7 @@ import org.schabi.newpipe.database.playlist.model.PlaylistStreamEntity import org.schabi.newpipe.database.stream.model.StreamEntity import org.schabi.newpipe.database.stream.model.StreamStateEntity import org.schabi.newpipe.extractor.stream.StreamInfoItem +import kotlin.jvm.Throws class PlaylistStreamEntry( @Embedded From b30e025bdac1167466d497a112d3510a2f575120 Mon Sep 17 00:00:00 2001 From: hlloreda Date: Mon, 7 Dec 2020 10:53:33 +0100 Subject: [PATCH 3/3] [FIX] - Use of a Data class instead of overriding equals method --- .../database/playlist/PlaylistStreamEntry.kt | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/database/playlist/PlaylistStreamEntry.kt b/app/src/main/java/org/schabi/newpipe/database/playlist/PlaylistStreamEntry.kt index af741fdc8..aff6205f2 100644 --- a/app/src/main/java/org/schabi/newpipe/database/playlist/PlaylistStreamEntry.kt +++ b/app/src/main/java/org/schabi/newpipe/database/playlist/PlaylistStreamEntry.kt @@ -9,7 +9,7 @@ import org.schabi.newpipe.database.stream.model.StreamStateEntity import org.schabi.newpipe.extractor.stream.StreamInfoItem import kotlin.jvm.Throws -class PlaylistStreamEntry( +data class PlaylistStreamEntry( @Embedded val streamEntity: StreamEntity, @@ -36,20 +36,4 @@ class PlaylistStreamEntry( override fun getLocalItemType(): LocalItem.LocalItemType { return LocalItem.LocalItemType.PLAYLIST_STREAM_ITEM } - - override fun equals(other: Any?): Boolean { - if (other == null || other !is PlaylistStreamEntry || streamEntity != other.streamEntity || - progressTime != other.progressTime || streamId != other.streamId || joinIndex != other.joinIndex - ) return false - - return true - } - - override fun hashCode(): Int { - var result = streamEntity.hashCode() - result = 31 * result + progressTime.hashCode() - result = 31 * result + streamId.hashCode() - result = 31 * result + joinIndex - return result - } }