Java Code Examples for android.appwidget.AppWidgetHostView#updateAppWidgetSize()
The following examples show how to use
android.appwidget.AppWidgetHostView#updateAppWidgetSize() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WidgetsDialogFragment.java From HgLauncher with GNU General Public License v3.0 | 5 votes |
/** * Adds a widget to the desktop. * * @param data Intent used to receive the ID of the widget being added. */ private void addWidget(Intent data, int index, boolean newWidget) { int widgetId = data.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, WIDGET_CONFIG_DEFAULT_CODE); AppWidgetProviderInfo appWidgetInfo = appWidgetManager.getAppWidgetInfo(widgetId); AppWidgetHostView appWidgetHostView = appWidgetHost.createView( requireActivity().getApplicationContext(), widgetId, appWidgetInfo); // Prevents crashing when the widget info can't be found. // https://github.com/Neamar/KISS/commit/f81ae32ef5ff5c8befe0888e6ff818a41d8dedb4 if (appWidgetInfo == null) { removeWidget(appWidgetHostView, widgetId); } else { // Notify widget of the available minimum space. appWidgetHostView.setMinimumHeight(appWidgetInfo.minHeight); appWidgetHostView.setAppWidget(widgetId, appWidgetInfo); if (Utils.sdkIsAround(16)) { appWidgetHostView.updateAppWidgetSize(null, appWidgetInfo.minWidth, appWidgetInfo.minHeight, appWidgetInfo.minWidth, appWidgetInfo.minHeight); } // Remove existing widget if any and then add the new widget. appWidgetContainer.addView(appWidgetHostView, index); // Immediately listens for the widget. appWidgetHost.startListening(); addWidgetActionListener(index); registerForContextMenu(appWidgetContainer.getChildAt(index)); if (newWidget) { // Update our list. widgetsList.add(String.valueOf(widgetId)); // Apply preference changes. PreferenceHelper.updateWidgets(widgetsList); } } }
Example 2
Source File: WidgetsDialogFragment.java From HgLauncher with GNU General Public License v3.0 | 5 votes |
/** * Adds a widget to the desktop. * * @param data Intent used to receive the ID of the widget being added. */ private void addWidget(Intent data, int index, boolean newWidget) { int widgetId = data.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, WIDGET_CONFIG_DEFAULT_CODE); AppWidgetProviderInfo appWidgetInfo = appWidgetManager.getAppWidgetInfo(widgetId); AppWidgetHostView appWidgetHostView = appWidgetHost.createView( requireActivity().getApplicationContext(), widgetId, appWidgetInfo); // Prevents crashing when the widget info can't be found. // https://github.com/Neamar/KISS/commit/f81ae32ef5ff5c8befe0888e6ff818a41d8dedb4 if (appWidgetInfo == null) { removeWidget(appWidgetHostView, widgetId); } else { // Notify widget of the available minimum space. appWidgetHostView.setMinimumHeight(appWidgetInfo.minHeight); appWidgetHostView.setAppWidget(widgetId, appWidgetInfo); if (Utils.sdkIsAround(16)) { appWidgetHostView.updateAppWidgetSize(null, appWidgetInfo.minWidth, appWidgetInfo.minHeight, appWidgetInfo.minWidth, appWidgetInfo.minHeight); } // Remove existing widget if any and then add the new widget. appWidgetContainer.addView(appWidgetHostView, index); // Immediately listens for the widget. appWidgetHost.startListening(); addWidgetActionListener(index); registerForContextMenu(appWidgetContainer.getChildAt(index)); if (newWidget) { // Update our list. widgetsList.add(String.valueOf(widgetId)); // Apply preference changes. PreferenceHelper.updateWidgets(widgetsList); } } }
Example 3
Source File: AppWidgetResizeFrame.java From TurboLauncher with Apache License 2.0 | 5 votes |
static void updateWidgetSizeRanges(AppWidgetHostView widgetView, Launcher launcher, int spanX, int spanY) { getWidgetSizeRanges(launcher, spanX, spanY, mTmpRect); widgetView.updateAppWidgetSize(null, mTmpRect.left, mTmpRect.top, mTmpRect.right, mTmpRect.bottom); }
Example 4
Source File: AppWidgetResizeFrame.java From LB-Launcher with Apache License 2.0 | 5 votes |
static void updateWidgetSizeRanges(AppWidgetHostView widgetView, Launcher launcher, int spanX, int spanY) { getWidgetSizeRanges(launcher, spanX, spanY, mTmpRect); widgetView.updateAppWidgetSize(null, mTmpRect.left, mTmpRect.top, mTmpRect.right, mTmpRect.bottom); }
Example 5
Source File: AppWidgetResizeFrame.java From LaunchEnr with GNU General Public License v3.0 | 4 votes |
static void updateWidgetSizeRanges(AppWidgetHostView widgetView, Launcher launcher, int spanX, int spanY) { getWidgetSizeRanges(launcher, spanX, spanY, sTmpRect); widgetView.updateAppWidgetSize(null, sTmpRect.left, sTmpRect.top, sTmpRect.right, sTmpRect.bottom); }
Example 6
Source File: AppWidgetResizeFrame.java From Trebuchet with GNU General Public License v3.0 | 4 votes |
static void updateWidgetSizeRanges(AppWidgetHostView widgetView, Launcher launcher, int spanX, int spanY) { getWidgetSizeRanges(launcher, spanX, spanY, sTmpRect); widgetView.updateAppWidgetSize(null, sTmpRect.left, sTmpRect.top, sTmpRect.right, sTmpRect.bottom); }