Skip to content

Commit 9c100f6

Browse files
author
Nedyalko Nikolov
committed
Merge pull request #1 from NativeScript/nnikolov/WrapLayoutWrongPaddings
Fixed issue #360.
2 parents aee834c + 71bf6f5 commit 9c100f6

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

src/org/nativescript/widgets/WrapLayout.java

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class WrapLayout extends LayoutBase {
1616
private int _itemWidth = -1;
1717
private int _itemHeight = -1;
1818
private Orientation _orientation = Orientation.horzontal;
19-
private ArrayList<Integer> _lenghts = new ArrayList<Integer>();
19+
private ArrayList<Integer> _lengths = new ArrayList<Integer>();
2020

2121
public WrapLayout(Context context) {
2222
super(context);
@@ -82,9 +82,9 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
8282

8383
int count = this.getChildCount();
8484

85-
this._lenghts.clear();
85+
this._lengths.clear();
8686
int rowOrColumn = 0;
87-
int maxLenght = 0;
87+
int maxLength = 0;
8888

8989
for (int i = 0; i < count; i++) {
9090
View child = this.getChildAt(i);
@@ -99,10 +99,10 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
9999
if (isVertical) {
100100
if (childMeasuredHeight > remainingHeight) {
101101
rowOrColumn++;
102-
maxLenght = Math.max(maxLenght, measureHeight);
102+
maxLength = Math.max(maxLength, measureHeight);
103103
measureHeight = childMeasuredHeight;
104104
remainingWidth = height - childMeasuredHeight;
105-
this._lenghts.add(rowOrColumn, childMeasuredWidth);
105+
this._lengths.add(rowOrColumn, childMeasuredWidth);
106106
}
107107
else {
108108
remainingHeight -= childMeasuredHeight;
@@ -112,36 +112,36 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
112112
else {
113113
if (childMeasuredWidth > remainingWidth) {
114114
rowOrColumn++;
115-
maxLenght = Math.max(maxLenght, measureWidth);
115+
maxLength = Math.max(maxLength, measureWidth);
116116
measureWidth = childMeasuredWidth;
117117
remainingWidth = width - childMeasuredWidth;
118-
this._lenghts.add(rowOrColumn, childMeasuredHeight);
118+
this._lengths.add(rowOrColumn, childMeasuredHeight);
119119
}
120120
else {
121121
remainingWidth -= childMeasuredWidth;
122122
measureWidth += childMeasuredWidth;
123123
}
124124
}
125125

126-
if(this._lenghts.size() <= rowOrColumn) {
127-
this._lenghts.add(rowOrColumn, isVertical ? childMeasuredWidth : childMeasuredHeight);
126+
if(this._lengths.size() <= rowOrColumn) {
127+
this._lengths.add(rowOrColumn, isVertical ? childMeasuredWidth : childMeasuredHeight);
128128
}
129129
else {
130-
this._lenghts.set(rowOrColumn, Math.max(this._lenghts.get(rowOrColumn), isVertical ? childMeasuredWidth : childMeasuredHeight));
130+
this._lengths.set(rowOrColumn, Math.max(this._lengths.get(rowOrColumn), isVertical ? childMeasuredWidth : childMeasuredHeight));
131131
}
132132
}
133133

134-
count = this._lenghts.size();
134+
count = this._lengths.size();
135135
if (isVertical) {
136-
measureHeight = Math.max(maxLenght, measureHeight);
136+
measureHeight = Math.max(maxLength, measureHeight);
137137
for (int i = 0; i < count; i++) {
138-
measureWidth += this._lenghts.get(i);
138+
measureWidth += this._lengths.get(i);
139139
}
140140
}
141141
else {
142-
measureWidth = Math.max(maxLenght, measureWidth);
142+
measureWidth = Math.max(maxLength, measureWidth);
143143
for (int i = 0; i < count; i++) {
144-
measureHeight += this._lenghts.get(i);
144+
measureHeight += this._lengths.get(i);
145145
}
146146
}
147147

@@ -170,7 +170,7 @@ protected void onLayout(boolean changed, int left, int top, int right, int botto
170170

171171
int childLeft = paddingLeft;
172172
int childTop = paddingTop;
173-
int childrenLength = isVertical ? bottom - top - (paddingRight + paddingBottom) : right - left - (paddingLeft + paddingRight);
173+
int childrenLength = isVertical ? bottom - top - paddingBottom : right - left - paddingRight;
174174

175175
int rowOrColumn = 0;
176176
int count = this.getChildCount();
@@ -184,7 +184,7 @@ protected void onLayout(boolean changed, int left, int top, int right, int botto
184184
int childWidth = CommonLayoutParams.getDesiredWidth(child);
185185
int childHeight = CommonLayoutParams.getDesiredHeight(child);
186186

187-
int length = this._lenghts.get(rowOrColumn);
187+
int length = this._lengths.get(rowOrColumn);
188188
if (isVertical) {
189189

190190
childWidth = length;
@@ -200,7 +200,7 @@ protected void onLayout(boolean changed, int left, int top, int right, int botto
200200
rowOrColumn++;
201201

202202
// Take current column width.
203-
childWidth = length = this._lenghts.get(rowOrColumn);
203+
childWidth = length = this._lengths.get(rowOrColumn);
204204
}
205205
}
206206
else {
@@ -217,7 +217,7 @@ protected void onLayout(boolean changed, int left, int top, int right, int botto
217217
rowOrColumn++;
218218

219219
// Take current row height.
220-
childHeight = length = this._lenghts.get(rowOrColumn);
220+
childHeight = length = this._lengths.get(rowOrColumn);
221221
}
222222
}
223223

0 commit comments

Comments
 (0)