2015-03-31 22:44:41 +00:00
|
|
|
package org.thoughtcrime.securesms.components;
|
|
|
|
|
2015-05-05 22:14:41 +00:00
|
|
|
import android.annotation.TargetApi;
|
|
|
|
import android.app.Activity;
|
2015-03-31 22:44:41 +00:00
|
|
|
import android.content.Context;
|
2015-07-15 20:42:59 +00:00
|
|
|
import android.content.res.TypedArray;
|
|
|
|
import android.graphics.Color;
|
2015-07-30 22:02:20 +00:00
|
|
|
import android.os.Build;
|
2015-05-05 22:14:41 +00:00
|
|
|
import android.os.Build.VERSION;
|
|
|
|
import android.os.Build.VERSION_CODES;
|
2015-03-31 22:44:41 +00:00
|
|
|
import android.support.annotation.NonNull;
|
|
|
|
import android.support.annotation.Nullable;
|
|
|
|
import android.util.AttributeSet;
|
|
|
|
import android.util.Log;
|
|
|
|
import android.view.View;
|
2015-06-27 03:14:51 +00:00
|
|
|
import android.view.animation.AlphaAnimation;
|
|
|
|
import android.view.animation.Animation;
|
|
|
|
import android.view.animation.Animation.AnimationListener;
|
|
|
|
import android.widget.FrameLayout;
|
2015-07-30 22:02:20 +00:00
|
|
|
import android.widget.ImageButton;
|
2015-07-15 20:42:59 +00:00
|
|
|
import android.widget.ImageView;
|
2015-03-31 22:44:41 +00:00
|
|
|
|
2015-06-08 18:07:46 +00:00
|
|
|
import com.bumptech.glide.DrawableTypeRequest;
|
2015-03-31 22:44:41 +00:00
|
|
|
import com.bumptech.glide.GenericRequestBuilder;
|
|
|
|
import com.bumptech.glide.Glide;
|
2015-07-15 20:42:59 +00:00
|
|
|
import com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable;
|
|
|
|
import com.bumptech.glide.load.resource.drawable.GlideDrawable;
|
2015-03-31 22:44:41 +00:00
|
|
|
import com.bumptech.glide.request.RequestListener;
|
|
|
|
import com.bumptech.glide.request.target.Target;
|
2015-06-27 03:14:51 +00:00
|
|
|
import com.pnikosis.materialishprogress.ProgressWheel;
|
2015-03-31 22:44:41 +00:00
|
|
|
|
|
|
|
import org.thoughtcrime.securesms.R;
|
|
|
|
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
2015-08-24 22:24:31 +00:00
|
|
|
import org.thoughtcrime.securesms.database.PartDatabase;
|
2015-06-27 03:14:51 +00:00
|
|
|
import org.thoughtcrime.securesms.jobs.PartProgressEvent;
|
2015-03-31 22:44:41 +00:00
|
|
|
import org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader.DecryptableUri;
|
2015-08-10 16:33:57 +00:00
|
|
|
import org.thoughtcrime.securesms.mms.RoundedCorners;
|
2015-03-31 22:44:41 +00:00
|
|
|
import org.thoughtcrime.securesms.mms.Slide;
|
|
|
|
import org.thoughtcrime.securesms.mms.SlideDeck;
|
|
|
|
import org.thoughtcrime.securesms.util.FutureTaskListener;
|
|
|
|
import org.thoughtcrime.securesms.util.ListenableFutureTask;
|
2015-05-18 15:38:48 +00:00
|
|
|
import org.thoughtcrime.securesms.util.Util;
|
2015-07-30 22:02:20 +00:00
|
|
|
import org.thoughtcrime.securesms.util.ViewUtil;
|
2015-03-31 22:44:41 +00:00
|
|
|
|
2015-06-27 03:14:51 +00:00
|
|
|
import de.greenrobot.event.EventBus;
|
2015-03-31 22:44:41 +00:00
|
|
|
import ws.com.google.android.mms.pdu.PduPart;
|
|
|
|
|
2015-06-27 03:14:51 +00:00
|
|
|
public class ThumbnailView extends FrameLayout {
|
|
|
|
private static final String TAG = ThumbnailView.class.getSimpleName();
|
|
|
|
|
2015-08-24 22:24:31 +00:00
|
|
|
private boolean hideControls;
|
2015-07-15 20:42:59 +00:00
|
|
|
private ImageView image;
|
|
|
|
private ProgressWheel progress;
|
2015-07-30 22:02:20 +00:00
|
|
|
private ImageView removeButton;
|
2015-08-24 22:24:31 +00:00
|
|
|
private ImageButton downloadButton;
|
2015-07-15 20:42:59 +00:00
|
|
|
private int backgroundColorHint;
|
|
|
|
private int radius;
|
2015-05-18 15:38:48 +00:00
|
|
|
|
2015-03-31 22:44:41 +00:00
|
|
|
private ListenableFutureTask<SlideDeck> slideDeckFuture = null;
|
|
|
|
private SlideDeckListener slideDeckListener = null;
|
|
|
|
private ThumbnailClickListener thumbnailClickListener = null;
|
2015-08-24 22:24:31 +00:00
|
|
|
private ThumbnailClickListener downloadClickListener = null;
|
2015-05-18 15:38:48 +00:00
|
|
|
private String slideId = null;
|
|
|
|
private Slide slide = null;
|
2015-03-31 22:44:41 +00:00
|
|
|
|
|
|
|
public ThumbnailView(Context context) {
|
2015-06-27 03:14:51 +00:00
|
|
|
this(context, null);
|
2015-03-31 22:44:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public ThumbnailView(Context context, AttributeSet attrs) {
|
2015-06-27 03:14:51 +00:00
|
|
|
this(context, attrs, 0);
|
2015-03-31 22:44:41 +00:00
|
|
|
}
|
|
|
|
|
2015-08-24 22:24:31 +00:00
|
|
|
public ThumbnailView(final Context context, AttributeSet attrs, int defStyle) {
|
2015-03-31 22:44:41 +00:00
|
|
|
super(context, attrs, defStyle);
|
2015-06-27 03:14:51 +00:00
|
|
|
inflate(context, R.layout.thumbnail_view, this);
|
2015-08-24 22:24:31 +00:00
|
|
|
radius = getResources().getDimensionPixelSize(R.dimen.message_bubble_corner_radius);
|
|
|
|
image = (ImageView) findViewById(R.id.thumbnail_image);
|
|
|
|
progress = (ProgressWheel) findViewById(R.id.progress_wheel);
|
|
|
|
downloadButton = (ImageButton) findViewById(R.id.download_button);
|
2015-07-15 20:42:59 +00:00
|
|
|
|
|
|
|
if (attrs != null) {
|
|
|
|
TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.ThumbnailView, 0, 0);
|
|
|
|
backgroundColorHint = typedArray.getColor(0, Color.BLACK);
|
|
|
|
typedArray.recycle();
|
|
|
|
}
|
2015-06-27 03:14:51 +00:00
|
|
|
}
|
|
|
|
|
2015-07-30 22:02:20 +00:00
|
|
|
@Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
|
|
|
super.onLayout(changed, left, top, right, bottom);
|
|
|
|
if (removeButton != null) {
|
|
|
|
final int paddingHorizontal = removeButton.getWidth() / 2;
|
|
|
|
final int paddingVertical = removeButton.getHeight() / 2;
|
|
|
|
image.setPadding(paddingHorizontal, paddingVertical, paddingHorizontal, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-27 03:14:51 +00:00
|
|
|
@Override protected void onAttachedToWindow() {
|
|
|
|
super.onAttachedToWindow();
|
2015-07-13 19:33:00 +00:00
|
|
|
if (!EventBus.getDefault().isRegistered(this)) EventBus.getDefault().registerSticky(this);
|
2015-06-27 03:14:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override protected void onDetachedFromWindow() {
|
|
|
|
super.onDetachedFromWindow();
|
|
|
|
EventBus.getDefault().unregister(this);
|
|
|
|
}
|
|
|
|
|
2015-07-30 22:02:20 +00:00
|
|
|
private ProgressWheel getProgressWheel() {
|
|
|
|
if (progress == null) progress = ViewUtil.inflateStub(this, R.id.progress_wheel_stub);
|
|
|
|
return progress;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void hideProgressWheel() {
|
|
|
|
if (progress != null) progress.setVisibility(GONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
private ImageView getRemoveButton() {
|
|
|
|
if (removeButton == null) removeButton = ViewUtil.inflateStub(this, R.id.remove_button_stub);
|
|
|
|
return removeButton;
|
|
|
|
}
|
|
|
|
|
2015-06-27 03:14:51 +00:00
|
|
|
@SuppressWarnings("unused")
|
|
|
|
public void onEventAsync(final PartProgressEvent event) {
|
|
|
|
if (this.slide != null && event.partId.equals(this.slide.getPart().getPartId())) {
|
|
|
|
Util.runOnMain(new Runnable() {
|
|
|
|
@Override public void run() {
|
2015-07-30 22:02:20 +00:00
|
|
|
getProgressWheel().setInstantProgress(((float)event.progress) / event.total);
|
2015-06-27 03:14:51 +00:00
|
|
|
if (event.progress >= event.total) animateOutProgress();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2015-03-31 22:44:41 +00:00
|
|
|
}
|
|
|
|
|
2015-07-15 20:42:59 +00:00
|
|
|
public void setBackgroundColorHint(int color) {
|
|
|
|
this.backgroundColorHint = color;
|
|
|
|
}
|
|
|
|
|
2015-05-18 15:38:48 +00:00
|
|
|
public void setImageResource(@Nullable MasterSecret masterSecret,
|
|
|
|
long id, long timestamp,
|
|
|
|
@NonNull ListenableFutureTask<SlideDeck> slideDeckFuture)
|
2015-03-31 22:44:41 +00:00
|
|
|
{
|
|
|
|
if (this.slideDeckFuture != null && this.slideDeckListener != null) {
|
|
|
|
this.slideDeckFuture.removeListener(this.slideDeckListener);
|
|
|
|
}
|
|
|
|
|
2015-05-18 15:38:48 +00:00
|
|
|
String slideId = id + "::" + timestamp;
|
|
|
|
|
|
|
|
if (!slideId.equals(this.slideId)) {
|
2015-07-30 22:02:20 +00:00
|
|
|
hideProgressWheel();
|
2015-06-27 03:14:51 +00:00
|
|
|
image.setImageDrawable(null);
|
2015-05-18 15:38:48 +00:00
|
|
|
this.slide = null;
|
|
|
|
this.slideId = slideId;
|
|
|
|
}
|
|
|
|
|
2015-03-31 22:44:41 +00:00
|
|
|
this.slideDeckListener = new SlideDeckListener(masterSecret);
|
|
|
|
this.slideDeckFuture = slideDeckFuture;
|
|
|
|
this.slideDeckFuture.addListener(this.slideDeckListener);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setImageResource(@NonNull Slide slide, @Nullable MasterSecret masterSecret) {
|
2015-06-27 03:14:51 +00:00
|
|
|
if (Util.equals(slide, this.slide)) {
|
|
|
|
Log.w(TAG, "Not loading resource, slide was identical");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!isContextValid()) {
|
|
|
|
Log.w(TAG, "Not loading resource, context is invalid");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-08-24 22:24:31 +00:00
|
|
|
if (!hideControls && slide.getTransferProgress() == PartDatabase.TRANSFER_PROGRESS_STARTED) {
|
2015-07-30 22:02:20 +00:00
|
|
|
getProgressWheel().spin();
|
|
|
|
getProgressWheel().setVisibility(VISIBLE);
|
2015-08-24 22:24:31 +00:00
|
|
|
downloadButton.setVisibility(GONE);
|
|
|
|
} else if (!hideControls && slide.getTransferProgress() == PartDatabase.TRANSFER_PROGRESS_AUTO_PENDING ||
|
|
|
|
slide.getTransferProgress() == PartDatabase.TRANSFER_PROGRESS_FAILED)
|
|
|
|
{
|
|
|
|
hideProgressWheel();
|
|
|
|
downloadButton.setVisibility(VISIBLE);
|
2015-05-05 22:14:41 +00:00
|
|
|
} else {
|
2015-07-30 22:02:20 +00:00
|
|
|
hideProgressWheel();
|
2015-08-24 22:24:31 +00:00
|
|
|
downloadButton.setVisibility(GONE);
|
2015-05-05 22:14:41 +00:00
|
|
|
}
|
2015-08-24 22:24:31 +00:00
|
|
|
|
|
|
|
this.slide = slide;
|
2015-06-27 03:14:51 +00:00
|
|
|
buildGlideRequest(slide, masterSecret).into(image);
|
2015-09-07 03:20:01 +00:00
|
|
|
if (this.slide.getTransferProgress() == PartDatabase.TRANSFER_PROGRESS_DONE) {
|
|
|
|
setOnClickListener(new ThumbnailClickDispatcher(thumbnailClickListener, slide));
|
|
|
|
} else {
|
|
|
|
setOnClickListener(null);
|
|
|
|
}
|
2015-08-24 22:24:31 +00:00
|
|
|
downloadButton.setOnClickListener(new ThumbnailClickDispatcher(downloadClickListener, slide));
|
2015-03-31 22:44:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setThumbnailClickListener(ThumbnailClickListener listener) {
|
|
|
|
this.thumbnailClickListener = listener;
|
|
|
|
}
|
|
|
|
|
2015-07-30 22:02:20 +00:00
|
|
|
public void setRemoveClickListener(OnClickListener listener) {
|
|
|
|
getRemoveButton().setOnClickListener(listener);
|
|
|
|
}
|
|
|
|
|
2015-08-24 22:24:31 +00:00
|
|
|
public void setDownloadClickListener(ThumbnailClickListener listener) {
|
|
|
|
this.downloadClickListener = listener;
|
|
|
|
}
|
|
|
|
|
2015-05-31 05:10:40 +00:00
|
|
|
public void clear() {
|
|
|
|
if (isContextValid()) Glide.clear(this);
|
|
|
|
}
|
|
|
|
|
2015-08-24 22:24:31 +00:00
|
|
|
public void hideControls(boolean hideControls) {
|
|
|
|
this.hideControls = hideControls;
|
|
|
|
if (hideControls) hideProgressWheel();
|
2015-06-27 03:14:51 +00:00
|
|
|
}
|
|
|
|
|
2015-05-05 22:14:41 +00:00
|
|
|
@TargetApi(VERSION_CODES.JELLY_BEAN_MR1)
|
|
|
|
private boolean isContextValid() {
|
|
|
|
return !(getContext() instanceof Activity) ||
|
|
|
|
VERSION.SDK_INT < VERSION_CODES.JELLY_BEAN_MR1 ||
|
|
|
|
!((Activity)getContext()).isDestroyed();
|
|
|
|
}
|
|
|
|
|
2015-03-31 22:44:41 +00:00
|
|
|
private GenericRequestBuilder buildGlideRequest(@NonNull Slide slide,
|
|
|
|
@Nullable MasterSecret masterSecret)
|
|
|
|
{
|
|
|
|
final GenericRequestBuilder builder;
|
2015-06-27 03:14:51 +00:00
|
|
|
if (slide.getThumbnailUri() != null) {
|
2015-03-31 22:44:41 +00:00
|
|
|
builder = buildThumbnailGlideRequest(slide, masterSecret);
|
|
|
|
} else {
|
|
|
|
builder = buildPlaceholderGlideRequest(slide);
|
|
|
|
}
|
|
|
|
|
2015-08-24 22:24:31 +00:00
|
|
|
if (slide.isInProgress() && !hideControls) {
|
2015-06-27 03:14:51 +00:00
|
|
|
return builder;
|
|
|
|
} else {
|
|
|
|
return builder.error(R.drawable.ic_missing_thumbnail_picture);
|
|
|
|
}
|
2015-03-31 22:44:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private GenericRequestBuilder buildThumbnailGlideRequest(Slide slide, MasterSecret masterSecret) {
|
|
|
|
|
|
|
|
final GenericRequestBuilder builder;
|
2015-06-08 18:07:46 +00:00
|
|
|
if (slide.isDraft()) builder = buildDraftGlideRequest(slide, masterSecret);
|
|
|
|
else builder = buildPartGlideRequest(slide, masterSecret);
|
2015-03-31 22:44:41 +00:00
|
|
|
return builder;
|
|
|
|
}
|
|
|
|
|
2015-06-08 18:07:46 +00:00
|
|
|
private GenericRequestBuilder buildDraftGlideRequest(Slide slide, MasterSecret masterSecret) {
|
|
|
|
final DrawableTypeRequest<?> request;
|
|
|
|
if (masterSecret == null) request = Glide.with(getContext()).load(slide.getThumbnailUri());
|
|
|
|
else request = Glide.with(getContext()).load(new DecryptableUri(masterSecret, slide.getThumbnailUri()));
|
2015-04-16 05:38:33 +00:00
|
|
|
|
2015-07-15 20:42:59 +00:00
|
|
|
return request.transform(new RoundedCorners(getContext(), false, radius, backgroundColorHint))
|
2015-06-08 18:07:46 +00:00
|
|
|
.listener(new PduThumbnailSetListener(slide.getPart()));
|
2015-04-16 05:38:33 +00:00
|
|
|
}
|
|
|
|
|
2015-06-08 18:07:46 +00:00
|
|
|
private GenericRequestBuilder buildPartGlideRequest(Slide slide, MasterSecret masterSecret) {
|
2015-03-31 22:44:41 +00:00
|
|
|
if (masterSecret == null) {
|
|
|
|
throw new IllegalStateException("null MasterSecret when loading non-draft thumbnail");
|
|
|
|
}
|
|
|
|
|
2015-07-15 20:42:59 +00:00
|
|
|
return Glide.with(getContext()).load(new DecryptableUri(masterSecret, slide.getThumbnailUri()))
|
|
|
|
.crossFade()
|
|
|
|
.transform(new RoundedCorners(getContext(), true, radius, backgroundColorHint));
|
2015-03-31 22:44:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private GenericRequestBuilder buildPlaceholderGlideRequest(Slide slide) {
|
|
|
|
return Glide.with(getContext()).load(slide.getPlaceholderRes(getContext().getTheme()))
|
2015-07-16 00:31:02 +00:00
|
|
|
.asBitmap()
|
|
|
|
.fitCenter();
|
2015-03-31 22:44:41 +00:00
|
|
|
}
|
|
|
|
|
2015-06-27 03:14:51 +00:00
|
|
|
private void animateOutProgress() {
|
2015-07-30 22:02:20 +00:00
|
|
|
if (progress == null) return;
|
2015-06-27 03:14:51 +00:00
|
|
|
AlphaAnimation animation = new AlphaAnimation(1f, 0f);
|
|
|
|
animation.setDuration(200);
|
|
|
|
animation.setAnimationListener(new AnimationListener() {
|
|
|
|
@Override public void onAnimationStart(Animation animation) { }
|
|
|
|
@Override public void onAnimationRepeat(Animation animation) { }
|
|
|
|
@Override public void onAnimationEnd(Animation animation) {
|
2015-07-30 22:02:20 +00:00
|
|
|
getProgressWheel().setVisibility(View.GONE);
|
2015-06-27 03:14:51 +00:00
|
|
|
}
|
|
|
|
});
|
2015-07-30 22:02:20 +00:00
|
|
|
getProgressWheel().startAnimation(animation);
|
2015-06-27 03:14:51 +00:00
|
|
|
}
|
|
|
|
|
2015-03-31 22:44:41 +00:00
|
|
|
private class SlideDeckListener implements FutureTaskListener<SlideDeck> {
|
|
|
|
private final MasterSecret masterSecret;
|
|
|
|
|
|
|
|
public SlideDeckListener(MasterSecret masterSecret) {
|
|
|
|
this.masterSecret = masterSecret;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSuccess(final SlideDeck slideDeck) {
|
|
|
|
if (slideDeck == null) return;
|
|
|
|
|
2015-08-10 16:33:57 +00:00
|
|
|
final Slide slide = slideDeck.getThumbnailSlide();
|
|
|
|
|
2015-03-31 22:44:41 +00:00
|
|
|
if (slide != null) {
|
2015-06-27 03:14:51 +00:00
|
|
|
Util.runOnMain(new Runnable() {
|
2015-03-31 22:44:41 +00:00
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
setImageResource(slide, masterSecret);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
2015-06-27 03:14:51 +00:00
|
|
|
Util.runOnMain(new Runnable() {
|
2015-03-31 22:44:41 +00:00
|
|
|
@Override
|
|
|
|
public void run() {
|
2015-05-18 15:38:48 +00:00
|
|
|
Log.w(TAG, "Resolved slide was null!");
|
|
|
|
setVisibility(View.GONE);
|
2015-03-31 22:44:41 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onFailure(Throwable error) {
|
|
|
|
Log.w(TAG, error);
|
2015-06-27 03:14:51 +00:00
|
|
|
Util.runOnMain(new Runnable() {
|
2015-03-31 22:44:41 +00:00
|
|
|
@Override
|
|
|
|
public void run() {
|
2015-05-18 15:38:48 +00:00
|
|
|
Log.w(TAG, "onFailure!");
|
|
|
|
setVisibility(View.GONE);
|
2015-03-31 22:44:41 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public interface ThumbnailClickListener {
|
|
|
|
void onClick(View v, Slide slide);
|
|
|
|
}
|
|
|
|
|
2015-08-12 23:22:08 +00:00
|
|
|
private static class ThumbnailClickDispatcher implements View.OnClickListener {
|
2015-03-31 22:44:41 +00:00
|
|
|
private ThumbnailClickListener listener;
|
|
|
|
private Slide slide;
|
|
|
|
|
|
|
|
public ThumbnailClickDispatcher(ThumbnailClickListener listener, Slide slide) {
|
|
|
|
this.listener = listener;
|
|
|
|
this.slide = slide;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onClick(View view) {
|
2015-09-07 03:20:01 +00:00
|
|
|
if (listener != null)
|
|
|
|
{
|
2015-04-23 18:33:34 +00:00
|
|
|
listener.onClick(view, slide);
|
|
|
|
}
|
2015-03-31 22:44:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-30 22:02:20 +00:00
|
|
|
private class PduThumbnailSetListener implements RequestListener<Object, GlideDrawable> {
|
2015-03-31 22:44:41 +00:00
|
|
|
private PduPart part;
|
|
|
|
|
|
|
|
public PduThumbnailSetListener(@NonNull PduPart part) {
|
|
|
|
this.part = part;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-07-15 20:42:59 +00:00
|
|
|
public boolean onException(Exception e, Object model, Target<GlideDrawable> target, boolean isFirstResource) {
|
2015-03-31 22:44:41 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-07-15 20:42:59 +00:00
|
|
|
public boolean onResourceReady(GlideDrawable resource, Object model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
|
|
|
|
if (resource instanceof GlideBitmapDrawable) {
|
|
|
|
Log.w(TAG, "onResourceReady() for a Bitmap. Saving.");
|
|
|
|
part.setThumbnail(((GlideBitmapDrawable)resource).getBitmap());
|
|
|
|
}
|
2015-07-30 22:02:20 +00:00
|
|
|
if (resource.getIntrinsicWidth() < resource.getIntrinsicHeight()) {
|
|
|
|
getRemoveButton().setPadding(0, 0, (getWidth() - resource.getIntrinsicWidth()) / 2, 0);
|
|
|
|
} else {
|
|
|
|
getRemoveButton().setPadding(0, (getHeight() - resource.getIntrinsicHeight()) / 2, 0, 0);
|
|
|
|
}
|
2015-03-31 22:44:41 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|