There was an error while loading. Please reload this page.
2 parents 2220d9b + ab14435 commit 7003ffdCopy full SHA for 7003ffd
autoimageslider/src/main/java/com/smarteist/autoimageslider/InfiniteAdapter/InfinitePagerAdapter.java
@@ -57,10 +57,15 @@ public int getRealCount() {
57
* @return virtual mid point
58
*/
59
public int getMiddlePosition(int item) {
60
- int adapterCount = getRealCount() - 1;
61
- adapterCount = adapterCount == 0 ? 1 : adapterCount;
+ int realCount = getRealCount();
+ int adapterCount = realCount - 1 == 0 ? 1 : realCount - 1;
62
int midpoint = adapterCount * (InfinitePagerAdapter.INFINITE_SCROLL_LIMIT / 2);
63
- return item + midpoint;
+
64
+ if (realCount != 0 && midpoint % realCount != 0) {
65
+ return midpoint + (realCount - midpoint % realCount) + item;
66
+ } else {
67
+ return midpoint + item;
68
+ }
69
}
70
71
@NonNull
0 commit comments