Skip to content

Commit

Permalink
Merge pull request #4 from TSurkis/recyclerview_no_adapter_crash_fix
Browse files Browse the repository at this point in the history
Crash fix
  • Loading branch information
TSurkis authored Mar 17, 2019
2 parents 456739d + b509869 commit 6cea69c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ dependencies {
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation "com.android.support:recyclerview-v7:28.0.0"

implementation 'com.github.tsurkis:timdicator:1.2.2'
implementation 'com.github.tsurkis:timdicator:1.2.3'
}
2 changes: 1 addition & 1 deletion timdicator/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {
minSdkVersion 14
targetSdkVersion 28
versionCode 7
versionName "1.2.2"
versionName "1.2.3"
}

buildTypes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ public static TimdicatorViewPagerBinder attachViewPagerDynamically(@NonNull Timd
return timdicatorViewPagerBinder;
}

public static TimdicatorRecyclerViewBinder attachRecyclerView(@NonNull Timdicator timdicator, @NonNull RecyclerView recyclerView, @NonNull SnapHelper snapHelper, boolean isHorizontal) {
public static void attachRecyclerView(@NonNull Timdicator timdicator, @NonNull RecyclerView recyclerView, @NonNull SnapHelper snapHelper, boolean isHorizontal) {
TimdicatorRecyclerViewBinder timdicatorRecyclerViewBinder = new TimdicatorRecyclerViewBinder();
timdicatorRecyclerViewBinder.attach(timdicator, recyclerView, snapHelper, isHorizontal);
return timdicatorRecyclerViewBinder;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,18 @@ private void updateTimdicator(int newNumberOfCircles) {
}
};

public void attach(@NonNull Timdicator timdicator, @NonNull RecyclerView recyclerView, @NonNull SnapHelper snapHelper, boolean isHorizontal) {
void attach(@NonNull Timdicator timdicator, @NonNull RecyclerView recyclerView, @NonNull SnapHelper snapHelper, boolean isHorizontal) {
attach(timdicator, recyclerView, snapHelper, isHorizontal, recyclerView.getAdapter() != null ? recyclerView.getAdapter().getItemCount() : 0);
}

public void attach(@NonNull Timdicator timdicator, @NonNull RecyclerView recyclerView, @NonNull SnapHelper snapHelper, boolean isHorizontal, int initialIndex) {
void attach(@NonNull Timdicator timdicator, @NonNull RecyclerView recyclerView, @NonNull SnapHelper snapHelper, boolean isHorizontal, int initialIndex) {
this.timdicator = timdicator;
this.recyclerView = recyclerView;
this.snapHelper = snapHelper;
this.isHorizontal = isHorizontal;
recyclerView.addOnScrollListener(scrollListener);
if (recyclerView.getAdapter() != null) {
recyclerView.getAdapter().registerAdapterDataObserver(recyclerViewChangesObserver);
timdicator.setNumberOfCircles(recyclerView.getAdapter().getItemCount());
timdicator.requestLayout();
}
Expand All @@ -106,7 +107,6 @@ public void attach(@NonNull Timdicator timdicator, @NonNull RecyclerView recycle
if (isReversed) {
timdicator.setIndex(initialIndex);
}
recyclerView.getAdapter().registerAdapterDataObserver(recyclerViewChangesObserver);
}

@Override
Expand Down

0 comments on commit 6cea69c

Please sign in to comment.