diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2012-06-23 12:36:04 +0200 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2012-06-23 12:36:04 +0200 |
commit | 5c308c7f1e3aa2ed00bc63023664ccff875702a6 (patch) | |
tree | a7102b0ffae2c8a62565cf891b1b375d14b73bbd /src/de/podfetcher | |
parent | 119f718bcf0fa5e31747735f26cceb8c6ea1ce36 (diff) | |
download | AntennaPod-5c308c7f1e3aa2ed00bc63023664ccff875702a6.zip |
Improvements to layouts
Diffstat (limited to 'src/de/podfetcher')
-rw-r--r-- | src/de/podfetcher/adapter/FeedItemlistAdapter.java | 68 |
1 files changed, 56 insertions, 12 deletions
diff --git a/src/de/podfetcher/adapter/FeedItemlistAdapter.java b/src/de/podfetcher/adapter/FeedItemlistAdapter.java index 936f4e2d5..c0fb2ce40 100644 --- a/src/de/podfetcher/adapter/FeedItemlistAdapter.java +++ b/src/de/podfetcher/adapter/FeedItemlistAdapter.java @@ -1,5 +1,6 @@ package de.podfetcher.adapter; +import java.text.DateFormat; import java.util.List; import de.podfetcher.feed.FeedItem; @@ -8,7 +9,10 @@ import de.podfetcher.R; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.ImageButton; +import android.widget.ImageView; +import android.widget.RelativeLayout; import android.widget.TextView; +import android.text.format.DateUtils; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; @@ -19,8 +23,8 @@ import android.graphics.Typeface; public class FeedItemlistAdapter extends ArrayAdapter<FeedItem> { private OnClickListener onButActionClicked; - public FeedItemlistAdapter(Context context, - int textViewResourceId, List<FeedItem> objects, OnClickListener onButActionClicked) { + public FeedItemlistAdapter(Context context, int textViewResourceId, + List<FeedItem> objects, OnClickListener onButActionClicked) { super(context, textViewResourceId, objects); this.onButActionClicked = onButActionClicked; } @@ -30,17 +34,28 @@ public class FeedItemlistAdapter extends ArrayAdapter<FeedItem> { Holder holder; FeedItem item = getItem(position); - if(convertView == null) { + if (convertView == null) { holder = new Holder(); - LayoutInflater inflater = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); + LayoutInflater inflater = (LayoutInflater) getContext() + .getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = inflater.inflate(R.layout.feeditemlist_item, null); - holder.title = (TextView) convertView.findViewById(R.id.txtvItemname); - holder.size = (TextView) convertView.findViewById(R.id.txtvItemsize); - holder.butAction = (ImageButton) convertView.findViewById(R.id.butAction); - + holder.title = (TextView) convertView + .findViewById(R.id.txtvItemname); + holder.lenSize = (TextView) convertView + .findViewById(R.id.txtvLenSize); + holder.butAction = (ImageButton) convertView + .findViewById(R.id.butAction); + holder.published = (TextView) convertView + .findViewById(R.id.txtvPublished); + holder.downloaded = (ImageView) convertView + .findViewById(R.id.imgvDownloaded); + holder.type = (ImageView) convertView.findViewById(R.id.imgvType); + holder.encInfo = (RelativeLayout) convertView + .findViewById(R.id.enc_info); + convertView.setTag(holder); } else { - holder = (Holder) convertView.getTag(); + holder = (Holder) convertView.getTag(); } holder.title.setText(item.getTitle()); @@ -49,16 +64,45 @@ public class FeedItemlistAdapter extends ArrayAdapter<FeedItem> { } else { holder.title.setTypeface(Typeface.DEFAULT); } - holder.size.setText(Converter.byteToString(item.getMedia().getSize())); + + holder.published.setText("Published: " + + DateUtils.formatSameDayTime(item.getPubDate().getTime(), + System.currentTimeMillis(), DateFormat.SHORT, + DateFormat.SHORT)); + + if (item.getMedia() == null) { + holder.encInfo.setVisibility(View.GONE); + } else { + if (item.getMedia().isDownloaded()) { + holder.lenSize.setText(Converter.getDurationStringShort(item + .getMedia().getDuration())); + holder.downloaded.setVisibility(View.VISIBLE); + } else { + holder.lenSize.setText(Converter.byteToString(item.getMedia() + .getSize())); + } + String type = item.getMedia().getMime_type() + .substring(0, item.getMedia().getMime_type().indexOf('/')); + if (type.equals("audio")) { + holder.type.setImageResource(R.drawable.type_audio); + } else if (type.equals("video")) { + holder.type.setImageResource(R.drawable.type_video); + } + } + holder.butAction.setFocusable(false); holder.butAction.setOnClickListener(onButActionClicked); return convertView; - + } static class Holder { TextView title; - TextView size; + TextView published; + TextView lenSize; + ImageView downloaded; + ImageView type; ImageButton butAction; + RelativeLayout encInfo; } } |