OSDN Git Service

Merge "Eleven: Fix crash when launching a song from file manager" into cm-12.0
[android-x86/packages-apps-Eleven.git] / src / com / cyanogenmod / eleven / model / Album.java
1 /*
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.
12  */
13
14 package com.cyanogenmod.eleven.model;
15
16 import android.text.TextUtils;
17
18 /**
19  * A class that represents an album.
20  * 
21  * @author Andrew Neal (andrewdneal@gmail.com)
22  */
23 public class Album {
24
25     /**
26      * The unique Id of the album
27      */
28     public long mAlbumId;
29
30     /**
31      * The name of the album
32      */
33     public String mAlbumName;
34
35     /**
36      * The album artist
37      */
38     public String mArtistName;
39
40     /**
41      * The number of songs in the album
42      */
43     public int mSongNumber;
44
45     /**
46      * The year the album was released
47      */
48     public String mYear;
49
50     /**
51      * Bucket label for the name - may not necessarily be the name - for example albums sorted by
52      * artists would be the artist bucket label and not the album name bucket label
53      */
54     public String mBucketLabel;
55
56     /**
57      * Constructor of <code>Album</code>
58      * 
59      * @param albumId The Id of the album
60      * @param albumName The name of the album
61      * @param artistName The album artist
62      * @param songNumber The number of songs in the album
63      * @param albumYear The year the album was released
64      */
65     public Album(final long albumId, final String albumName, final String artistName,
66             final int songNumber, final String albumYear) {
67         super();
68         mAlbumId = albumId;
69         mAlbumName = albumName;
70         mArtistName = artistName;
71         mSongNumber = songNumber;
72         mYear = albumYear;
73     }
74
75     /**
76      * {@inheritDoc}
77      */
78     @Override
79     public int hashCode() {
80         final int prime = 31;
81         int result = 1;
82         result = prime * result + (int) mAlbumId;
83         result = prime * result + (mAlbumName == null ? 0 : mAlbumName.hashCode());
84         result = prime * result + (mArtistName == null ? 0 : mArtistName.hashCode());
85         result = prime * result + mSongNumber;
86         result = prime * result + (mYear == null ? 0 : mYear.hashCode());
87         return result;
88     }
89
90     /**
91      * {@inheritDoc}
92      */
93     @Override
94     public boolean equals(final Object obj) {
95         if (this == obj) {
96             return true;
97         }
98         if (obj == null) {
99             return false;
100         }
101         if (getClass() != obj.getClass()) {
102             return false;
103         }
104         final Album other = (Album)obj;
105         if (mAlbumId != other.mAlbumId) {
106             return false;
107         }
108         if (!TextUtils.equals(mAlbumName, other.mAlbumName)) {
109             return false;
110         }
111         if (!TextUtils.equals(mArtistName, other.mArtistName)) {
112             return false;
113         }
114         if (mSongNumber != other.mSongNumber) {
115             return false;
116         }
117         if (!TextUtils.equals(mYear, other.mYear)) {
118             return false;
119         }
120         return true;
121     }
122
123     /**
124      * {@inheritDoc}
125      */
126     @Override
127     public String toString() {
128         return mAlbumName;
129     }
130
131 }