From 5b74a4cc39885e74488b31afc5071ab71e74ce21 Mon Sep 17 00:00:00 2001 From: daniel oeh Date: Thu, 3 Apr 2014 12:29:07 +0200 Subject: Added secondary button to new episodes list --- .../antennapod/adapter/NewEpisodesListAdapter.java | 51 ++++++++++++++-------- .../antennapod/fragment/NewEpisodesFragment.java | 6 +++ 2 files changed, 38 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/de/danoeh/antennapod/adapter/NewEpisodesListAdapter.java b/src/de/danoeh/antennapod/adapter/NewEpisodesListAdapter.java index 105d4c3ca..4d4a2494e 100644 --- a/src/de/danoeh/antennapod/adapter/NewEpisodesListAdapter.java +++ b/src/de/danoeh/antennapod/adapter/NewEpisodesListAdapter.java @@ -6,10 +6,7 @@ import android.text.format.DateUtils; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.BaseAdapter; -import android.widget.ImageView; -import android.widget.ProgressBar; -import android.widget.TextView; +import android.widget.*; import de.danoeh.antennapod.R; import de.danoeh.antennapod.asynctask.ImageLoader; import de.danoeh.antennapod.feed.FeedItem; @@ -35,8 +32,8 @@ public class NewEpisodesListAdapter extends BaseAdapter { this.context = context; this.itemAccess = itemAccess; drawables = context.obtainStyledAttributes(new int[]{ - R.attr.navigation_accept, R.attr.navigation_refresh, R.attr.av_download}); - labels = new int[]{R.string.status_downloaded_label, R.string.status_downloading_label, R.string.status_not_downloaded_label}; + R.attr.av_play, R.attr.navigation_cancel, R.attr.av_download}); + labels = new int[]{R.string.play_label, R.string.cancel_download_label, R.string.download_label}; } @Override @@ -113,8 +110,8 @@ public class NewEpisodesListAdapter extends BaseAdapter { holder.title = (TextView) convertView.findViewById(R.id.txtvTitle); holder.pubDate = (TextView) convertView .findViewById(R.id.txtvPublished); - holder.downloadStatus = (ImageView) convertView - .findViewById(R.id.imgvDownloadStatus); + holder.butSecondary = (ImageButton) convertView + .findViewById(R.id.butSecondaryAction); holder.queueStatus = (ImageView) convertView .findViewById(R.id.imgvInPlaylist); holder.statusPlaying = (ImageView) convertView @@ -159,27 +156,27 @@ public class NewEpisodesListAdapter extends BaseAdapter { if (!media.isDownloaded()) { if (isDownloadingMedia) { // item is being downloaded - holder.downloadStatus.setVisibility(View.VISIBLE); - holder.downloadStatus.setImageDrawable(drawables + holder.butSecondary.setVisibility(View.VISIBLE); + holder.butSecondary.setImageDrawable(drawables .getDrawable(1)); - holder.downloadStatus.setContentDescription(context.getString(labels[1])); + holder.butSecondary.setContentDescription(context.getString(labels[1])); holder.downloadProgress.setProgress(itemAccess.getItemDownloadProgressPercent(item)); } else { // item is not downloaded and not being downloaded - holder.downloadStatus.setVisibility(View.VISIBLE); - holder.downloadStatus.setImageDrawable(drawables.getDrawable(2)); - holder.downloadStatus.setContentDescription(context.getString(labels[2])); + holder.butSecondary.setVisibility(View.VISIBLE); + holder.butSecondary.setImageDrawable(drawables.getDrawable(2)); + holder.butSecondary.setContentDescription(context.getString(labels[2])); } } else { // item is not being downloaded - holder.downloadStatus.setVisibility(View.VISIBLE); - holder.downloadStatus + holder.butSecondary.setVisibility(View.VISIBLE); + holder.butSecondary .setImageDrawable(drawables.getDrawable(0)); - holder.downloadStatus.setContentDescription(context.getString(labels[0])); + holder.butSecondary.setContentDescription(context.getString(labels[0])); } } else { - holder.downloadStatus.setVisibility(View.INVISIBLE); + holder.butSecondary.setVisibility(View.INVISIBLE); } if (itemAccess.isInQueue(item)) { @@ -188,6 +185,12 @@ public class NewEpisodesListAdapter extends BaseAdapter { holder.queueStatus.setVisibility(View.INVISIBLE); } + holder.butSecondary.setFocusable(false); + holder.butSecondary.setTag(item); + holder.butSecondary.setOnClickListener(secondaryActionListener); + + + ImageLoader.getInstance().loadThumbnailBitmap( item, holder.imageView, @@ -197,16 +200,24 @@ public class NewEpisodesListAdapter extends BaseAdapter { return convertView; } + private View.OnClickListener secondaryActionListener = new View.OnClickListener() { + @Override + public void onClick(View v) { + FeedItem item = (FeedItem) v.getTag(); + itemAccess.onFeedItemSecondaryAction(item); + } + }; + static class Holder { TextView title; TextView pubDate; - ImageView downloadStatus; ImageView queueStatus; ImageView imageView; ImageView statusPlaying; ProgressBar downloadProgress; TextView txtvDuration; + ImageButton butSecondary; } public interface ItemAccess { @@ -221,5 +232,7 @@ public class NewEpisodesListAdapter extends BaseAdapter { int getItemDownloadProgressPercent(FeedItem item); boolean isInQueue(FeedItem item); + + void onFeedItemSecondaryAction(FeedItem item); } } diff --git a/src/de/danoeh/antennapod/fragment/NewEpisodesFragment.java b/src/de/danoeh/antennapod/fragment/NewEpisodesFragment.java index 8250e20d3..aa3f9ab65 100644 --- a/src/de/danoeh/antennapod/fragment/NewEpisodesFragment.java +++ b/src/de/danoeh/antennapod/fragment/NewEpisodesFragment.java @@ -6,6 +6,7 @@ import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; import android.support.v4.app.Fragment; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -193,6 +194,11 @@ public class NewEpisodesFragment extends Fragment { } } + @Override + public void onFeedItemSecondaryAction(FeedItem item) { + Log.i(TAG, item.getTitle()); + } + }; -- cgit v1.2.3