Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slightfoot/fe35ce1fc3fde7daa0d6 to your computer and use it in GitHub Desktop.
Save slightfoot/fe35ce1fc3fde7daa0d6 to your computer and use it in GitHub Desktop.
Picasso RecyclerView ScrollListener
import android.support.v7.widget.RecyclerView;
import com.squareup.picasso.Picasso;
import com.squareup.picasso.scrolling.PicassoFlingScrollListener;
/**
* Example Use:
* mRecyclerView.setOnScrollListener(new PicassoRecyclerViewScrollListener(mPicasso));
*
* @author Simon Lightfoot <simon@demondevelopers.com>
*
*/
public static class PicassoRecyclerViewScrollListener implements RecyclerView.OnScrollListener
{
private final PicassoFlingScrollListener mListener;
private final RecyclerView.OnScrollListener mDelegate;
public PicassoRecyclerViewScrollListener(Picasso picasso)
{
this(picasso, null);
}
public PicassoRecyclerViewScrollListener(Picasso picasso, RecyclerView.OnScrollListener delegate)
{
mListener = new PicassoFlingScrollListener(picasso);
mDelegate = delegate;
}
@Override
public void onScrollStateChanged(int newState)
{
mListener.onScrollStateChanged(null, newState);
if(mDelegate != null){
mDelegate.onScrollStateChanged(newState);
}
}
@Override
public void onScrolled(int dx, int dy)
{
if(mDelegate != null){
mDelegate.onScrolled(dx, dy);
}
}
}
@sravanco
Copy link

sravanco commented Feb 5, 2015

PicassoFlingScrollListener is no more available with Picasso library. Was it replaced with some other listener?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment