Giter Site home page Giter Site logo

stickyheader's People

Contributors

christophkaser avatar lycrachel avatar okornev avatar pankona avatar shuhart avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

stickyheader's Issues

item underneath header gets clicked

Hi,

The item underneath my header item gets clicked. If i scroll the list and if there is an item under the header item then whatever the function underneath item has get clicked. How do i resolve it ?

Possible extra header, and crash in sample app.

Hello,

I was playing around with the sample app you've provided and I noticed a quirk with the top header, along with a crash.

The first issue might be related to #4, but I did not see a full on extra header. Gif shown below.

https://i.imgur.com/BW2NiG9.gif

The second issue is the crash. Playing with the sample app, if you go a little crazy scrolling up and down, the following crash happens.

2019-05-22 19:59:58.346 27441-27441/com.shuhart.stickyheader.sample E/AndroidRuntime: FATAL EXCEPTION: main Process: com.shuhart.stickyheader.sample, PID: 27441 java.lang.ArrayIndexOutOfBoundsException: length=33; index=-1 at java.util.ArrayList.get(ArrayList.java:439) at com.shuhart.stickyheader.sample.SectionAdapter.getHeaderPositionForItem(SectionAdapter.java:53) at com.shuhart.stickyheader.StickyHeaderItemDecorator.onDrawOver(StickyHeaderItemDecorator.java:81) at android.support.v7.widget.RecyclerView.draw(RecyclerView.java:4017) at android.view.View.updateDisplayListIfDirty(View.java:19082) at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4317) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4290) at android.view.View.updateDisplayListIfDirty(View.java:19042) at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4317) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4290) at android.view.View.updateDisplayListIfDirty(View.java:19042) <Repeats many more times>

how to hide header?

I want to hide header if there is only one section in list but i am not able to fine any way to do this, if I hide main view of header then some space still there.

Sticky header causes glitches if RecyclerView's child item has mergin or divider

Hello!

I've tried this library and the sample codes worked as I expected. That's great!

However, I noticed that if the items held by RecyclerView has margin (represented as android:marginTop/Bottom) or divider (that is provided by using DividerItemDecoration), sticky header causes glitches if the margin/divider part contacts to the header.

I dived into the implementation, I guess following part should be corrected not to return but continue to latter part.

    // Here're methods in StickyHeaderItemDecorator.java

    public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {

        // omit former part

        View viewOverlappedByHeader = getChildInContact(parent, currentStickyHolder.itemView.getBottom());
        if (viewOverlappedByHeader == null) {
            // ****** if return here, sticky header disappeared. ******
            return;
        }

        // omit latter part
    }

    // "margin" or "divider" contacts to the sticky header, this method probably return null.
    private View getChildInContact(RecyclerView parent, int contactPoint) {
        View childInContact = null;
        for (int i = 0; i < parent.getChildCount(); i++) {
            View child = parent.getChildAt(i);
            if (child.getBottom() > contactPoint) {
                if (child.getTop() <= contactPoint) {
                    // This child overlaps the contactPoint
                    childInContact = child;
                    break;
                }
            }
        }
        return childInContact;
    }

I think this is not expected behavior of this library. How do you think?

If getChildInContact returns null, I guess onDrawOver should not return then but should continue to proceed with a view that is "last contacted".

Just my idea, onDrawOver method should be like this:

// prepare a view represents "last contacted"
private View lastViewOverlappedByHeader = null;

public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {

    // omit former part

    View viewOverlappedByHeader = getChildInContact(parent,     currentStickyHolder.itemView.getBottom());
    if (viewOverlappedByHeader == null) {
        // continue processing with "last contacted"
        if (lastViewOverlappedByHeader != null) {
            viewOverlappedByHeader = lastViewOverlappedByHeader;
        } else {
            return;
        }
    }

    // omit latter part
}

If you can agree, I'll try to create a pull request for this issue. Please let me know.
Thanks!

Adding a padding to the top of the RecyclerView adds another header

I have a RecyclerView that uses the library, adding a paddingTop and clipToPadding = false, adds an unwanted header to the top

<androidx.recyclerview.widget.RecyclerView
            android:id="@+id/countriesList"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:paddingTop="30dp"
            android:clipToPadding="false"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            tools:listitem="@layout/country_list_item">
</androidx.recyclerview.widget.RecyclerView>

Screen Shot 2019-05-14 at 14 00 59

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.