Created
July 24, 2014 21:26
-
-
Save slightfoot/fe35ce1fc3fde7daa0d6 to your computer and use it in GitHub Desktop.
Picasso RecyclerView ScrollListener
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
PicassoFlingScrollListener is no more available with Picasso library. Was it replaced with some other listener?