Added default drawables for folders and for files without icons.

This commit is contained in:
Felix Ableitner 2014-04-27 13:36:37 +02:00
parent 5ec9cb2271
commit 86b4f3ad03
22 changed files with 29 additions and 7 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 773 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 736 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 508 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 858 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 636 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 609 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 442 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 936 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 838 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 582 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 713 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

@ -27,10 +27,15 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package com.github.nutomic.controldlna.utility; package com.github.nutomic.controldlna.utility;
import java.net.URI;
import java.util.List; import java.util.List;
import org.teleal.cling.support.model.DIDLObject; import org.teleal.cling.support.model.DIDLObject;
import org.teleal.cling.support.model.item.AudioItem;
import org.teleal.cling.support.model.item.ImageItem;
import org.teleal.cling.support.model.item.Item; import org.teleal.cling.support.model.item.Item;
import org.teleal.cling.support.model.item.PlaylistItem;
import org.teleal.cling.support.model.item.VideoItem;
import org.teleal.cling.support.model.item.MusicTrack; import org.teleal.cling.support.model.item.MusicTrack;
import android.content.Context; import android.content.Context;
@ -39,6 +44,7 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.TextView; import android.widget.TextView;
import android.util.Log;
import com.github.nutomic.controldlna.R; import com.github.nutomic.controldlna.R;
@ -68,7 +74,6 @@ public class FileArrayAdapter extends ArrayAdapter<DIDLObject> {
TextView title = (TextView) convertView.findViewById(R.id.title); TextView title = (TextView) convertView.findViewById(R.id.title);
TextView artist = (TextView) convertView.findViewById(R.id.subtitle); TextView artist = (TextView) convertView.findViewById(R.id.subtitle);
artist.setText(""); artist.setText("");
RemoteImageView image = (RemoteImageView) convertView.findViewById(R.id.image);
if (item instanceof MusicTrack) { if (item instanceof MusicTrack) {
MusicTrack track = (MusicTrack) item; MusicTrack track = (MusicTrack) item;
String trackNumber = (track.getOriginalTrackNumber() != null) String trackNumber = (track.getOriginalTrackNumber() != null)
@ -81,8 +86,27 @@ public class FileArrayAdapter extends ArrayAdapter<DIDLObject> {
else else
title.setText(item.getTitle()); title.setText(item.getTitle());
image.setImageUri(item.getFirstPropertyValue( RemoteImageView image = (RemoteImageView) convertView.findViewById(R.id.image);
DIDLObject.Property.UPNP.ALBUM_ART_URI.class)); URI icon = item.getFirstPropertyValue(
DIDLObject.Property.UPNP.ALBUM_ART_URI.class);
if (icon != null) {
image.setImageUri(icon);
}
else {
int resId;
if (item instanceof AudioItem)
resId = R.drawable.ic_doc_audio_am;
else if (item instanceof VideoItem)
resId = R.drawable.ic_doc_video_am;
else if (item instanceof ImageItem)
resId = R.drawable.ic_doc_image;
else if (item instanceof PlaylistItem)
resId = R.drawable.ic_doc_album;
else
resId = R.drawable.ic_root_folder_am;
image.setImageResource(resId);
}
return convertView; return convertView;
} }

View file

@ -54,8 +54,6 @@ public class RemoteImageView extends ImageView {
protected void onPostExecute(Bitmap bm) { protected void onPostExecute(Bitmap bm) {
if (bm != null) if (bm != null)
setImageBitmap(bm); setImageBitmap(bm);
else
setImageDrawable(null);
} }
}; };