diff options
author | Tom Hennen <tom.hennen@gmail.com> | 2016-03-25 13:57:34 -0400 |
---|---|---|
committer | Tom Hennen <tom.hennen@gmail.com> | 2016-03-25 13:57:34 -0400 |
commit | d6bda2e144c57dc878d70aec303467ca51e1f794 (patch) | |
tree | c1afd2c50b72618e05ebfb807bad631d92d92e9d /app | |
parent | f5111ce6e3a2c90848d5b9e992c01403a82d1db3 (diff) | |
download | AntennaPod-d6bda2e144c57dc878d70aec303467ca51e1f794.zip |
removed unneeded views
Diffstat (limited to 'app')
4 files changed, 79 insertions, 152 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/SubscriptionsAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/SubscriptionsAdapter.java index de000570b..ce8d384dd 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/SubscriptionsAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/SubscriptionsAdapter.java @@ -1,70 +1,106 @@ package de.danoeh.antennapod.adapter; import android.content.Context; +import android.net.Uri; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; 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.core.feed.Feed; -import de.danoeh.antennapod.view.SubscriptionViewItem; +import de.danoeh.antennapod.core.glide.ApGlideSettings; /** * Adapter for subscriptions */ 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) { - mItemAccess = itemAccess; - mContext = context; + this.itemAccess = itemAccess; + this.context = context; } public void setItemAccess(NavListAdapter.ItemAccess itemAccess) { - mItemAccess = itemAccess; + this.itemAccess = itemAccess; } @Override public int getCount() { - return mItemAccess.getCount(); + return itemAccess.getCount(); } @Override public Object getItem(int position) { - return mItemAccess.getItem(position); + return itemAccess.getItem(position); } @Override public long getItemId(int position) { - return mItemAccess.getItem(position).getId(); + return itemAccess.getItem(position).getId(); } @Override public View getView(int position, View convertView, ViewGroup parent) { Holder holder; - final Feed item = (Feed) getItem(position); - if (item == null) return null; + final Feed feed = (Feed) getItem(position); + if (feed == null) return null; if (convertView == null) { holder = new Holder(); - LayoutInflater inflater = - (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - convertView = inflater.inflate(R.layout.subscription_item, parent, false); - holder.itemView = (SubscriptionViewItem) convertView.findViewById(R.id.subscription_item); + + LayoutInflater layoutInflater = + (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + 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); } else { 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; } static class Holder { - SubscriptionViewItem itemView; + public TextView feedTitle; + public ImageView imageView; } } diff --git a/app/src/main/java/de/danoeh/antennapod/view/SubscriptionViewItem.java b/app/src/main/java/de/danoeh/antennapod/view/SubscriptionViewItem.java deleted file mode 100644 index 67973a7ef..000000000 --- a/app/src/main/java/de/danoeh/antennapod/view/SubscriptionViewItem.java +++ /dev/null @@ -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); - } - -} diff --git a/app/src/main/res/layout/subscription_item.xml b/app/src/main/res/layout/subscription_item.xml index cee37f7aa..c23d05bd4 100644 --- a/app/src/main/res/layout/subscription_item.xml +++ b/app/src/main/res/layout/subscription_item.xml @@ -1,12 +1,29 @@ <?xml version="1.0" encoding="utf-8"?> -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:orientation="vertical" - android:layout_width="wrap_content" - android:layout_height="wrap_content"> +<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="match_parent" + android:orientation="horizontal"> - <de.danoeh.antennapod.view.SubscriptionViewItem - android:layout_width="match_parent" - android:id="@+id/subscription_item" - android:layout_height="match_parent"/> + <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" /> -</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> diff --git a/app/src/main/res/layout/subscription_view.xml b/app/src/main/res/layout/subscription_view.xml deleted file mode 100644 index 629d9a492..000000000 --- a/app/src/main/res/layout/subscription_view.xml +++ /dev/null @@ -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> |