use CoverTarget for Subscriptions, some cleanup of how it looks
This commit is contained in:
parent
b6ac166c4f
commit
1d6a03ca29
|
@ -1,7 +1,5 @@
|
||||||
package de.danoeh.antennapod.adapter;
|
package de.danoeh.antennapod.adapter;
|
||||||
|
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.support.v7.widget.helper.ItemTouchHelper;
|
import android.support.v7.widget.helper.ItemTouchHelper;
|
||||||
|
@ -19,9 +17,6 @@ import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
import com.bumptech.glide.load.resource.drawable.GlideDrawable;
|
|
||||||
import com.bumptech.glide.request.animation.GlideAnimation;
|
|
||||||
import com.bumptech.glide.request.target.GlideDrawableImageViewTarget;
|
|
||||||
import com.joanzapata.iconify.Iconify;
|
import com.joanzapata.iconify.Iconify;
|
||||||
import com.nineoldandroids.view.ViewHelper;
|
import com.nineoldandroids.view.ViewHelper;
|
||||||
|
|
||||||
|
@ -197,7 +192,7 @@ public class AllEpisodesRecycleAdapter extends RecyclerView.Adapter<AllEpisodesR
|
||||||
.diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY)
|
.diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY)
|
||||||
.fitCenter()
|
.fitCenter()
|
||||||
.dontAnimate()
|
.dontAnimate()
|
||||||
.into(new CoverTarget(item.getFeed().getImageUri(), holder.placeholder, holder.cover));
|
.into(new CoverTarget(item.getFeed().getImageUri(), holder.placeholder, holder.cover, mainActivityRef.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -221,44 +216,6 @@ public class AllEpisodesRecycleAdapter extends RecyclerView.Adapter<AllEpisodesR
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class CoverTarget extends GlideDrawableImageViewTarget {
|
|
||||||
|
|
||||||
private final WeakReference<Uri> fallback;
|
|
||||||
private final WeakReference<TextView> placeholder;
|
|
||||||
private final WeakReference<ImageView> cover;
|
|
||||||
|
|
||||||
public CoverTarget(Uri fallbackUri, TextView txtvPlaceholder, ImageView imgvCover) {
|
|
||||||
super(imgvCover);
|
|
||||||
fallback = new WeakReference<>(fallbackUri);
|
|
||||||
placeholder = new WeakReference<>(txtvPlaceholder);
|
|
||||||
cover = new WeakReference<>(imgvCover);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onLoadFailed(Exception e, Drawable errorDrawable) {
|
|
||||||
Uri fallbackUri = fallback.get();
|
|
||||||
TextView txtvPlaceholder = placeholder.get();
|
|
||||||
ImageView imgvCover = cover.get();
|
|
||||||
if(fallbackUri != null && txtvPlaceholder != null && imgvCover != null) {
|
|
||||||
Glide.with(mainActivityRef.get())
|
|
||||||
.load(fallbackUri)
|
|
||||||
.diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY)
|
|
||||||
.fitCenter()
|
|
||||||
.dontAnimate()
|
|
||||||
.into(new CoverTarget(null, txtvPlaceholder, imgvCover));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResourceReady(GlideDrawable drawable, GlideAnimation anim) {
|
|
||||||
super.onResourceReady(drawable, anim);
|
|
||||||
TextView txtvPlaceholder = placeholder.get();
|
|
||||||
if(txtvPlaceholder != null) {
|
|
||||||
txtvPlaceholder.setVisibility(View.INVISIBLE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private View.OnClickListener secondaryActionListener = new View.OnClickListener() {
|
private View.OnClickListener secondaryActionListener = new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
|
|
@ -0,0 +1,61 @@
|
||||||
|
package de.danoeh.antennapod.adapter;
|
||||||
|
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.view.View;
|
||||||
|
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.animation.GlideAnimation;
|
||||||
|
import com.bumptech.glide.request.target.GlideDrawableImageViewTarget;
|
||||||
|
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
|
|
||||||
|
import de.danoeh.antennapod.activity.MainActivity;
|
||||||
|
import de.danoeh.antennapod.core.glide.ApGlideSettings;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Tom on 3/29/16.
|
||||||
|
*/
|
||||||
|
class CoverTarget extends GlideDrawableImageViewTarget {
|
||||||
|
|
||||||
|
private final WeakReference<Uri> fallback;
|
||||||
|
private final WeakReference<TextView> placeholder;
|
||||||
|
private final WeakReference<ImageView> cover;
|
||||||
|
private final WeakReference<MainActivity> mainActivity;
|
||||||
|
|
||||||
|
public CoverTarget(Uri fallbackUri, TextView txtvPlaceholder, ImageView imgvCover, MainActivity activity) {
|
||||||
|
super(imgvCover);
|
||||||
|
fallback = new WeakReference<>(fallbackUri);
|
||||||
|
placeholder = new WeakReference<>(txtvPlaceholder);
|
||||||
|
cover = new WeakReference<>(imgvCover);
|
||||||
|
mainActivity = new WeakReference<>(activity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoadFailed(Exception e, Drawable errorDrawable) {
|
||||||
|
Uri fallbackUri = fallback.get();
|
||||||
|
TextView txtvPlaceholder = placeholder.get();
|
||||||
|
ImageView imgvCover = cover.get();
|
||||||
|
if (fallbackUri != null && txtvPlaceholder != null && imgvCover != null) {
|
||||||
|
MainActivity activity = mainActivity.get();
|
||||||
|
Glide.with(activity)
|
||||||
|
.load(fallbackUri)
|
||||||
|
.diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY)
|
||||||
|
.fitCenter()
|
||||||
|
.dontAnimate()
|
||||||
|
.into(new CoverTarget(null, txtvPlaceholder, imgvCover, activity));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResourceReady(GlideDrawable drawable, GlideAnimation anim) {
|
||||||
|
super.onResourceReady(drawable, anim);
|
||||||
|
TextView txtvPlaceholder = placeholder.get();
|
||||||
|
if (txtvPlaceholder != null) {
|
||||||
|
txtvPlaceholder.setVisibility(View.INVISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +1,5 @@
|
||||||
package de.danoeh.antennapod.adapter;
|
package de.danoeh.antennapod.adapter;
|
||||||
|
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v4.view.MotionEventCompat;
|
import android.support.v4.view.MotionEventCompat;
|
||||||
|
@ -23,9 +21,6 @@ import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
import com.bumptech.glide.load.resource.drawable.GlideDrawable;
|
|
||||||
import com.bumptech.glide.request.animation.GlideAnimation;
|
|
||||||
import com.bumptech.glide.request.target.GlideDrawableImageViewTarget;
|
|
||||||
import com.joanzapata.iconify.Iconify;
|
import com.joanzapata.iconify.Iconify;
|
||||||
import com.nineoldandroids.view.ViewHelper;
|
import com.nineoldandroids.view.ViewHelper;
|
||||||
|
|
||||||
|
@ -297,50 +292,11 @@ public class QueueRecyclerAdapter extends RecyclerView.Adapter<QueueRecyclerAdap
|
||||||
.diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY)
|
.diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY)
|
||||||
.fitCenter()
|
.fitCenter()
|
||||||
.dontAnimate()
|
.dontAnimate()
|
||||||
.into(new CoverTarget(item.getFeed().getImageUri(), placeholder, cover));
|
.into(new CoverTarget(item.getFeed().getImageUri(), placeholder, cover, mainActivity.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private class CoverTarget extends GlideDrawableImageViewTarget {
|
|
||||||
|
|
||||||
private final WeakReference<Uri> fallback;
|
|
||||||
private final WeakReference<TextView> placeholder;
|
|
||||||
private final WeakReference<ImageView> cover;
|
|
||||||
|
|
||||||
public CoverTarget(Uri fallbackUri, TextView txtvPlaceholder, ImageView imgvCover) {
|
|
||||||
super(imgvCover);
|
|
||||||
fallback = new WeakReference<>(fallbackUri);
|
|
||||||
placeholder = new WeakReference<>(txtvPlaceholder);
|
|
||||||
cover = new WeakReference<>(imgvCover);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onLoadFailed(Exception e, Drawable errorDrawable) {
|
|
||||||
Uri fallbackUri = fallback.get();
|
|
||||||
TextView txtvPlaceholder = placeholder.get();
|
|
||||||
ImageView imgvCover = cover.get();
|
|
||||||
if(fallbackUri != null && txtvPlaceholder != null && imgvCover != null) {
|
|
||||||
Glide.with(mainActivity.get())
|
|
||||||
.load(fallbackUri)
|
|
||||||
.diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY)
|
|
||||||
.fitCenter()
|
|
||||||
.dontAnimate()
|
|
||||||
.into(new CoverTarget(null, txtvPlaceholder, imgvCover));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResourceReady(GlideDrawable drawable, GlideAnimation anim) {
|
|
||||||
super.onResourceReady(drawable, anim);
|
|
||||||
TextView txtvPlaceholder = placeholder.get();
|
|
||||||
if(txtvPlaceholder != null) {
|
|
||||||
txtvPlaceholder.setVisibility(View.INVISIBLE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private View.OnClickListener secondaryActionListener = new View.OnClickListener() {
|
private View.OnClickListener secondaryActionListener = new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package de.danoeh.antennapod.adapter;
|
package de.danoeh.antennapod.adapter;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.net.Uri;
|
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -12,9 +11,6 @@ import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.bumptech.glide.Glide;
|
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 java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
|
|
||||||
|
@ -113,24 +109,11 @@ public class SubscriptionsAdapter extends BaseAdapter implements AdapterView.OnI
|
||||||
holder.count.setPrimaryText(String.valueOf(itemAccess.getFeedCounter(feed.getId())));
|
holder.count.setPrimaryText(String.valueOf(itemAccess.getFeedCounter(feed.getId())));
|
||||||
Glide.with(mainActivityRef.get())
|
Glide.with(mainActivityRef.get())
|
||||||
.load(feed.getImageUri())
|
.load(feed.getImageUri())
|
||||||
.placeholder(R.color.light_gray)
|
|
||||||
.error(R.color.light_gray)
|
.error(R.color.light_gray)
|
||||||
.diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY)
|
.diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY)
|
||||||
.fitCenter()
|
.fitCenter()
|
||||||
.dontAnimate()
|
.dontAnimate()
|
||||||
.listener(new RequestListener<Uri, GlideDrawable>() {
|
.into(new CoverTarget(feed.getImageUri(), holder.feedTitle, holder.imageView, mainActivityRef.get()));
|
||||||
@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.INVISIBLE);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.into(holder.imageView);
|
|
||||||
|
|
||||||
return convertView;
|
return convertView;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,16 +18,11 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/txtvTitle"
|
android:id="@+id/txtvTitle"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:layout_centerInParent="true"
|
|
||||||
android:layout_margin="@dimen/widget_margin"
|
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:padding="@dimen/widget_margin"
|
|
||||||
style="@style/AntennaPod.TextView.Heading"
|
style="@style/AntennaPod.TextView.Heading"
|
||||||
android:textSize="15sp"
|
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:layout_gravity="bottom"
|
android:gravity="center_horizontal|bottom"
|
||||||
android:textColor="@android:color/white"
|
|
||||||
android:background="#55000000"
|
android:background="#55000000"
|
||||||
tools:text="@string/app_name" />
|
tools:text="@string/app_name" />
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue