Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
shuhart committed Feb 22, 2018
1 parent 9ff594b commit 2ed7e86
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Usage
-----

1. Add jcenter() to repositories block in your gradle file.
2. Add `implementation 'com.shuhart.stickyheader:stickyheader:1.0.1'` to your dependencies.
2. Add `implementation 'com.shuhart.stickyheader:stickyheader:1.0.2` to your dependencies.
3. Look into the sample for additional details on how to use and configure the library.

You should provide an adapter that extends [StickyAdapter](https://github.com/shuhart/StickyHeader/blob/master/stickyheader/src/main/java/com/shuhart/stickyheader/StickyAdapter.java) to the StickyHeaderItemDecorator that is used to create and bind sticky headers.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import java.util.ArrayList;
import java.util.List;

public class SectionAdapter extends StickyHeaderItemDecorator.StickyAdapter<RecyclerView.ViewHolder, RecyclerView.ViewHolder> {
public class SectionAdapter extends StickyAdapter<RecyclerView.ViewHolder, RecyclerView.ViewHolder> {
List<Section> items = new ArrayList<>();

@Override
Expand Down Expand Up @@ -44,18 +44,18 @@ public int getItemCount() {
}

@Override
int getHeaderPositionForItem(int itemPosition) {
public int getHeaderPositionForItem(int itemPosition) {
return items.get(itemPosition).section();
}

@SuppressLint("SetTextI18n")
@Override
void onBindHeaderViewHolder(RecyclerView.ViewHolder holder, int headerPosition) {
public void onBindHeaderViewHolder(RecyclerView.ViewHolder holder, int headerPosition) {
((HeaderViewholder) holder).textView.setText("Header " + headerPosition);
}

@Override
RecyclerView.ViewHolder onCreateHeaderViewHolder(ViewGroup parent) {
public RecyclerView.ViewHolder onCreateHeaderViewHolder(ViewGroup parent) {
return createViewHolder(parent, Section.HEADER);
}

Expand Down
2 changes: 1 addition & 1 deletion stickyheader/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ext {
siteUrl = 'https://github.com/shuhart/StickyHeader'
gitUrl = 'https://github.com/shuhart/StickyHeader.git'

libraryVersion = '1.0.1'
libraryVersion = '1.0.2'

developerId = 'shuhart'
developerName = 'Redrick Shuhart'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public abstract class StickyAdapter<SVH extends RecyclerView.ViewHolder,
*
* @param itemPosition int. Adapter's position of the item for which to do
* the search of the position of the header item.
* @return int. Position of the header item in the adapter.
* @return int. Position of the header for an item in the adapter or
* {@link RecyclerView.NO_POSITION} (-1) if an item has no header.
*/
public abstract int getHeaderPositionForItem(int itemPosition);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state)
@SuppressWarnings("unchecked")
private void updateStickyHeader(int topChildPosition, int contactChildPosition) {
int headerPositionForItem = adapter.getHeaderPositionForItem(topChildPosition);
if (headerPositionForItem != currentStickyPosition) {
if (headerPositionForItem != currentStickyPosition && headerPositionForItem != RecyclerView.NO_POSITION) {
adapter.onBindHeaderViewHolder(currentStickyHolder, headerPositionForItem);
currentStickyPosition = headerPositionForItem;
} else if (contactChildPosition != RecyclerView.NO_POSITION) {
Expand Down

0 comments on commit 2ed7e86

Please sign in to comment.