Search in sources :

Example 51 with AppWidgetHostView

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;
}
Also used : Context(android.content.Context) AppWidgetHostView(android.appwidget.AppWidgetHostView) AppWidgetProviderInfo(android.appwidget.AppWidgetProviderInfo) Implementation(org.robolectric.annotation.Implementation)

Example 52 with AppWidgetHostView

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);
}
Also used : AppWidgetHostView(android.appwidget.AppWidgetHostView) Before(org.junit.Before)

Example 53 with 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);
        }
    }
}
Also used : AppWidgetHostView(android.appwidget.AppWidgetHostView) AppWidgetProviderInfo(android.appwidget.AppWidgetProviderInfo) LauncherIntent(mobi.intuitit.android.content.LauncherIntent) Intent(android.content.Intent) AppWidgetHostView(android.appwidget.AppWidgetHostView) ImageView(android.widget.ImageView) View(android.view.View)

Example 54 with AppWidgetHostView

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;
}
Also used : Context(android.content.Context) AppWidgetHostView(android.appwidget.AppWidgetHostView) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) AppWidgetProviderInfo(android.appwidget.AppWidgetProviderInfo)

Example 55 with AppWidgetHostView

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;
    }
}
Also used : AppWidgetHostView(android.appwidget.AppWidgetHostView) AppWidgetProviderInfo(android.appwidget.AppWidgetProviderInfo)

Aggregations

AppWidgetHostView (android.appwidget.AppWidgetHostView)87 AppWidgetProviderInfo (android.appwidget.AppWidgetProviderInfo)32 View (android.view.View)23 Bundle (android.os.Bundle)22 Point (android.graphics.Point)19 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)16 PendingAppWidgetHostView (com.android.launcher3.widget.PendingAppWidgetHostView)16 Context (android.content.Context)15 SuppressLint (android.annotation.SuppressLint)13 TextView (android.widget.TextView)12 Intent (android.content.Intent)10 ImageView (android.widget.ImageView)9 AppWidgetHost (android.appwidget.AppWidgetHost)7 ViewGroup (android.view.ViewGroup)7 LinearLayout (android.widget.LinearLayout)7 DragView (com.android.launcher3.dragndrop.DragView)7 PendingAddWidgetInfo (com.android.launcher3.widget.PendingAddWidgetInfo)7 Test (org.junit.Test)5 Rect (android.graphics.Rect)4 DraggableView (com.android.launcher3.dragndrop.DraggableView)4