|
17 | 17 | package com.etsy.android.grid;
|
18 | 18 |
|
19 | 19 | import android.content.Context;
|
| 20 | +import android.content.res.Configuration; |
20 | 21 | import android.content.res.TypedArray;
|
21 | 22 | import android.os.Parcel;
|
22 | 23 | import android.os.Parcelable;
|
@@ -241,13 +242,16 @@ public void setColumnCount(int columnCount) {
|
241 | 242 | // //////////////////////////////////////////////////////////////////////////////////////////
|
242 | 243 | // MEASUREMENT
|
243 | 244 | //
|
| 245 | + private boolean isLandscape() { |
| 246 | + return getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE ? true : false; |
| 247 | + } |
244 | 248 |
|
245 | 249 | @Override
|
246 | 250 | protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec) {
|
247 | 251 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
248 | 252 |
|
249 | 253 | if (mColumnCount <= 0) {
|
250 |
| - boolean isLandscape = getMeasuredWidth() > getMeasuredHeight(); |
| 254 | + boolean isLandscape = isLandscape(); |
251 | 255 | mColumnCount = isLandscape ? mColumnCountLandscape : mColumnCountPortrait;
|
252 | 256 | }
|
253 | 257 |
|
@@ -860,7 +864,7 @@ protected void onSizeChanged(final int w, final int h, final int oldw, final int
|
860 | 864 | @Override
|
861 | 865 | protected void onSizeChanged(int w, int h) {
|
862 | 866 | super.onSizeChanged(w, h);
|
863 |
| - boolean isLandscape = w > h; |
| 867 | + boolean isLandscape = isLandscape(); |
864 | 868 | int newColumnCount = isLandscape ? mColumnCountLandscape : mColumnCountPortrait;
|
865 | 869 | if (mColumnCount != newColumnCount) {
|
866 | 870 | mColumnCount = newColumnCount;
|
|
0 commit comments