本文整理了Java中android.appwidget.AppWidgetHostView.getAppWidgetId()
方法的一些代码示例,展示了AppWidgetHostView.getAppWidgetId()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AppWidgetHostView.getAppWidgetId()
方法的具体详情如下:
包路径:android.appwidget.AppWidgetHostView
类名称:AppWidgetHostView
方法名:getAppWidgetId
暂无
代码示例来源:origin: robolectric/robolectric
@Test
public void createView_shouldSetViewsAppWidgetId() throws Exception {
AppWidgetHostView hostView = appWidgetHost.createView(context, 765, null);
assertThat(hostView.getAppWidgetId()).isEqualTo(765);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void shouldKnowItsWidgetId() throws Exception {
appWidgetHostView.setAppWidget(789, null);
assertThat(appWidgetHostView.getAppWidgetId()).isEqualTo(789);
}
代码示例来源:origin: Neamar/KISS
/**
* Removes a single widget and deletes it from persistent prefs
*
* @param hostView instance of a displayed widget
*/
private void removeAppWidget(AppWidgetHostView hostView) {
// remove widget from view
int appWidgetId = hostView.getAppWidgetId();
mAppWidgetHost.deleteAppWidgetId(appWidgetId);
widgetArea.removeView(hostView);
// remove widget id from persistent prefs
SharedPreferences.Editor widgetPrefsEditor = widgetPrefs.edit();
widgetPrefsEditor.remove(String.valueOf(appWidgetId));
widgetPrefsEditor.apply();
// only one widget allowed so widgetUsed is false now
widgetUsed = false;
}
代码示例来源:origin: quaap/LaunchTime
public void saveLoadedWidget(ComponentName cn, AppWidgetHostView hostView) {
saveWidgetId(cn, hostView.getAppWidgetId());
mLoadedWidgets.put(cn, hostView);
}
代码示例来源:origin: quaap/LaunchTime
private AppWidgetHostView createWidgetFromId(int widget_id) {
AppWidgetProviderInfo appWidgetInfo = mAppWidgetManager.getAppWidgetInfo(widget_id);
if (appWidgetInfo==null) {
return null;
}
// if (checkBindPermission(widget_id, appWidgetInfo.provider)) return null;
AppWidgetHostView hostView = getLoadedAppWidgetHostView(appWidgetInfo.provider);
if (hostView==null || hostView.getAppWidgetId()!=widget_id) {
// Create the host view
hostView = mAppWidgetHost.createView(mContext, widget_id, appWidgetInfo);
hostView.setAppWidget(widget_id, appWidgetInfo);
}
return hostView;
}
代码示例来源:origin: fookwood/Launcher3
@Override
public void onDragEnd() {
// Cleanup up preloading state.
mLauncher.getDragController().removeDragListener(this);
mHandler.removeCallbacks(mBindWidgetRunnable);
mHandler.removeCallbacks(mInflateWidgetRunnable);
// Cleanup widget id
if (mWidgetLoadingId != -1) {
mLauncher.getAppWidgetHost().deleteAppWidgetId(mWidgetLoadingId);
mWidgetLoadingId = -1;
}
// The widget was inflated and added to the DragLayer -- remove it.
if (mInfo.boundWidget != null) {
mLauncher.getDragLayer().removeView(mInfo.boundWidget);
mLauncher.getAppWidgetHost().deleteAppWidgetId(mInfo.boundWidget.getAppWidgetId());
mInfo.boundWidget = null;
}
}
代码示例来源:origin: enricocid/LaunchEnr
@Override
public void onDragEnd() {
// Cleanup up preloading state.
mLauncher.getDragController().removeDragListener(this);
mHandler.removeCallbacks(mBindWidgetRunnable);
mHandler.removeCallbacks(mInflateWidgetRunnable);
// Cleanup widget id
if (mWidgetLoadingId != -1) {
mLauncher.getAppWidgetHost().deleteAppWidgetId(mWidgetLoadingId);
mWidgetLoadingId = -1;
}
// The widget was inflated and added to the DragLayer -- remove it.
if (mInfo.boundWidget != null) {
mLauncher.getDragLayer().removeView(mInfo.boundWidget);
mLauncher.getAppWidgetHost().deleteAppWidgetId(mInfo.boundWidget.getAppWidgetId());
mInfo.boundWidget = null;
}
}
代码示例来源:origin: klinker24/Android-Blur-Launcher
@Override
public void onDragEnd() {
if (LOGD) {
Log.d(TAG, "Cleaning up in onDragEnd()...");
}
// Cleanup up preloading state.
mLauncher.getDragController().removeDragListener(this);
mHandler.removeCallbacks(mBindWidgetRunnable);
mHandler.removeCallbacks(mInflateWidgetRunnable);
// Cleanup widget id
if (mWidgetLoadingId != -1) {
mLauncher.getAppWidgetHost().deleteAppWidgetId(mWidgetLoadingId);
mWidgetLoadingId = -1;
}
// The widget was inflated and added to the DragLayer -- remove it.
if (mInfo.boundWidget != null) {
if (LOGD) {
Log.d(TAG, "...removing widget from drag layer");
}
mLauncher.getDragLayer().removeView(mInfo.boundWidget);
mLauncher.getAppWidgetHost().deleteAppWidgetId(mInfo.boundWidget.getAppWidgetId());
mInfo.boundWidget = null;
}
}
代码示例来源:origin: klinker24/launcher3
@Override
public void onDragEnd() {
if (LOGD) {
Log.d(TAG, "Cleaning up in onDragEnd()...");
}
// Cleanup up preloading state.
mLauncher.getDragController().removeDragListener(this);
mHandler.removeCallbacks(mBindWidgetRunnable);
mHandler.removeCallbacks(mInflateWidgetRunnable);
// Cleanup widget id
if (mWidgetLoadingId != -1) {
mLauncher.getAppWidgetHost().deleteAppWidgetId(mWidgetLoadingId);
mWidgetLoadingId = -1;
}
// The widget was inflated and added to the DragLayer -- remove it.
if (mInfo.boundWidget != null) {
if (LOGD) {
Log.d(TAG, "...removing widget from drag layer");
}
mLauncher.getDragLayer().removeView(mInfo.boundWidget);
mLauncher.getAppWidgetHost().deleteAppWidgetId(mInfo.boundWidget.getAppWidgetId());
mInfo.boundWidget = null;
}
}
代码示例来源:origin: WeAreFairphone/FP2-Launcher
int appWidgetId;
if (hostView != null) {
appWidgetId = hostView.getAppWidgetId();
addAppWidgetImpl(appWidgetId, info, hostView, info.info);
} else {
代码示例来源:origin: fookwood/Launcher3
int appWidgetId;
if (hostView != null) {
appWidgetId = hostView.getAppWidgetId();
addAppWidgetImpl(appWidgetId, info, hostView, info.info);
代码示例来源:origin: klinker24/launcher3
appWidgetId = hostView.getAppWidgetId();
addAppWidgetFromDropImpl(appWidgetId, info, hostView, info.info);
代码示例来源:origin: klinker24/Android-Blur-Launcher
appWidgetId = hostView.getAppWidgetId();
addAppWidgetFromDropImpl(appWidgetId, info, hostView, info.info);
代码示例来源:origin: enricocid/LaunchEnr
/**
* Process a widget drop.
*/
private void addAppWidgetFromDrop(PendingAddWidgetInfo info) {
AppWidgetHostView hostView = info.boundWidget;
int appWidgetId;
WidgetAddFlowHandler addFlowHandler = info.getHandler();
if (hostView != null) {
// In the case where we've prebound the widget, we remove it from the DragLayer
getDragLayer().removeView(hostView);
appWidgetId = hostView.getAppWidgetId();
addAppWidgetFromDropImpl(appWidgetId, info, hostView, addFlowHandler);
// Clear the boundWidget so that it doesn't get destroyed.
info.boundWidget = null;
} else {
// In this case, we either need to start an activity to get permission to bind
// the widget, or we need to start an activity to configure the widget, or both.
appWidgetId = getAppWidgetHost().allocateAppWidgetId();
Bundle options = info.bindOptions;
boolean success = mAppWidgetManager.bindAppWidgetIdIfAllowed(
appWidgetId, info.info, options);
if (success) {
addAppWidgetFromDropImpl(appWidgetId, info, null, addFlowHandler);
} else {
addFlowHandler.startBindFlow(this, appWidgetId, info, REQUEST_BIND_APPWIDGET);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!