diff options
author | Scott Jackson <daneren2005@gmail.com> | 2014-08-28 22:27:33 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2014-08-28 22:27:33 -0700 |
commit | c8c5267bdab2a12138c20e74781855d16b13fb99 (patch) | |
tree | b930c192a18e53a580fd4fa620a5f1d015003be8 /src | |
parent | 825fcc20125fd71ff53b53660bdaa048405e612d (diff) | |
download | dsub-c8c5267bdab2a12138c20e74781855d16b13fb99.tar.gz dsub-c8c5267bdab2a12138c20e74781855d16b13fb99.tar.bz2 dsub-c8c5267bdab2a12138c20e74781855d16b13fb99.zip |
#251 Add layout for displaying when songs are already in playlist
Diffstat (limited to 'src')
-rw-r--r-- | src/github/daneren2005/dsub/fragments/SubsonicFragment.java | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java index 0655e461..14e941f1 100644 --- a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java +++ b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java @@ -34,15 +34,18 @@ import android.support.v4.widget.SwipeRefreshLayout; import android.util.Log;
import android.view.ContextMenu;
import android.view.GestureDetector;
+import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
+import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
+import android.widget.LinearLayout;
import android.widget.TextView;
import github.daneren2005.dsub.R;
import github.daneren2005.dsub.activity.DownloadActivity;
@@ -929,7 +932,7 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR // Create new if not getting a convert view to use
LinearLayout view;
if(convertView == null) {
- view = LayoutInflater.from(context).inflate(R.layout.basic_count_item, parent, false);
+ view = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.basic_count_item, parent, false);
} else {
view = (LinearLayout) convertView;
}
@@ -943,12 +946,11 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR int count = 0;
// Don't try to lookup playlist for Create New
if(!"-1".equals(playlist.getId())) {
- String cacheName = "playlist" + (Util.getRestUrl(context, null, false) + playlist.getId()).hashCode() + ".ser";
- MusicDirectory playlist = FileUtil.deserialize(context, cacheName, MusicDirectory.class);
- if(playlist != null) {
+ MusicDirectory cache = FileUtil.deserialize(context, Util.getCacheName(context, "playlist", playlist.getId()), MusicDirectory.class);
+ if(cache != null) {
// Try to find song instances in the given playlists
- for(MusicDirectory song: songs) {
- if(playlist.getChildren().contains(song)) {
+ for(MusicDirectory.Entry song: songs) {
+ if(cache.getChildren().contains(song)) {
count++;
}
}
@@ -969,20 +971,22 @@ public class SubsonicFragment extends Fragment implements SwipeRefreshLayout.OnR countView.setText(displayName);
countView.setVisibility(View.VISIBLE);
}
+
+ return view;
}
};
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(R.string.playlist_add_to)
.setAdapter(playlistAdapter, new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- if(which > 0) {
- addToPlaylist(playlists.get(which - 1), songs);
- } else {
- createNewPlaylist(songs, false);
+ public void onClick(DialogInterface dialog, int which) {
+ if (which > 0) {
+ addToPlaylist(playlists.get(which - 1), songs);
+ } else {
+ createNewPlaylist(songs, false);
+ }
}
- }
- });
+ });
AlertDialog dialog = builder.create();
dialog.show();
}
|