Skip to content

Commit 6bcda4f

Browse files
author
jxnk25
committed
fix bug
1 parent 17f1cb6 commit 6bcda4f

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

xbanner/src/main/java/com/stx/xhb/androidx/XBanner.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,11 @@ public void handleAutoPlayActionUpOrCancel(float xVelocity) {
789789
}
790790

791791
private int getRealPosition(int position) {
792-
return position % getRealCount();
792+
int realCount = getRealCount();
793+
if (realCount != 0) {
794+
return position % realCount;
795+
}
796+
return position;
793797
}
794798

795799
/**
@@ -1128,6 +1132,22 @@ public void setClipChildrenLeftRightMargin(@Dimension int mClipChildrenLeftMargi
11281132
this.mClipChildrenRightMargin = mClipChildrenRightMargin;
11291133
}
11301134

1135+
/**
1136+
* 是否显示提示文案
1137+
* @param mIsShowTips
1138+
*/
1139+
public void setIsShowTips(boolean mIsShowTips) {
1140+
this.mIsShowTips = mIsShowTips;
1141+
}
1142+
1143+
/**
1144+
* 低于三张图片是否展示一屏多显模式
1145+
* @param mIsClipChildrenModeLessThree
1146+
*/
1147+
public void setIsClipChildrenModeLessThree(boolean mIsClipChildrenModeLessThree) {
1148+
this.mIsClipChildrenModeLessThree = mIsClipChildrenModeLessThree;
1149+
}
1150+
11311151
@Override
11321152
protected void onVisibilityChanged(@NonNull View changedView, int visibility) {
11331153
super.onVisibilityChanged(changedView, visibility);
@@ -1206,6 +1226,9 @@ public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
12061226
@NonNull
12071227
@Override
12081228
public Object instantiateItem(@NonNull ViewGroup container, int position) {
1229+
if (getRealCount() == 0) {
1230+
return null;
1231+
}
12091232
final int realPosition = getRealPosition(position);
12101233
View itemView;
12111234
if (holderCreator == null) {

0 commit comments

Comments
 (0)