diff --git a/.idea/gradle.xml b/.idea/gradle.xml index b4c3469..5aacb98 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -15,7 +15,6 @@ - diff --git a/.idea/shelf/Uncommitted_changes_before_Update_at_2022_05_01_18_20_[Default_Changelist]/shelved.patch b/.idea/shelf/Uncommitted_changes_before_Update_at_2022_05_01_18_20_[Default_Changelist]/shelved.patch deleted file mode 100644 index 5e2e035..0000000 --- a/.idea/shelf/Uncommitted_changes_before_Update_at_2022_05_01_18_20_[Default_Changelist]/shelved.patch +++ /dev/null @@ -1,68 +0,0 @@ -Index: .idea/misc.xml -IDEA additional info: -Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP -<+>\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n -Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP -<+>UTF-8 -=================================================================== -diff --git a/.idea/misc.xml b/.idea/misc.xml ---- a/.idea/misc.xml (revision 4feb2f32478bc15cd7ac64849e18b32036254ca5) -+++ b/.idea/misc.xml (date 1647611244486) -@@ -8,6 +8,7 @@ - - - -+ - - - -Index: app/src/main/java/com/shencoder/demo/MyRelativeLayout.java -IDEA additional info: -Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP -<+>UTF-8 -=================================================================== -diff --git a/app/src/main/java/com/shencoder/demo/MyRelativeLayout.java b/app/src/main/java/com/shencoder/demo/MyRelativeLayout.java -new file mode 100644 ---- /dev/null (date 1647610998832) -+++ b/app/src/main/java/com/shencoder/demo/MyRelativeLayout.java (date 1647610998832) -@@ -0,0 +1,40 @@ -+package com.shencoder.demo; -+ -+import android.content.Context; -+import android.os.Build; -+import android.util.AttributeSet; -+import android.widget.RelativeLayout; -+ -+/** -+ * @author ShenBen -+ * @date 2022/03/18 21:33 -+ * @email 714081644@qq.com -+ */ -+public class MyRelativeLayout extends RelativeLayout { -+ public MyRelativeLayout(Context context) { -+ super(context); -+ } -+ -+ public MyRelativeLayout(Context context, AttributeSet attrs) { -+ super(context, attrs); -+ } -+ -+ public MyRelativeLayout(Context context, AttributeSet attrs, int defStyleAttr) { -+ super(context, attrs, defStyleAttr); -+ } -+ -+ @Override -+ public LayoutParams generateLayoutParams(AttributeSet attrs) { -+ LayoutParams layoutParams = super.generateLayoutParams(attrs); -+ System.out.println("generateLayoutParams--->" + layoutParams.width + "," + layoutParams.height); -+ -+ return layoutParams; -+ } -+ -+ @Override -+ protected void onLayout(boolean changed, int l, int t, int r, int b) { -+ -+ super.onLayout(changed, l, t, r, b); -+ -+ } -+} diff --git a/.idea/shelf/Uncommitted_changes_before_Update_at_2022_05_01_18_20__Default_Changelist_.xml b/.idea/shelf/Uncommitted_changes_before_Update_at_2022_05_01_18_20__Default_Changelist_.xml deleted file mode 100644 index f2e92e1..0000000 --- a/.idea/shelf/Uncommitted_changes_before_Update_at_2022_05_01_18_20__Default_Changelist_.xml +++ /dev/null @@ -1,4 +0,0 @@ - - \ No newline at end of file diff --git a/pagergridlayoutmanager/build.gradle b/pagergridlayoutmanager/build.gradle index 60f0737..1298d61 100644 --- a/pagergridlayoutmanager/build.gradle +++ b/pagergridlayoutmanager/build.gradle @@ -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' } } } diff --git a/pagergridlayoutmanager/src/main/java/com/shencoder/pagergridlayoutmanager/PagerGridLayoutManager.java b/pagergridlayoutmanager/src/main/java/com/shencoder/pagergridlayoutmanager/PagerGridLayoutManager.java index 9929cc2..0cf61df 100644 --- a/pagergridlayoutmanager/src/main/java/com/shencoder/pagergridlayoutmanager/PagerGridLayoutManager.java +++ b/pagergridlayoutmanager/src/main/java/com/shencoder/pagergridlayoutmanager/PagerGridLayoutManager.java @@ -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) { @@ -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(); @@ -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; } @@ -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(); } @@ -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(); }