[Android] Fix playlist sections duplicated
Geoffrey Métais
git at videolan.org
Wed Feb 24 11:51:24 CET 2016
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Feb 24 11:50:54 2016 +0100| [ed5f1dc8d9dc78d31b661916eabba5e25336cad1] | committer: Geoffrey Métais
Fix playlist sections duplicated
> https://code.videolan.org/videolan/vlc-android/commit/ed5f1dc8d9dc78d31b661916eabba5e25336cad1
---
.../src/org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java
index 93bb1b5..2da6748 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java
@@ -223,8 +223,9 @@ public class AudioBrowserListAdapter extends BaseAdapter implements SectionIndex
* @param type Type of the audio file sort.
*/
private void calculateSections(int type) {
- char prevFirstChar = 'a';
+ char prevFirstChar = '%';
boolean firstSeparator = true;
+ ArrayList<String> sections = new ArrayList<>();
for (int i = 0; i < mItems.size(); ++i) {
String title = mItems.get(i).mTitle;
@@ -249,13 +250,15 @@ public class AudioBrowserListAdapter extends BaseAdapter implements SectionIndex
firstChar = '#'; // Blank / spaces-only song title.
if (Character.isLetter(firstChar)) {
- if (firstSeparator || firstChar != prevFirstChar) {
- ListItem item = new ListItem(String.valueOf(firstChar), null, null, true);
+ String firstCharInString = String.valueOf(firstChar);
+ if ((firstSeparator || firstChar != prevFirstChar) && !sections.contains(firstCharInString)) {
+ ListItem item = new ListItem(firstCharInString, null, null, true);
mItems.add(i, item);
mSections.put(i, String.valueOf(firstChar));
i++;
prevFirstChar = firstChar;
firstSeparator = false;
+ sections.add(firstCharInString);
}
}
else if (firstSeparator) {
More information about the Android
mailing list