Skip to content

Commit 24aaefd

Browse files
authored
Merge pull request smarteist#172 from smarteist/dev
bugs fixed.
2 parents 04932f2 + 2dbdfa5 commit 24aaefd

File tree

3 files changed

+6
-12
lines changed

3 files changed

+6
-12
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This is an amazing image slider for the Android .
1010
You can easily load images with your custom layout, and there are many kinds of amazing animations you can choose.
1111

1212
```groovy
13-
implementation 'com.github.smarteist:autoimageslider:1.3.9'
13+
implementation 'com.github.smarteist:autoimageslider:1.4.0'
1414
```
1515
If you are using appcompat libraries use this one, but please migrate to androidx as soon as you can.
1616
```groovy
@@ -220,7 +220,7 @@ here is an example for adapter implementation :
220220

221221
## Set the adapter to the Sliderview
222222

223-
After the instantiating of the sliderView (inside the activity or fragment with findViewById|BindView blah blah...), set the adapter to the slider.
223+
After the instantiating of the sliderView (inside the activity or fragment with findViewById|BindView...), set the adapter to the slider.
224224

225225
```java
226226
SliderView sliderView = findViewById(R.id.imageSlider);

autoimageslider/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ ext {
1515
siteUrl = 'https://github.com/smarteist'
1616
gitUrl = 'https://github.com/smarteist/android-image-slider.git'
1717

18-
libraryVersion = '1.3.9'
18+
libraryVersion = '1.4.0'
1919
organization = 'smarteistbintray' // if you push to organization's repository.
2020
developerId = 'smarteist'
2121
developerName = 'Ali Hosseini'

autoimageslider/src/main/java/com/smarteist/autoimageslider/InfiniteAdapter/InfinitePagerAdapter.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import android.database.DataSetObserver;
44
import android.os.Parcelable;
5+
import android.util.Log;
56
import android.view.View;
67
import android.view.ViewGroup;
78

@@ -57,15 +58,8 @@ public int getRealCount() {
5758
* @return virtual mid point
5859
*/
5960
public int getMiddlePosition(int item) {
60-
int realCount = getRealCount();
61-
int adapterCount = realCount - 1 == 0 ? 1 : realCount - 1;
62-
int midpoint = adapterCount * (InfinitePagerAdapter.INFINITE_SCROLL_LIMIT / 2);
63-
64-
if (realCount != 0 && midpoint % realCount != 0) {
65-
return midpoint + (realCount - midpoint % realCount) + item;
66-
} else {
67-
return midpoint + item;
68-
}
61+
int midpoint = Math.max(0, getRealCount()) * (InfinitePagerAdapter.INFINITE_SCROLL_LIMIT / 2);
62+
return item + midpoint;
6963
}
7064

7165
@NonNull

0 commit comments

Comments
 (0)