Giter Club home page Giter Club logo

Comments (9)

joakim5937x avatar joakim5937x commented on August 20, 2024

Is there any workarounds to get the scroll position? The thing i need is to know when the list is scrolled to the bottom so I can load new data.

from staggeredgridview.

david90 avatar david90 commented on August 20, 2024

Here's how I tried to tackle the problem

First ,add a private instance :

private AbsListView.OnScrollListener mOnScrollListener;

Add public setOnClickListener method :

public void setOnScrollListener (AbsListView.OnScrollListener l) {
    mOnScrollListener = l;
}

Then, in trackMotionScroll , add lines of codes to invoke the listener

private boolean trackMotionScroll(int deltaY, boolean allowOverScroll) {
.
.
.

  /* HERE we call onScroll */
    if (mOnScrollListener != null) {
        mOnScrollListener.onScroll(null, getFirstPosition(), getChildCount(), this.mItemCount);
    }

    return deltaY == 0 || movedBy != 0;
}

You can also implement your own onScrollStateChanged (AbsListView view, int scrollState) method, but I am too lazy to do so :P

Finally you can call gridView.setOnScrollListener(listener) to pass in a listener to StaggeredGridView

Hope it helps.

from staggeredgridview.

GoMino avatar GoMino commented on August 20, 2024

I added the support in my version https://github.com/GoMino/StaggeredGridView, I still need to merge the code with this version of the StaggeredGridView, I based mine on the original one in the support library.

from staggeredgridview.

joakim5937x avatar joakim5937x commented on August 20, 2024

Does this fix the setscroll ?

from staggeredgridview.

GoMino avatar GoMino commented on August 20, 2024

It works exactly the same as any other scroll listener:

private OnScrollListener    mScrollListener = new OnScrollListener() {

    @Override
    public void onScrollStateChanged(ViewGroup view, int scrollState) {
        Log.d(TAG, "[onScrollStateChanged] scrollState:" + scrollState);
        switch (scrollState) {
        case SCROLL_STATE_IDLE:
            break;

        case SCROLL_STATE_FLING:
            break;

        case SCROLL_STATE_TOUCH_SCROLL:
            break;

        default:
            break;
        }

    }

    @Override
    public void onScroll(ViewGroup view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
        Log.d(TAG, "[onScroll] firstVisibleItem:" + firstVisibleItem + " visibleItemCount:"+visibleItemCount + " totalItemCount:" + totalItemCount);

    }
};

then you set the listener via youStaggeredGridView.setOnScrollListener(mScrollListener), and you will get notified!

from staggeredgridview.

joakim5937x avatar joakim5937x commented on August 20, 2024

What I mean is does the setScrollY or scrollTo function work, course if i try i use it i just get weird results.

from staggeredgridview.

GoMino avatar GoMino commented on August 20, 2024

I remember getting a similar issue when I used that version of the StaggeredGridView, that is why I decided to rebase my work on the original one from the support library which doesn't have the problem, I would suggest you to try it out and let me know if you got any problem with it

from staggeredgridview.

joakim5937x avatar joakim5937x commented on August 20, 2024

where do i find the original and what is the downsides with using that one?
Edit: Didn't read properly will try your library!

from staggeredgridview.

feliperohde avatar feliperohde commented on August 20, 2024

I can get how many pixels I moved?

from staggeredgridview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.