OSDN Git Service

57e0825c45f7e6238b41736b3f8010b197f929c7
[android-x86/packages-apps-Eleven.git] / src / com / cyanogenmod / eleven / model / Playlist.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 a playlist.
20  *
21  * @author Andrew Neal (andrewdneal@gmail.com)
22  */
23 public class Playlist {
24
25     /**
26      * The unique Id of the playlist
27      */
28     public long mPlaylistId;
29
30     /**
31      * The playlist name
32      */
33     public String mPlaylistName;
34
35     /**
36      * The number of songs in this playlist
37      */
38     public int mSongCount;
39
40     /**
41      * Constructor of <code>Genre</code>
42      *
43      * @param playlistId The Id of the playlist
44      * @param playlistName The playlist name
45      */
46     public Playlist(final long playlistId, final String playlistName, final int songCount) {
47         super();
48         mPlaylistId = playlistId;
49         mPlaylistName = playlistName;
50         mSongCount = songCount;
51     }
52
53     /**
54      * {@inheritDoc}
55      */
56     @Override
57     public int hashCode() {
58         final int prime = 31;
59         int result = 1;
60         result = prime * result + (int) mPlaylistId;
61         result = prime * result + (mPlaylistName == null ? 0 : mPlaylistName.hashCode());
62         result = prime * result + mSongCount;
63         return result;
64     }
65
66     /**
67      * {@inheritDoc}
68      */
69     @Override
70     public boolean equals(final Object obj) {
71         if (this == obj) {
72             return true;
73         }
74         if (obj == null) {
75             return false;
76         }
77         if (getClass() != obj.getClass()) {
78             return false;
79         }
80         final Playlist other = (Playlist)obj;
81         if (mPlaylistId != other.mPlaylistId) {
82             return false;
83         }
84
85         if (mSongCount != other.mSongCount) {
86             return false;
87         }
88
89         return TextUtils.equals(mPlaylistName, other.mPlaylistName);
90     }
91
92     /**
93      * {@inheritDoc}
94      */
95     @Override
96     public String toString() {
97         return mPlaylistName;
98     }
99
100     /**
101      * @return true if this is a smart playlist
102      */
103     public boolean isSmartPlaylist() {
104         return mPlaylistId < 0;
105     }
106 }