Skip to content

Commit

Permalink
1、修复mOnePageSize某些情况下值为0的问题;
Browse files Browse the repository at this point in the history
v1.1.7
  • Loading branch information
ShenBen committed Jun 19, 2022
1 parent 385b24b commit 94887f0
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 76 deletions.
1 change: 0 additions & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion pagergridlayoutmanager/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ afterEvaluate {
// You can then customize attributes of the publication as shown below.
groupId = 'com.shencoder'
artifactId = 'pagergridlayoutmanager'
version = '1.1.6'
version = '1.1.7'
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,6 @@ public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State
mEndSnapRect.set(getWidth() - getPaddingEnd() - mItemWidth, getHeight() - getPaddingBottom() - mItemHeight, getWidth() - getPaddingEnd(), getHeight() - getPaddingBottom());
}

mOnePageSize = mRows * mColumns;

//计算总页数
int pagerCount = itemCount / mOnePageSize;
if (itemCount % mOnePageSize != 0) {
Expand Down Expand Up @@ -585,6 +583,7 @@ public void onRestoreInstanceState(Parcelable state) {
mOrientation = savedState.mOrientation;
mRows = savedState.mRows;
mColumns = savedState.mColumns;
calculateOnePageSize();
setCurrentPagerIndex(savedState.mCurrentPagerIndex);
mReverseLayout = savedState.mReverseLayout;
requestLayout();
Expand Down Expand Up @@ -766,9 +765,17 @@ public final int getItemHeight() {
return mItemHeight;
}

/**
* 计算一页的数量
*/
private void calculateOnePageSize() {
mOnePageSize = mRows * mColumns;
}

/**
* @return 一页的数量
*/
@IntRange(from = 1)
public final int getOnePageSize() {
return mOnePageSize;
}
Expand All @@ -782,6 +789,7 @@ public void setColumns(@IntRange(from = 1) int columns) {
mColumns = Math.max(columns, 1);
mPagerCount = NO_PAGER_COUNT;
mCurrentPagerIndex = NO_ITEM;
calculateOnePageSize();
requestLayout();
}

Expand All @@ -802,6 +810,7 @@ public void setRows(@IntRange(from = 1) int rows) {
mRows = Math.max(rows, 1);
mPagerCount = NO_PAGER_COUNT;
mCurrentPagerIndex = NO_ITEM;
calculateOnePageSize();
requestLayout();
}

Expand Down

0 comments on commit 94887f0

Please sign in to comment.