Skip to content

Commit 026b7ba

Browse files
committed
[NewFeature] Add helps determine if the app is running in a Tablet context
1 parent b8f3e65 commit 026b7ba

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
eclipse.preferences.version=1
2+
encoding/<project>=UTF-8

src/com/worthed/util/ViewUtils.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import java.util.ArrayList;
2020
import java.util.List;
2121

22+
import android.content.Context;
23+
import android.content.res.Configuration;
2224
import android.graphics.Paint;
2325
import android.graphics.Paint.FontMetrics;
2426
import android.view.View;
@@ -136,6 +138,7 @@ public static int getAbsListViewHeightBasedOnChildren(AbsListView view) {
136138

137139
/**
138140
* get Font height
141+
*
139142
* @param view
140143
* @return
141144
*/
@@ -145,7 +148,7 @@ public static int getFontHeight(TextView view) {
145148
FontMetrics fm = paint.getFontMetrics();
146149
return (int) (Math.ceil(fm.descent - fm.ascent));
147150
}
148-
151+
149152
/**
150153
* set view height
151154
*
@@ -250,4 +253,15 @@ public static <T extends View> List<T> getDescendants(ViewGroup parent,
250253
}
251254
return descendedViewList;
252255
}
256+
257+
/**
258+
* Helps determine if the app is running in a Tablet context.
259+
*
260+
* @param context
261+
* @return
262+
*/
263+
public static boolean isTablet(Context context) {
264+
return (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE;
265+
}
266+
253267
}

0 commit comments

Comments
 (0)