OSDN Git Service

Playlists: sort ignoring case
[android-x86/packages-apps-Eleven.git] / src / org / lineageos / eleven / model / Playlist.java
index 91d11df..60b2145 100644 (file)
@@ -1,20 +1,28 @@
 /*
  * Copyright (C) 2012 Andrew Neal
  * Copyright (C) 2014 The CyanogenMod Project
- * Licensed under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with the
- * License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
- * or agreed to in writing, software distributed under the License is
- * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the specific language
- * governing permissions and limitations under the License.
+ * Copyright (C) 2019 The LineageOS Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 
 package org.lineageos.eleven.model;
 
+import android.support.annotation.NonNull;
 import android.text.TextUtils;
 
+import java.util.Comparator;
+
 /**
  * A class that represents a playlist.
  *
@@ -50,9 +58,6 @@ public class Playlist {
         mSongCount = songCount;
     }
 
-    /**
-     * {@inheritDoc}
-     */
     @Override
     public int hashCode() {
         final int prime = 31;
@@ -63,9 +68,6 @@ public class Playlist {
         return result;
     }
 
-    /**
-     * {@inheritDoc}
-     */
     @Override
     public boolean equals(final Object obj) {
         if (this == obj) {
@@ -89,12 +91,13 @@ public class Playlist {
         return TextUtils.equals(mPlaylistName, other.mPlaylistName);
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    @NonNull
     @Override
     public String toString() {
-        return mPlaylistName;
+        return "Playlist[playlistId=" + mPlaylistId
+                + ", playlistName=" + mPlaylistName
+                + ", songCount=" + mSongCount
+                + "]";
     }
 
     /**
@@ -103,4 +106,11 @@ public class Playlist {
     public boolean isSmartPlaylist() {
         return mPlaylistId < 0;
     }
+
+    public static class IgnoreCaseComparator implements Comparator<Playlist> {
+        @Override
+        public int compare(Playlist p1, Playlist p2) {
+            return p1.mPlaylistName.compareToIgnoreCase(p2.mPlaylistName);
+        }
+    }
 }