2019-03-04 03:55:09 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2019 Hemanth Savarala.
|
|
|
|
*
|
|
|
|
* Licensed under the GNU General Public License v3
|
|
|
|
*
|
|
|
|
* This is free software: you can redistribute it and/or modify it under
|
|
|
|
* the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
* See the GNU General Public License for more details.
|
|
|
|
*/
|
|
|
|
package code.name.monkey.retromusic.model
|
|
|
|
|
|
|
|
import android.os.Parcelable
|
2020-08-21 14:19:15 +00:00
|
|
|
import code.name.monkey.retromusic.db.HistoryEntity
|
2020-08-20 10:01:22 +00:00
|
|
|
import code.name.monkey.retromusic.db.SongEntity
|
2019-03-04 03:55:09 +00:00
|
|
|
import kotlinx.android.parcel.Parcelize
|
|
|
|
|
2020-09-17 21:25:41 +00:00
|
|
|
// update equals and hashcode if fields changes
|
2019-03-04 03:55:09 +00:00
|
|
|
@Parcelize
|
2019-11-13 13:07:44 +00:00
|
|
|
open class Song(
|
2020-09-17 21:25:41 +00:00
|
|
|
open val id: Long,
|
|
|
|
open val title: String,
|
|
|
|
open val trackNumber: Int,
|
|
|
|
open val year: Int,
|
|
|
|
open val duration: Long,
|
|
|
|
open val data: String,
|
|
|
|
open val dateModified: Long,
|
|
|
|
open val albumId: Long,
|
|
|
|
open val albumName: String,
|
|
|
|
open val artistId: Long,
|
|
|
|
open val artistName: String,
|
|
|
|
open val composer: String?,
|
|
|
|
open val albumArtist: String?
|
2019-11-13 13:07:44 +00:00
|
|
|
) : Parcelable {
|
2020-08-21 14:19:15 +00:00
|
|
|
|
2019-03-04 03:55:09 +00:00
|
|
|
|
2020-09-17 21:25:41 +00:00
|
|
|
// need to override manually because is open and cannot be a data class
|
|
|
|
override fun equals(other: Any?): Boolean {
|
|
|
|
if (this === other) return true
|
|
|
|
if (javaClass != other?.javaClass) return false
|
|
|
|
|
|
|
|
other as Song
|
|
|
|
|
|
|
|
if (id != other.id) return false
|
|
|
|
if (title != other.title) return false
|
|
|
|
if (trackNumber != other.trackNumber) return false
|
|
|
|
if (year != other.year) return false
|
|
|
|
if (duration != other.duration) return false
|
|
|
|
if (data != other.data) return false
|
|
|
|
if (dateModified != other.dateModified) return false
|
|
|
|
if (albumId != other.albumId) return false
|
|
|
|
if (albumName != other.albumName) return false
|
|
|
|
if (artistId != other.artistId) return false
|
|
|
|
if (artistName != other.artistName) return false
|
|
|
|
if (composer != other.composer) return false
|
|
|
|
if (albumArtist != other.albumArtist) return false
|
|
|
|
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun hashCode(): Int {
|
|
|
|
var result = id.hashCode()
|
|
|
|
result = 31 * result + title.hashCode()
|
|
|
|
result = 31 * result + trackNumber
|
|
|
|
result = 31 * result + year
|
|
|
|
result = 31 * result + duration.hashCode()
|
|
|
|
result = 31 * result + data.hashCode()
|
|
|
|
result = 31 * result + dateModified.hashCode()
|
|
|
|
result = 31 * result + albumId.hashCode()
|
|
|
|
result = 31 * result + albumName.hashCode()
|
|
|
|
result = 31 * result + artistId.hashCode()
|
|
|
|
result = 31 * result + artistName.hashCode()
|
|
|
|
result = 31 * result + (composer?.hashCode() ?: 0)
|
|
|
|
result = 31 * result + (albumArtist?.hashCode() ?: 0)
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
2019-03-04 03:55:09 +00:00
|
|
|
|
|
|
|
companion object {
|
2020-05-05 19:44:59 +00:00
|
|
|
|
2019-03-04 03:55:09 +00:00
|
|
|
@JvmStatic
|
2019-11-13 13:07:44 +00:00
|
|
|
val emptySong = Song(
|
2020-09-17 21:25:41 +00:00
|
|
|
id = -1,
|
|
|
|
title = "",
|
|
|
|
trackNumber = -1,
|
|
|
|
year = -1,
|
|
|
|
duration = -1,
|
|
|
|
data = "",
|
|
|
|
dateModified = -1,
|
|
|
|
albumId = -1,
|
|
|
|
albumName = "",
|
|
|
|
artistId = -1,
|
|
|
|
artistName = "",
|
|
|
|
composer = "",
|
|
|
|
albumArtist = ""
|
2019-11-13 13:07:44 +00:00
|
|
|
)
|
2019-03-04 03:55:09 +00:00
|
|
|
}
|
|
|
|
}
|