aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--res/layout/album_cell_item.xml56
-rw-r--r--res/layout/select_album.xml1
-rw-r--r--src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java4
-rw-r--r--src/github/daneren2005/dsub/view/AlbumCell.java71
-rw-r--r--src/github/daneren2005/dsub/view/AlbumGridAdapter.java9
-rw-r--r--src/github/daneren2005/dsub/view/SquareImageView.java32
6 files changed, 167 insertions, 6 deletions
diff --git a/res/layout/album_cell_item.xml b/res/layout/album_cell_item.xml
new file mode 100644
index 00000000..9cc85c6e
--- /dev/null
+++ b/res/layout/album_cell_item.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <github.daneren2005.dsub.view.SquareImageView
+ android:id="@+id/album_coverart"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="1"
+ android:src="@drawable/unknown_album"/>
+
+ <LinearLayout
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:paddingTop="4dp"
+ android:paddingLeft="2dp">
+
+ <LinearLayout
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:gravity="center_vertical"
+ android:orientation="vertical">
+
+ <TextView
+ android:id="@+id/album_title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:singleLine="true"
+ android:ellipsize="marquee"
+ android:text="@string/search.albums"/>
+
+ <TextView
+ android:id="@+id/album_artist"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:singleLine="true"
+ android:text="@string/search.artists"/>
+ </LinearLayout>
+
+ <ImageView
+ android:id="@+id/album_more"
+ android:src="?attr/download_none"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="right|center_vertical"
+ android:paddingRight="2dp"
+ android:background="@drawable/menubar_button"/>
+ </LinearLayout>
+
+</LinearLayout> \ No newline at end of file
diff --git a/res/layout/select_album.xml b/res/layout/select_album.xml
index b9bd3196..53b6bb63 100644
--- a/res/layout/select_album.xml
+++ b/res/layout/select_album.xml
@@ -30,7 +30,6 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:numColumns="auto_fit"
- android:columnWidth="90dp"
android:horizontalSpacing="10dp"
android:verticalSpacing="10dp"
android:gravity="center"
diff --git a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
index 499732f1..fb03f325 100644
--- a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
+++ b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
@@ -142,13 +142,13 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter
}
});
- entryList.setOnScrollListener(new AbsListView.OnScrollListener() {
+ albumList.setOnScrollListener(new AbsListView.OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {}
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
- int topRowVerticalPosition = (entryList.getChildCount() == 0) ? 0 : entryList.getChildAt(0).getTop();
+ int topRowVerticalPosition = (albumList.getChildCount() == 0) ? 0 : albumList.getChildAt(0).getTop();
refreshLayout.setEnabled(topRowVerticalPosition >= 0);
}
});
diff --git a/src/github/daneren2005/dsub/view/AlbumCell.java b/src/github/daneren2005/dsub/view/AlbumCell.java
index b78ed442..9cee0c41 100644
--- a/src/github/daneren2005/dsub/view/AlbumCell.java
+++ b/src/github/daneren2005/dsub/view/AlbumCell.java
@@ -15,5 +15,74 @@
package github.daneren2005.dsub.view;
-public class AlbumCell {
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.ImageButton;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import java.io.File;
+
+import github.daneren2005.dsub.R;
+import github.daneren2005.dsub.domain.MusicDirectory;
+import github.daneren2005.dsub.util.FileUtil;
+import github.daneren2005.dsub.util.ImageLoader;
+
+public class AlbumCell extends UpdateView {
+ private static final String TAG = AlbumCell.class.getSimpleName();
+
+ private Context context;
+ private MusicDirectory.Entry album;
+ private File file;
+
+ private View coverArtView;
+ private TextView titleView;
+ private TextView artistView;
+
+ public AlbumCell(Context context) {
+ super(context);
+ this.context = context;
+ LayoutInflater.from(context).inflate(R.layout.album_cell_item, this, true);
+
+ coverArtView = findViewById(R.id.album_coverart);
+ titleView = (TextView) findViewById(R.id.album_title);
+ artistView = (TextView) findViewById(R.id.album_artist);
+ moreButton = (ImageView) findViewById(R.id.album_more);
+ moreButton.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ v.showContextMenu();
+ }
+ });
+ }
+
+ protected void setObjectImpl(Object obj1, Object obj2) {
+ this.album = (MusicDirectory.Entry) obj1;
+ if(album.getAlbum() == null) {
+ titleView.setText(album.getTitle());
+ } else {
+ titleView.setText(album.getAlbum());
+ }
+ String artist = album.getArtist();
+ if(artist == null) {
+ artist = "";
+ }
+ if(album.getYear() != null) {
+ artist += " - " + album.getYear();
+ }
+ artistView.setText(artist);
+ artistView.setVisibility(album.getArtist() == null ? View.GONE : View.VISIBLE);
+ ((ImageLoader)obj2).loadImage(coverArtView, album, false, true);
+ file = null;
+ }
+
+ @Override
+ protected void updateBackground() {
+ if(file == null) {
+ file = FileUtil.getAlbumDirectory(context, album);
+ }
+
+ exists = file.exists();
+ isStarred = album.isStarred();
+ }
}
diff --git a/src/github/daneren2005/dsub/view/AlbumGridAdapter.java b/src/github/daneren2005/dsub/view/AlbumGridAdapter.java
index 60d4cda6..3c81fa9a 100644
--- a/src/github/daneren2005/dsub/view/AlbumGridAdapter.java
+++ b/src/github/daneren2005/dsub/view/AlbumGridAdapter.java
@@ -42,8 +42,13 @@ public class AlbumGridAdapter extends ArrayAdapter<MusicDirectory.Entry> {
public View getView(int position, View convertView, ViewGroup parent) {
MusicDirectory.Entry entry = getItem(position);
- AlbumView view;
- view = new AlbumView(activity);
+ AlbumCell view;
+ if(convertView instanceof AlbumCell) {
+ view = (AlbumCell) convertView;
+ } else {
+ view = new AlbumCell(activity);
+ }
+
view.setObject(entry, imageLoader);
return view;
}
diff --git a/src/github/daneren2005/dsub/view/SquareImageView.java b/src/github/daneren2005/dsub/view/SquareImageView.java
new file mode 100644
index 00000000..77ca50db
--- /dev/null
+++ b/src/github/daneren2005/dsub/view/SquareImageView.java
@@ -0,0 +1,32 @@
+/*
+ This file is part of Subsonic.
+ Subsonic is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+ Subsonic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+ You should have received a copy of the GNU General Public License
+ along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
+ Copyright 2014 (C) Scott Jackson
+*/
+
+package github.daneren2005.dsub.view;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.widget.ImageView;
+
+public class SquareImageView extends ImageView {
+ public SquareImageView(final Context context, final AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ @Override
+ public void onMeasure(final int widthSpec, final int heightSpec) {
+ super.onMeasure(widthSpec, heightSpec);
+ setMeasuredDimension(getMeasuredWidth(), getMeasuredWidth());
+ }
+}