aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-08-28 22:27:33 -0700
committerScott Jackson <daneren2005@gmail.com>2014-08-28 22:27:33 -0700
commitc8c5267bdab2a12138c20e74781855d16b13fb99 (patch)
treeb930c192a18e53a580fd4fa620a5f1d015003be8
parent825fcc20125fd71ff53b53660bdaa048405e612d (diff)
downloaddsub-c8c5267bdab2a12138c20e74781855d16b13fb99.tar.gz
dsub-c8c5267bdab2a12138c20e74781855d16b13fb99.tar.bz2
dsub-c8c5267bdab2a12138c20e74781855d16b13fb99.zip
#251 Add layout for displaying when songs are already in playlist
-rw-r--r--res/layout/basic_count_item.xml35
-rw-r--r--src/github/daneren2005/dsub/fragments/SubsonicFragment.java30
2 files changed, 52 insertions, 13 deletions
diff --git a/res/layout/basic_count_item.xml b/res/layout/basic_count_item.xml
new file mode 100644
index 00000000..36a0e75d
--- /dev/null
+++ b/res/layout/basic_count_item.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:background="@android:color/transparent"
+ android:minHeight="50dip">
+
+ <TextView
+ android:id="@+id/basic_count_name"
+ android:layout_width="wrap_content"
+ android:layout_height="fill_parent"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:gravity="left|center_vertical"
+ android:paddingLeft="6dip"
+ android:paddingRight="6dip"
+ android:background="@android:color/transparent"
+ android:text="Text"/>
+
+ <TextView
+ android:id="@+id/basic_count_count"
+ android:layout_width="32dp"
+ android:layout_height="32dp"
+ android:layout_marginRight="12dp"
+ android:background="@drawable/ic_number_border"
+ android:focusable="false"
+ android:paddingRight="10dp"
+ android:layout_marginLeft="20px"
+ android:layout_marginBottom="4px"
+ android:text="99"
+ android:textAppearance="?android:attr/textAppearanceSmallPopupMenu"
+ android:textSize="11sp"
+ android:gravity="right|center_vertical"
+ android:layout_gravity="center_vertical"
+ android:visibility="gone"/>
+</LinearLayout> \ No newline at end of file
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();
}