2 * Copyright (C) 2012 Andrew Neal
3 * Copyright (C) 2014 The CyanogenMod Project
4 * Licensed under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with the
6 * License. You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
8 * or agreed to in writing, software distributed under the License is
9 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
10 * KIND, either express or implied. See the License for the specific language
11 * governing permissions and limitations under the License.
14 package com.cyanogenmod.eleven.model;
16 import android.text.TextUtils;
19 * A class that represents a song.
21 * @author Andrew Neal (andrewdneal@gmail.com)
26 * The unique Id of the song
33 public String mSongName;
38 public String mArtistName;
43 public String mAlbumName;
51 * The song duration in seconds
56 * The year the song was recorded
61 * Bucket label for the name - may not necessarily be the name - for example songs sorted by
62 * artists would be the artist bucket label and not the song name bucket label
64 public String mBucketLabel;
67 * Constructor of <code>Song</code>
69 * @param songId The Id of the song
70 * @param songName The name of the song
71 * @param artistName The song artist
72 * @param albumName The song album
73 * @param duration The duration of a song in seconds
74 * @param year The year the song was recorded
76 public Song(final long songId, final String songName, final String artistName,
77 final String albumName, final long albumId, final int duration, final int year) {
80 mArtistName = artistName;
81 mAlbumName = albumName;
91 public int hashCode() {
94 result = prime * result + (mAlbumName == null ? 0 : mAlbumName.hashCode());
95 result = prime * result + (int) mAlbumId;
96 result = prime * result + (mArtistName == null ? 0 : mArtistName.hashCode());
97 result = prime * result + mDuration;
98 result = prime * result + (int) mSongId;
99 result = prime * result + (mSongName == null ? 0 : mSongName.hashCode());
100 result = prime * result + mYear;
108 public boolean equals(final Object obj) {
115 if (getClass() != obj.getClass()) {
118 final Song other = (Song)obj;
119 if (mSongId != other.mSongId) {
122 if (!TextUtils.equals(mAlbumName, other.mAlbumName)) {
125 if (mAlbumId != other.mAlbumId) {
128 if (!TextUtils.equals(mArtistName, other.mArtistName)) {
131 if (mDuration != other.mDuration) {
134 if (!TextUtils.equals(mSongName, other.mSongName)) {
138 if (mYear != other.mYear) {
149 public String toString() {