Commit 76f750f4 authored by Alexandre Perraud's avatar Alexandre Perraud

Playlist : fix separator missing issue

parent ab55759e
......@@ -25,7 +25,6 @@ import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.TabLayout;
......@@ -269,6 +268,7 @@ public class AudioBrowserFragment extends MediaBrowserFragment implements SwipeR
updateLists();
else {
updateEmptyView(mViewPager.getCurrentItem());
updatePlaylists();
}
mMediaLibrary.addUpdateHandler(mHandler);
mMediaLibrary.setBrowser(this);
......@@ -279,7 +279,6 @@ public class AudioBrowserFragment extends MediaBrowserFragment implements SwipeR
mSwipeRefreshLayout.setEnabled(current.getFirstVisiblePosition() == 0);
}
});
updatePlaylists();
}
// Focus support. Start.
......@@ -863,20 +862,12 @@ public class AudioBrowserFragment extends MediaBrowserFragment implements SwipeR
Runnable updatePlaylists = new Runnable() {
@Override
public void run() {
if (Looper.myLooper() != Looper.getMainLooper()) {
mHandler.post(new Runnable() {
@Override
public void run() {
mPlaylistAdapter.clear();
}
});
}
//DB playlists
ArrayList<AudioBrowserListAdapter.ListItem> dbPlaylists = mMediaLibrary.getPlaylistDbItems();
mPlaylistAdapter.addAllDBPlaylists(dbPlaylists);
//File playlists
ArrayList<MediaWrapper> playlists = mMediaLibrary.getPlaylistFilesItems();
mPlaylistAdapter.addAll(playlists, AudioBrowserListAdapter.TYPE_PLAYLISTS);
//DB playlists
ArrayList<AudioBrowserListAdapter.ListItem> dbPlaylists = mMediaLibrary.getPlaylistDbItems();
mPlaylistAdapter.addAll(dbPlaylists);
mAdaptersToNotify.add(mPlaylistAdapter);
if (mReadyToDisplay && !mDisplaying)
......
......@@ -120,19 +120,6 @@ public class AudioBrowserListAdapter extends BaseAdapter implements SectionIndex
mAlignMode = Integer.valueOf(preferences.getString("audio_title_alignment", "0"));
}
public void addAll(final List<ListItem> items) {
mContext.runOnUiThread(new Runnable() {
@Override
public void run() {
for (ListItem item : items) {
mMediaItemMap.put(item.mTitle, item);
mItems.add(item);
}
Collections.sort(mItems, mItemsComparator);
}
});
}
public void add(String title, String subTitle, MediaWrapper media) {
add(title, subTitle, media, null);
}
......@@ -155,12 +142,26 @@ public class AudioBrowserListAdapter extends BaseAdapter implements SectionIndex
}
}
public void addAllDBPlaylists(final List<ListItem> items) {
mContext.runOnUiThread(new Runnable() {
@Override
public void run() {
clear();
for (ListItem item : items) {
mMediaItemMap.put(item.mMediaKey, item);
mItems.add(item);
}
}
});
}
public void addAll(List<MediaWrapper> mediaList, final int type) {
final LinkedList<MediaWrapper> list = new LinkedList<MediaWrapper>(mediaList);
mContext.runOnUiThread(new Runnable() {
@Override
public void run() {
clear();
if (type != TYPE_PLAYLISTS)
clear();
String title, subTitle, key;
for (MediaWrapper media : list) {
switch (type){
......@@ -226,6 +227,8 @@ public class AudioBrowserListAdapter extends BaseAdapter implements SectionIndex
char prevFirstChar = '%';
boolean firstSeparator = true;
ArrayList<String> sections = new ArrayList<>();
if (type == TYPE_PLAYLISTS)
Collections.sort(mItems, mItemsComparator);
for (int i = 0; i < mItems.size(); ++i) {
String title = mItems.get(i).mTitle;
......
......@@ -73,7 +73,7 @@ public class SavePlaylistDialog extends DialogFragment implements AdapterView.On
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mAdapter = new AudioBrowserListAdapter(getActivity(), AudioBrowserListAdapter.ITEM_WITHOUT_COVER);
mAdapter.addAll(MediaLibrary.getInstance().getPlaylistDbItems());
mAdapter.addAllDBPlaylists(MediaLibrary.getInstance().getPlaylistDbItems());
mTracks = getArguments().getParcelableArrayList(KEY_TRACKS);
mNewTrack = getArguments().getParcelableArrayList(KEY_NEW_TRACKS);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment