use of android.appwidget.AppWidgetProviderInfo in project qksms by moezbhatti.
the class WidgetProvider method isSmallWidget.
/**
* Returns 1 when widget has less than 4 columns, else 0
*/
@TargetApi(16)
private static int isSmallWidget(AppWidgetManager appWidgetManager, int appWidgetId) {
int size;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
Bundle options = appWidgetManager.getAppWidgetOptions(appWidgetId);
size = options.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH);
} else {
AppWidgetProviderInfo appWidgetInfo = appWidgetManager.getAppWidgetInfo(appWidgetId);
size = appWidgetInfo.minWidth;
}
int n = 2;
while (70 * n - 30 < size) {
++n;
}
int columns = n - 1;
if (columns < 4)
return 1;
else
return 0;
}
Aggregations