use of android.appwidget.AppWidgetHostView in project robolectric by robolectric.
the class ShadowAppWidgetHost method createView.
@Implementation
protected AppWidgetHostView createView(Context context, int appWidgetId, AppWidgetProviderInfo appWidget) {
AppWidgetHostView hostView = ReflectionHelpers.callInstanceMethod(AppWidgetHost.class, realAppWidgetHost, "onCreateView", ReflectionHelpers.ClassParameter.from(Context.class, context), ReflectionHelpers.ClassParameter.from(int.class, appWidgetId), ReflectionHelpers.ClassParameter.from(AppWidgetProviderInfo.class, appWidget));
hostView.setAppWidget(appWidgetId, appWidget);
ShadowAppWidgetHostView shadowAppWidgetHostView = Shadow.extract(hostView);
shadowAppWidgetHostView.setHost(realAppWidgetHost);
return hostView;
}
use of android.appwidget.AppWidgetHostView in project robolectric by robolectric.
the class ShadowAppWidgetHostViewTest method setUp.
@Before
public void setUp() throws Exception {
appWidgetHostView = new AppWidgetHostView(ApplicationProvider.getApplicationContext());
shadowAppWidgetHostView = shadowOf(appWidgetHostView);
}
use of android.appwidget.AppWidgetHostView in project ADWLauncher2 by boombuler.
the class WidgetCellLayout method onViewportOut.
/**
* Called when this cell layout get into the viewport
*/
public void onViewportOut() {
View child;
AppWidgetHostView widgetView;
AppWidgetProviderInfo widgetInfo;
Intent intent;
for (int i = this.getChildCount() - 1; i >= 0; i--) {
try {
child = this.getChildAt(i);
if (child instanceof AppWidgetHostView) {
widgetView = ((AppWidgetHostView) child);
// Stop all animations in the view
stopAllAnimationDrawables(widgetView);
// Notify the widget provider
widgetInfo = widgetView.getAppWidgetInfo();
int appWidgetId = widgetView.getAppWidgetId();
intent = new Intent(LauncherIntent.Notification.NOTIFICATION_OUT_VIEWPORT).setComponent(widgetInfo.provider);
intent.putExtra(LauncherIntent.Extra.EXTRA_APPWIDGET_ID, appWidgetId);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
getContext().sendBroadcast(intent);
}
} catch (Exception e) {
// LauncherApplication.reportExceptionStack(e);
}
}
}
use of android.appwidget.AppWidgetHostView in project ADWLauncher2 by boombuler.
the class WidgetSpace method unbindWidgetScrollableId.
public synchronized boolean unbindWidgetScrollableId(int widgetId) {
Log.d(TAG, "trying to completely unallocate widget ID=" + widgetId);
CharSequence keyToDelete = null;
for (ScrollViewInfos item : mScrollViewCursorInfos.values()) {
Log.d(TAG, "Comparing widget ID=" + item.widgetId);
if (item.widgetId == widgetId) {
Log.d(TAG, "trying to completely unallocate widget stuff...");
AppWidgetHostView widgetView = findWidget(widgetId);
Log.d(TAG, "Widget view to KILL:" + widgetView);
Context remoteContext = null;
if (widgetView != null) {
AppWidgetProviderInfo info = widgetView.getAppWidgetInfo();
if (info != null && info.provider != null) {
final String packageName = info.provider.getPackageName();
try {
remoteContext = getContext().createPackageContext(packageName, Context.CONTEXT_IGNORE_SECURITY);
} catch (NameNotFoundException e) {
Log.e(TAG, "couldn't find widget id:" + widgetId);
}
} else
remoteContext = null;
}
if (remoteContext == null)
remoteContext = getContext();
if (item.lv != null) {
Log.d(TAG, "Trying to KILL the ListView...");
if (item.lvAdapter != null) {
item.lvAdapter.dropCache(remoteContext);
}
item.lv.setAdapter(null);
item.lv = null;
}
remoteContext.getContentResolver().unregisterContentObserver(item.obs);
item.obsHandler = null;
item.obs = null;
keyToDelete = item.key;
item = null;
ListViewImageManager.getInstance().clearCacheForWidget(getContext(), widgetId);
}
}
if (keyToDelete != null)
mScrollViewCursorInfos.remove(keyToDelete);
ListViewImageManager.getInstance().unbindDrawables();
if (FORCE_FREE_MEMORY) {
System.gc();
}
Log.d(TAG, "AFTER REMOVING, Our Scrollable widgets array contains:" + mScrollViewCursorInfos.size());
return false;
}
use of android.appwidget.AppWidgetHostView in project android_frameworks_base by ParanoidAndroid.
the class KeyguardHostView method addWidget.
private boolean addWidget(int appId, int pageIndex, boolean updateDbIfFailed) {
AppWidgetProviderInfo appWidgetInfo = mAppWidgetManager.getAppWidgetInfo(appId);
if (appWidgetInfo != null) {
AppWidgetHostView view = mAppWidgetHost.createView(mContext, appId, appWidgetInfo);
addWidget(view, pageIndex);
return true;
} else {
if (updateDbIfFailed) {
Log.w(TAG, "*** AppWidgetInfo for app widget id " + appId + " was null for user" + mUserId + ", deleting");
mAppWidgetHost.deleteAppWidgetId(appId);
mLockPatternUtils.removeAppWidget(appId);
}
return false;
}
}
Aggregations