Converted download list to new item view
This commit is contained in:
parent
cb702a2de6
commit
e14ad4d859
@ -1,37 +1,24 @@
|
||||
package de.danoeh.antennapod.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.text.Layout;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.activity.MainActivity;
|
||||
import de.danoeh.antennapod.core.feed.FeedItem;
|
||||
import de.danoeh.antennapod.core.glide.ApGlideSettings;
|
||||
import de.danoeh.antennapod.core.util.Converter;
|
||||
import de.danoeh.antennapod.core.util.DateUtils;
|
||||
import de.danoeh.antennapod.core.feed.util.ImageResourceUtils;
|
||||
import de.danoeh.antennapod.view.EpisodeItemViewHolder;
|
||||
|
||||
/**
|
||||
* Shows a list of downloaded episodes
|
||||
* Shows a list of downloaded episodes.
|
||||
*/
|
||||
public class DownloadedEpisodesListAdapter extends BaseAdapter {
|
||||
|
||||
private final Context context;
|
||||
private final MainActivity activity;
|
||||
private final ItemAccess itemAccess;
|
||||
|
||||
public DownloadedEpisodesListAdapter(Context context, ItemAccess itemAccess) {
|
||||
public DownloadedEpisodesListAdapter(MainActivity activity, ItemAccess itemAccess) {
|
||||
super();
|
||||
this.context = context;
|
||||
this.activity = activity;
|
||||
this.itemAccess = itemAccess;
|
||||
}
|
||||
|
||||
@ -52,77 +39,23 @@ public class DownloadedEpisodesListAdapter extends BaseAdapter {
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
Holder holder;
|
||||
final FeedItem item = getItem(position);
|
||||
if (item == null) return null;
|
||||
|
||||
EpisodeItemViewHolder holder;
|
||||
if (convertView == null) {
|
||||
holder = new Holder();
|
||||
LayoutInflater inflater = (LayoutInflater) context
|
||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
convertView = inflater.inflate(R.layout.downloaded_episodeslist_item,
|
||||
parent, false);
|
||||
holder.imageView = convertView.findViewById(R.id.imgvImage);
|
||||
holder.title = convertView.findViewById(R.id.txtvTitle);
|
||||
if(Build.VERSION.SDK_INT >= 23) {
|
||||
holder.title.setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_FULL);
|
||||
}
|
||||
holder.txtvSize = convertView.findViewById(R.id.txtvSize);
|
||||
holder.queueStatus = convertView.findViewById(R.id.imgvInPlaylist);
|
||||
holder.pubDate = convertView
|
||||
.findViewById(R.id.txtvPublished);
|
||||
holder.butSecondary = convertView
|
||||
.findViewById(R.id.butSecondaryAction);
|
||||
convertView.setTag(holder);
|
||||
holder = new EpisodeItemViewHolder(activity, parent);
|
||||
} else {
|
||||
holder = (Holder) convertView.getTag();
|
||||
holder = (EpisodeItemViewHolder) convertView.getTag();
|
||||
}
|
||||
|
||||
Glide.with(context)
|
||||
.load(ImageResourceUtils.getImageLocation(item))
|
||||
.apply(new RequestOptions()
|
||||
.placeholder(R.color.light_gray)
|
||||
.error(R.color.light_gray)
|
||||
.diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY)
|
||||
.fitCenter()
|
||||
.dontAnimate())
|
||||
.into(holder.imageView);
|
||||
final FeedItem item = getItem(position);
|
||||
holder.bind(item);
|
||||
holder.dragHandle.setVisibility(View.GONE);
|
||||
holder.butSecondary.setImageResource(R.drawable.ic_delete_grey600_24dp);
|
||||
holder.butSecondary.setOnClickListener(v -> {
|
||||
FeedItem item1 = (FeedItem) v.getTag();
|
||||
itemAccess.onFeedItemSecondaryAction(item1);
|
||||
});
|
||||
|
||||
if(item.isPlayed()) {
|
||||
convertView.setAlpha(0.5f);
|
||||
} else {
|
||||
convertView.setAlpha(1.0f);
|
||||
}
|
||||
|
||||
holder.title.setText(item.getTitle());
|
||||
holder.txtvSize.setText(Converter.byteToString(item.getMedia().getSize()));
|
||||
holder.queueStatus.setVisibility(item.isTagged(FeedItem.TAG_QUEUE) ? View.VISIBLE : View.GONE);
|
||||
String pubDateStr = DateUtils.formatAbbrev(context, item.getPubDate());
|
||||
holder.pubDate.setText(pubDateStr);
|
||||
|
||||
holder.butSecondary.setFocusable(false);
|
||||
holder.butSecondary.setTag(item);
|
||||
holder.butSecondary.setOnClickListener(secondaryActionListener);
|
||||
|
||||
return convertView;
|
||||
}
|
||||
|
||||
private final View.OnClickListener secondaryActionListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
FeedItem item = (FeedItem) v.getTag();
|
||||
itemAccess.onFeedItemSecondaryAction(item);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
static class Holder {
|
||||
ImageView imageView;
|
||||
TextView title;
|
||||
TextView txtvSize;
|
||||
ImageView queueStatus;
|
||||
TextView pubDate;
|
||||
ImageButton butSecondary;
|
||||
return holder.itemView;
|
||||
}
|
||||
|
||||
public interface ItemAccess {
|
||||
|
@ -52,7 +52,7 @@ public class CompletedDownloadsFragment extends ListFragment {
|
||||
addVerticalPadding();
|
||||
addEmptyView();
|
||||
|
||||
listAdapter = new DownloadedEpisodesListAdapter(getActivity(), itemAccess);
|
||||
listAdapter = new DownloadedEpisodesListAdapter((MainActivity) getActivity(), itemAccess);
|
||||
setListAdapter(listAdapter);
|
||||
setListShown(false);
|
||||
EventBus.getDefault().register(this);
|
||||
|
@ -54,7 +54,7 @@ public class EpisodeItemViewHolder extends RecyclerView.ViewHolder
|
||||
private final ImageView isVideo;
|
||||
private final ImageView isFavorite;
|
||||
private final ProgressBar progressBar;
|
||||
private final ImageButton butSecondary;
|
||||
public final ImageButton butSecondary;
|
||||
private final MainActivity activity;
|
||||
|
||||
private FeedItem item;
|
||||
|
@ -1,102 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
tools:background="@android:color/darker_gray">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imgvImage"
|
||||
android:layout_width="@dimen/thumbnail_length_downloaded_item"
|
||||
android:layout_height="@dimen/thumbnail_length_downloaded_item"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginBottom="@dimen/listitem_threeline_verticalpadding"
|
||||
android:layout_marginLeft="@dimen/listitem_threeline_horizontalpadding"
|
||||
android:layout_marginStart="@dimen/listitem_threeline_horizontalpadding"
|
||||
android:layout_marginTop="@dimen/listitem_threeline_verticalpadding"
|
||||
android:contentDescription="@string/cover_label"
|
||||
android:scaleType="centerCrop"
|
||||
tools:src="@drawable/ic_antenna"
|
||||
tools:background="@android:color/holo_green_dark"/>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/listitem_threeline_textleftpadding"
|
||||
android:layout_marginStart="@dimen/listitem_threeline_textleftpadding"
|
||||
android:layout_marginRight="@dimen/listitem_threeline_textrightpadding"
|
||||
android:layout_marginEnd="@dimen/listitem_threeline_textrightpadding"
|
||||
android:layout_marginTop="@dimen/listitem_threeline_verticalpadding"
|
||||
android:layout_marginBottom="@dimen/listitem_threeline_verticalpadding"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical"
|
||||
tools:background="@android:color/holo_red_dark">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtvTitle"
|
||||
style="@style/AntennaPod.TextView.ListItemPrimaryTitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="4dp"
|
||||
tools:text="Downloaded episode title"
|
||||
tools:background="@android:color/holo_green_dark"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
tools:background="@android:color/holo_red_dark" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtvSize"
|
||||
style="@style/AntennaPod.TextView.ListItemSecondaryTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="23 MB"
|
||||
tools:background="@android:color/holo_green_dark"/>
|
||||
|
||||
<View
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="1dip"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imgvInPlaylist"
|
||||
android:layout_width="@dimen/enc_icons_size"
|
||||
android:layout_height="@dimen/enc_icons_size"
|
||||
android:contentDescription="@string/in_queue_label"
|
||||
android:src="?attr/stat_playlist"
|
||||
android:visibility="visible"
|
||||
tools:src="@drawable/ic_list_white_24dp"
|
||||
tools:background="@android:color/holo_red_light"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtvPublished"
|
||||
style="@style/AntennaPod.TextView.ListItemSecondaryTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
tools:text="Jan 23"
|
||||
tools:background="@android:color/holo_green_dark"/>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<include layout="@layout/vertical_list_divider"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/butSecondaryAction"
|
||||
android:layout_width="@dimen/listview_secondary_button_width"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:clickable="false"
|
||||
android:contentDescription="@string/delete_episode_label"
|
||||
android:focusable="false"
|
||||
android:focusableInTouchMode="false"
|
||||
android:src="?attr/content_discard"
|
||||
tools:src="@drawable/ic_delete_white_24dp"
|
||||
tools:background="@android:color/holo_green_dark" />
|
||||
|
||||
</LinearLayout>
|
Loading…
x
Reference in New Issue
Block a user