Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

PinterestLikeAdapterView #4

Open
lordzden opened this issue Aug 30, 2013 · 1 comment
Open

PinterestLikeAdapterView #4

lordzden opened this issue Aug 30, 2013 · 1 comment
Labels

Comments

@lordzden
Copy link

Universal Image Loader has this feature that makes sure to avoid lag during scrolling, but the problem is PauseOnScrollListener can't be casted to MultiColumnListView or the .PLA_AbsListView.setOnScrollListener. Is there many way to have a work around on this?

https://github.com/huewu/PinterestLikeAdapterView/blob/master/src/com/huewu/pla/lib/internal/PLA_AbsListView.java

Universal_Image-Loader

PauseOnScrollListener.java
/**
* Constructor
*
* @param imageLoader {@linkplain ImageLoader} instance for controlling
* @param pauseOnScroll Whether {@linkplain ImageLoader#pause() pause ImageLoader} during touch scrolling
* @param pauseOnFling Whether {@linkplain ImageLoader#pause() pause ImageLoader} during fling
*/
public PauseOnScrollListener(ImageLoader imageLoader, boolean pauseOnScroll, boolean pauseOnFling) {
this(imageLoader, pauseOnScroll, pauseOnFling, null);
}

/**
 * Constructor
 *
 * @param imageLoader    {@linkplain ImageLoader} instance for controlling
 * @param pauseOnScroll  Whether {@linkplain ImageLoader#pause() pause ImageLoader} during touch scrolling
 * @param pauseOnFling   Whether {@linkplain ImageLoader#pause() pause ImageLoader} during fling
 * @param customListener Your custom {@link OnScrollListener} for {@linkplain AbsListView list view} which also will
 *                       be get scroll events
 */
public PauseOnScrollListener(ImageLoader imageLoader, boolean pauseOnScroll, boolean pauseOnFling, OnScrollListener customListener) {
    this.imageLoader = imageLoader;
    this.pauseOnScroll = pauseOnScroll;
    this.pauseOnFling = pauseOnFling;
    externalListener = customListener;
}

@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
    switch (scrollState) {
        case OnScrollListener.SCROLL_STATE_IDLE:
            imageLoader.resume();
            break;
        case OnScrollListener.SCROLL_STATE_TOUCH_SCROLL:
            if (pauseOnScroll) {
                imageLoader.pause();
            }
            break;
        case OnScrollListener.SCROLL_STATE_FLING:
            if (pauseOnFling) {
                imageLoader.pause();
            }
            break;
    }
    if (externalListener != null) {
        externalListener.onScrollStateChanged(view, scrollState);
    }
}

@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
    if (externalListener != null) {
        externalListener.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount);
    }
}

}

@mjurkus
Copy link

mjurkus commented Nov 8, 2013

Well, you have the code here. So just use PLA_AbsListView.setOnScrollListener and do pausing/resuming yourself.

@dalinaum dalinaum added the ready label Jul 28, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants