removed unneeded views
This commit is contained in:
parent
f5111ce6e3
commit
d6bda2e144
|
@ -1,70 +1,106 @@
|
||||||
package de.danoeh.antennapod.adapter;
|
package de.danoeh.antennapod.adapter;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.net.Uri;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.BaseAdapter;
|
import android.widget.BaseAdapter;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.bumptech.glide.Glide;
|
||||||
|
import com.bumptech.glide.load.resource.drawable.GlideDrawable;
|
||||||
|
import com.bumptech.glide.request.RequestListener;
|
||||||
|
import com.bumptech.glide.request.target.Target;
|
||||||
|
|
||||||
import de.danoeh.antennapod.R;
|
import de.danoeh.antennapod.R;
|
||||||
import de.danoeh.antennapod.core.feed.Feed;
|
import de.danoeh.antennapod.core.feed.Feed;
|
||||||
import de.danoeh.antennapod.view.SubscriptionViewItem;
|
import de.danoeh.antennapod.core.glide.ApGlideSettings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adapter for subscriptions
|
* Adapter for subscriptions
|
||||||
*/
|
*/
|
||||||
public class SubscriptionsAdapter extends BaseAdapter {
|
public class SubscriptionsAdapter extends BaseAdapter {
|
||||||
|
|
||||||
private NavListAdapter.ItemAccess mItemAccess;
|
private NavListAdapter.ItemAccess itemAccess;
|
||||||
|
|
||||||
private Context mContext;
|
private final Context context;
|
||||||
|
|
||||||
public SubscriptionsAdapter(Context context, NavListAdapter.ItemAccess itemAccess) {
|
public SubscriptionsAdapter(Context context, NavListAdapter.ItemAccess itemAccess) {
|
||||||
mItemAccess = itemAccess;
|
this.itemAccess = itemAccess;
|
||||||
mContext = context;
|
this.context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setItemAccess(NavListAdapter.ItemAccess itemAccess) {
|
public void setItemAccess(NavListAdapter.ItemAccess itemAccess) {
|
||||||
mItemAccess = itemAccess;
|
this.itemAccess = itemAccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCount() {
|
public int getCount() {
|
||||||
return mItemAccess.getCount();
|
return itemAccess.getCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getItem(int position) {
|
public Object getItem(int position) {
|
||||||
return mItemAccess.getItem(position);
|
return itemAccess.getItem(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getItemId(int position) {
|
public long getItemId(int position) {
|
||||||
return mItemAccess.getItem(position).getId();
|
return itemAccess.getItem(position).getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
Holder holder;
|
Holder holder;
|
||||||
final Feed item = (Feed) getItem(position);
|
final Feed feed = (Feed) getItem(position);
|
||||||
if (item == null) return null;
|
if (feed == null) return null;
|
||||||
|
|
||||||
if (convertView == null) {
|
if (convertView == null) {
|
||||||
holder = new Holder();
|
holder = new Holder();
|
||||||
LayoutInflater inflater =
|
|
||||||
(LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
LayoutInflater layoutInflater =
|
||||||
convertView = inflater.inflate(R.layout.subscription_item, parent, false);
|
(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
holder.itemView = (SubscriptionViewItem) convertView.findViewById(R.id.subscription_item);
|
convertView = layoutInflater.inflate(R.layout.subscription_item, parent, false);
|
||||||
|
holder.feedTitle = (TextView) convertView.findViewById(R.id.txtvTitle);
|
||||||
|
holder.imageView = (ImageView) convertView.findViewById(R.id.imgvCover);
|
||||||
|
|
||||||
|
|
||||||
convertView.setTag(holder);
|
convertView.setTag(holder);
|
||||||
} else {
|
} else {
|
||||||
holder = (Holder) convertView.getTag();
|
holder = (Holder) convertView.getTag();
|
||||||
}
|
}
|
||||||
|
|
||||||
holder.itemView.setFeed(item);
|
holder.feedTitle.setVisibility(View.VISIBLE);
|
||||||
|
holder.feedTitle.setText(feed.getTitle());
|
||||||
|
Glide.with(context)
|
||||||
|
.load(feed.getImageUri())
|
||||||
|
.placeholder(R.color.light_gray)
|
||||||
|
.error(R.color.light_gray)
|
||||||
|
.diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY)
|
||||||
|
.fitCenter()
|
||||||
|
.dontAnimate()
|
||||||
|
.listener(new RequestListener<Uri, GlideDrawable>() {
|
||||||
|
@Override
|
||||||
|
public boolean onException(Exception e, Uri model, Target<GlideDrawable> target, boolean isFirstResource) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onResourceReady(GlideDrawable resource, Uri model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
|
||||||
|
holder.feedTitle.setVisibility(View.GONE);
|
||||||
|
holder.imageView.setVisibility(View.VISIBLE);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.into(holder.imageView);
|
||||||
|
|
||||||
return convertView;
|
return convertView;
|
||||||
}
|
}
|
||||||
|
|
||||||
static class Holder {
|
static class Holder {
|
||||||
SubscriptionViewItem itemView;
|
public TextView feedTitle;
|
||||||
|
public ImageView imageView;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,83 +0,0 @@
|
||||||
package de.danoeh.antennapod.view;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.util.AttributeSet;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.RelativeLayout;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import com.bumptech.glide.Glide;
|
|
||||||
import com.bumptech.glide.load.resource.drawable.GlideDrawable;
|
|
||||||
import com.bumptech.glide.request.RequestListener;
|
|
||||||
import com.bumptech.glide.request.target.Target;
|
|
||||||
|
|
||||||
import de.danoeh.antennapod.R;
|
|
||||||
import de.danoeh.antennapod.core.feed.Feed;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Custom view for handling feed item.
|
|
||||||
*/
|
|
||||||
public class SubscriptionViewItem extends RelativeLayout {
|
|
||||||
|
|
||||||
private ImageView mImageView;
|
|
||||||
private TextView mTextTime;
|
|
||||||
private TextView mFeedTitle;
|
|
||||||
private Context mContext;
|
|
||||||
|
|
||||||
public SubscriptionViewItem(Context context) {
|
|
||||||
super(context);
|
|
||||||
init(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
public SubscriptionViewItem(Context context, AttributeSet attrs) {
|
|
||||||
super(context, attrs);
|
|
||||||
init(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
public SubscriptionViewItem(Context context, AttributeSet attrs, int defStyle) {
|
|
||||||
super(context, attrs, defStyle);
|
|
||||||
init(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
|
||||||
super.onMeasure(widthMeasureSpec, widthMeasureSpec);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void init(Context context) {
|
|
||||||
mContext = context;
|
|
||||||
LayoutInflater mLayoutInflater =
|
|
||||||
(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
||||||
View view = mLayoutInflater.inflate(R.layout.subscription_view, this);
|
|
||||||
mTextTime = (TextView) view.findViewById(R.id.txtvTime);
|
|
||||||
mFeedTitle = (TextView) view.findViewById(R.id.txtvTitle);
|
|
||||||
mImageView = (ImageView) view.findViewById(R.id.imgvCover);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFeed(Feed feed) {
|
|
||||||
mFeedTitle.setVisibility(VISIBLE);
|
|
||||||
mFeedTitle.setText(feed.getTitle());
|
|
||||||
Glide.with(mContext)
|
|
||||||
.load(feed.getImageUri())
|
|
||||||
.listener(new RequestListener<Uri, GlideDrawable>() {
|
|
||||||
@Override
|
|
||||||
public boolean onException(Exception e, Uri model, Target<GlideDrawable> target, boolean isFirstResource) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onResourceReady(GlideDrawable resource, Uri model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
|
|
||||||
mFeedTitle.setVisibility(INVISIBLE);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.centerCrop()
|
|
||||||
.into(mImageView);
|
|
||||||
|
|
||||||
mTextTime.setVisibility(GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,12 +1,29 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:orientation="vertical"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<de.danoeh.antennapod.view.SubscriptionViewItem
|
<ImageView
|
||||||
android:layout_width="match_parent"
|
android:id="@+id/imgvCover"
|
||||||
android:id="@+id/subscription_item"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="match_parent"/>
|
android:layout_height="fill_parent"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
tools:src="@drawable/ic_launcher" />
|
||||||
|
|
||||||
</RelativeLayout>
|
<TextView
|
||||||
|
android:id="@+id/txtvTitle"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:layout_margin="@dimen/widget_margin"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:padding="@dimen/widget_margin"
|
||||||
|
style="@style/AntennaPod.TextView.Heading"
|
||||||
|
android:textSize="15sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
tools:text="@string/app_name" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
|
@ -1,43 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/imgvCover"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="fill_parent"
|
|
||||||
android:layout_centerHorizontal="true"
|
|
||||||
android:layout_centerVertical="true"
|
|
||||||
tools:src="@drawable/ic_launcher" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/txtvTitle"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_centerInParent="true"
|
|
||||||
android:layout_margin="@dimen/widget_margin"
|
|
||||||
android:ellipsize="end"
|
|
||||||
android:padding="@dimen/widget_margin"
|
|
||||||
style="@style/AntennaPod.TextView.Heading"
|
|
||||||
android:textSize="15sp"
|
|
||||||
android:textStyle="bold"
|
|
||||||
tools:text="@string/app_name" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/txtvTime"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignParentBottom="true"
|
|
||||||
android:layout_alignParentEnd="true"
|
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:layout_margin="@dimen/widget_margin"
|
|
||||||
android:ellipsize="end"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:textColor="@color/white"
|
|
||||||
android:textSize="12sp"
|
|
||||||
tools:text="@string/app_name" />
|
|
||||||
|
|
||||||
</RelativeLayout>
|
|
Loading…
Reference in New Issue