Skip to content
This repository has been archived by the owner on Jan 6, 2020. It is now read-only.

Commit

Permalink
Merge branch 'release/2.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Bartosz Lipinski committed May 18, 2016
2 parents 3f8dc1d + 923c209 commit 9b5b7ab
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 110 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
Version 2.0.1 *(2016-05-18)*
----------------------------

* Fix: Scroll jump bug
* Fix: Header not displaying if there are no items in the adapter
* Headers exceeding `RecyclerView's` height (for vertical) or width (for horizontal) are no longer supported (you cannot scroll them if there's no items in the adapter)

Version 2.0.0 *(2016-04-06)*
----------------------------
RecyclerViewHeader 2 is a major release that focuses on fixing all of the previously reported issues.
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ You need to bare in mind that the library is created to be used with relatively
E.g. if your header uses a complex layout (with multiple scrolls and focusable elements) or a complicated `Touch` management system I advice you not to use `RecyclerViewHeader`, but a proper `RecyclerView` `Adapter` that incorporates inflating multiple types of views.
There are other libraries on github (for example [HeaderRecyclerView by Karumi][1]) that might seem a bit more complicated to use, but are implementing mentioned approach and will fit your needs better.

TLDR:

1. Simple header
2. Header smaller than screen height (for vertical `RecyclerView`) or width (for horizontal `RecyclerView`)
3. No complicated touch system (including vertical scrolling elements)

On version 2
------------
I created this library back in the day when I thought `RecyclerView` was all new and difficult. Writing an adapter that could inflate multiple types of `Views` seemed like a difficult job to do.
Expand Down Expand Up @@ -93,7 +99,7 @@ You can grab the library via Maven Central. Just add a proper dependency inside

```xml
dependencies {
compile 'com.bartoszlipinski:recyclerviewheader2:2.0.0'
compile 'com.bartoszlipinski:recyclerviewheader2:2.0.1'
}
```

Expand Down
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ ext {
buildToolsVersion: "23.0.2",
minSdk : 11,
targetSdk : 23,
versionCode : 6,
versionName : "2.0.0"
versionCode : 7,
versionName : "2.0.1"
]

libraries = [
support: "23.2.1",
support: "23.4.0",
]
}

Expand All @@ -20,7 +20,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.android.tools.build:gradle:2.1.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
VERSION_NAME=2.0.0
VERSION_CODE=6
VERSION_NAME=2.0.1
VERSION_CODE=7
GROUP=com.bartoszlipinski

POM_DESCRIPTION=Super fast and easy way to create header for Android RecyclerView
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Apr 10 15:27:10 PDT 2013
#Wed May 18 10:14:31 CEST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public final void detach() {
}

private void onScrollChanged() {
hidden = !layoutManager.isFirstRowVisible();
hidden = recyclerView.hasItems() && !layoutManager.isFirstRowVisible();
RecyclerViewHeader.super.setVisibility(hidden ? INVISIBLE : intendedVisibility);
if (!hidden) {
final int translation = calculateTranslation();
Expand Down Expand Up @@ -160,7 +160,7 @@ protected final void onLayout(boolean changed, int l, int t, int r, int b) {
@CallSuper
public boolean onInterceptTouchEvent(MotionEvent ev) {
recyclerWantsTouch = isAttachedToRecycler && recyclerView.onInterceptTouchEvent(ev);
if (recyclerWantsTouch && ev.getAction() == MotionEvent.ACTION_DOWN) {
if (recyclerWantsTouch && ev.getAction() == MotionEvent.ACTION_MOVE) {
downTranslation = calculateTranslation();
}
return recyclerWantsTouch || super.onInterceptTouchEvent(ev);
Expand Down Expand Up @@ -270,6 +270,10 @@ public final int getTranslationBase(boolean isVertical) {
recyclerView.computeHorizontalScrollRange() - recyclerView.getWidth();
}

public final boolean hasItems() {
return recyclerView.getAdapter() != null && recyclerView.getAdapter().getItemCount() != 0;
}

public final void setHeaderDecoration(HeaderItemDecoration decoration) {
clearHeaderDecoration();
this.decoration = decoration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,14 @@
import com.bartoszlipinski.recyclerviewheader2.sample.R;
import com.bartoszlipinski.recyclerviewheader2.sample.fragment.SampleGridFragment;
import com.bartoszlipinski.recyclerviewheader2.sample.fragment.SampleListFragment;
import com.bartoszlipinski.recyclerviewheader2.sample.fragment.SampleListHugeHeaderFragment;
import com.bartoszlipinski.recyclerviewheader2.sample.fragment.SampleListReversedFragment;

/**
* Created by Bartosz Lipinski
* 01.02.15
*/
public class MainActivity extends FragmentActivity {
public static final int FRAGMENT_COUNT = 4;
public static final int FRAGMENT_COUNT = 3;
private ViewPager viewPager;

@Override
Expand Down Expand Up @@ -64,7 +63,7 @@ public Fragment getItem(int position) {
case 2:
return SampleListReversedFragment.newInstance();
default:
return SampleListHugeHeaderFragment.newInstance();
return SampleListFragment.newInstance();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
private void setupViews(View view) {
recycler = (RecyclerView) view.findViewById(R.id.recycler);
recycler.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
recycler.setAdapter(new ColorItemsAdapter(getActivity(), 21));
recycler.setAdapter(new ColorItemsAdapter(getActivity(), 12));

recyclerHeader = (RecyclerViewHeader) view.findViewById(R.id.header);
recyclerHeader.attachTo(recycler);
Expand Down

This file was deleted.

35 changes: 0 additions & 35 deletions sample/src/main/res/layout/fragment_sample_huge_header.xml

This file was deleted.

0 comments on commit 9b5b7ab

Please sign in to comment.