Skip to content

Commit

Permalink
Fixed glide animation issue (view may not be properly attached to Win…
Browse files Browse the repository at this point in the history
…dow)
  • Loading branch information
alexvasilkov committed Oct 18, 2015
1 parent fe25bf0 commit 2ed639b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import android.view.ViewGroup;

import com.alexvasilkov.gestures.sample.logic.Painting;
import com.alexvasilkov.gestures.sample.utils.glide.GlideHelper;
import com.alexvasilkov.gestures.views.GestureImageView;
import com.alexvasilkov.gestures.views.interfaces.GestureView;
import com.alexvasilkov.gestures.views.utils.RecyclePagerAdapter;
import com.bumptech.glide.Glide;

public class PaintingsImagesAdapter extends RecyclePagerAdapter<PaintingsImagesAdapter.ViewHolder> {

Expand Down Expand Up @@ -39,9 +39,7 @@ public ViewHolder onCreateViewHolder(@NonNull ViewGroup container) {
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
if (mSetupListener != null) mSetupListener.onSetupGestureView(holder.image);
holder.image.getController().resetState();

Glide.with(holder.image.getContext())
.load(mPaintings[position].getImageId()).into(holder.image);
GlideHelper.loadResource(mPaintings[position].getImageId(), holder.image);
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.alexvasilkov.gestures.sample.adapters;

import android.content.Context;
import android.graphics.Typeface;
import android.support.annotation.NonNull;
import android.support.v4.view.ViewPager;
Expand All @@ -14,10 +13,10 @@
import com.alexvasilkov.android.commons.utils.Views;
import com.alexvasilkov.gestures.sample.R;
import com.alexvasilkov.gestures.sample.logic.Painting;
import com.alexvasilkov.gestures.sample.utils.glide.GlideHelper;
import com.alexvasilkov.gestures.views.GestureFrameLayout;
import com.alexvasilkov.gestures.views.interfaces.GestureView;
import com.alexvasilkov.gestures.views.utils.RecyclePagerAdapter;
import com.bumptech.glide.Glide;

public class PaintingsLayoutsAdapter extends RecyclePagerAdapter<PaintingsLayoutsAdapter.ViewHolder>
implements View.OnClickListener {
Expand Down Expand Up @@ -51,11 +50,9 @@ public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
if (mSetupListener != null) mSetupListener.onSetupGestureView(holder.layout);
holder.layout.getController().resetState();

Context context = holder.itemView.getContext();
GlideHelper.loadResource(mPaintings[position].getImageId(), holder.image);

Glide.with(context).load(mPaintings[position].getImageId()).into(holder.image);

CharSequence titleText = new SpannableBuilder(context)
CharSequence titleText = new SpannableBuilder(holder.itemView.getContext())
.createStyle().setFont(Typeface.DEFAULT_BOLD).apply()
.append(R.string.paintings_author).append("\n")
.clearStyle()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.alexvasilkov.gestures.sample.utils.glide;

import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.View;
Expand All @@ -22,6 +23,10 @@ public void animate(View view) {
};


public static void loadResource(@DrawableRes int drawableId, @NonNull ImageView image) {
Glide.with(image.getContext()).load(drawableId).animate(ANIMATOR).into(image);
}

public static void loadFlickrThumb(@Nullable Photo photo, @NonNull final ImageView image) {
Glide.with(image.getContext())
.load(photo == null ? null : photo.getMediumUrl())
Expand Down

0 comments on commit 2ed639b

Please sign in to comment.