Skip to content

Commit 028bbf8

Browse files
author
uis
committed
fxied one item swip cause crash
1 parent d66eb97 commit 028bbf8

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
![效果图](/pic/demo20.gif)
1010

1111
### Use
12-
implementation 'com.uis:stacklayout:0.1.0'
12+
implementation 'com.uis:stacklayout:0.1.1'
1313

1414
*Name*| *Descript*|*Value*
1515
-----|--------|---
@@ -88,8 +88,9 @@ stackEdgeModel|层叠位置|left/right
8888
*Version*| *Descript*|*Fixed*
8989
----|----|----
9090
0.0.1|自动轮播,滑动从顶部移除,整体上浮|初始版本
91-
0.0.2|滑动从顶层加入,整体下沉|内部view点击事件
91+
0.0.2|滑动从顶层加入,整体下沉|fixed 内部view点击事件
9292
0.1.0|zoomX,zoomY呈等比数列|更改属性
93+
0.1.1|只有一条数据时|fixed
9394

9495
### Thanks
9596

stacklayout/src/main/java/com/uis/stackview/StackHelper.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ void layoutChild(){
101101
if(needRelayout && layout != null) {
102102
needRelayout = false;
103103
int childSize = layout.getChildCount();
104-
int stackSize = layout.stackSize;
104+
int stackSize = layout.getRealStackSize();
105105
int realSize = layout.getRealStackSize();
106106
for (int i = 0; i < childSize; i++) {
107107
int top, bottom, left, right, pivot;
@@ -301,9 +301,10 @@ void setAutoPlay(boolean looper){
301301
/** 加入底层 */
302302
private void addBottomView(){
303303
int cnt = layout.getAdapter().getItemCount();
304+
int stackSize = layout.getRealStackSize();
304305
displayPosition += 1;
305306
displayPosition %= cnt;
306-
int index = (layout.stackSize - 1 + displayPosition) % cnt;
307+
int index = (stackSize - 1 + displayPosition) % cnt;
307308
View view = getStackView();
308309
layout.getAdapter().onBindView(view, index);
309310
needRelayout = true;

stacklayout/src/main/java/com/uis/stackview/StackLayout.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
7575
int width = getDefaultSize(getSuggestedMinimumWidth(), widthMeasureSpec);
7676
int height = MeasureSpec.EXACTLY != MeasureSpec.getMode(heightMeasureSpec) ? width/2
7777
: getDefaultSize(getSuggestedMinimumHeight(),heightMeasureSpec);
78+
if(!isInEditMode() && (adapter == null || adapter.getItemCount() == 0)){
79+
height = 0;
80+
}
7881
setMeasuredDimension(width,height);
7982
if(adapter != null) {
8083
stackHelper.measureChild(width,height);

0 commit comments

Comments
 (0)