Search in sources :

Example 1 with DeferredAppWidgetHostView

use of com.android.launcher3.widget.DeferredAppWidgetHostView in project android_packages_apps_Trebuchet by LineageOS.

the class LauncherAppWidgetHost method createView.

public AppWidgetHostView createView(Context context, int appWidgetId, LauncherAppWidgetProviderInfo appWidget) {
    if (appWidget.isCustomWidget()) {
        LauncherAppWidgetHostView lahv = new LauncherAppWidgetHostView(context);
        lahv.setAppWidget(0, appWidget);
        CustomWidgetManager.INSTANCE.get(context).onViewCreated(lahv);
        return lahv;
    } else if ((mFlags & FLAG_LISTENING) == 0) {
        DeferredAppWidgetHostView view = new DeferredAppWidgetHostView(context);
        view.setAppWidget(appWidgetId, appWidget);
        mViews.put(appWidgetId, view);
        return view;
    } else {
        try {
            return super.createView(context, appWidgetId, appWidget);
        } catch (Exception e) {
            if (!Utilities.isBinderSizeError(e)) {
                throw new RuntimeException(e);
            }
            // If the exception was thrown while fetching the remote views, let the view stay.
            // This will ensure that if the widget posts a valid update later, the view
            // will update.
            LauncherAppWidgetHostView view = mViews.get(appWidgetId);
            if (view == null) {
                view = onCreateView(mContext, appWidgetId, appWidget);
            }
            view.setAppWidget(appWidgetId, appWidget);
            view.switchToErrorView();
            return view;
        }
    }
}
Also used : LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) DeferredAppWidgetHostView(com.android.launcher3.widget.DeferredAppWidgetHostView) ActivityNotFoundException(android.content.ActivityNotFoundException)

Example 2 with DeferredAppWidgetHostView

use of com.android.launcher3.widget.DeferredAppWidgetHostView in project Neo-Launcher by NeoApplications.

the class LauncherAppWidgetHost method createView.

public AppWidgetHostView createView(Context context, int appWidgetId, LauncherAppWidgetProviderInfo appWidget) {
    if (appWidget.isCustomWidget()) {
        /*LauncherAppWidgetHostView lahv = new LauncherAppWidgetHostView(context);
            lahv.setAppWidget(0, appWidget);
            CustomWidgetManager.INSTANCE.get(context).onViewCreated(lahv);
            return lahv;*/
        LauncherAppWidgetHostView lahv = new LauncherAppWidgetHostView(context);
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        inflater.inflate(appWidget.initialLayout, lahv);
        lahv.setAppWidget(0, appWidget);
        return lahv;
    } else if ((mFlags & FLAG_LISTENING) == 0) {
        DeferredAppWidgetHostView view = new DeferredAppWidgetHostView(context);
        view.setAppWidget(appWidgetId, appWidget);
        mViews.put(appWidgetId, view);
        return view;
    } else {
        try {
            return super.createView(context, appWidgetId, appWidget);
        } catch (Exception e) {
            if (!Utilities.isBinderSizeError(e)) {
                throw new RuntimeException(e);
            }
            // If the exception was thrown while fetching the remote views, let the view stay.
            // This will ensure that if the widget posts a valid update later, the view
            // will update.
            LauncherAppWidgetHostView view = mViews.get(appWidgetId);
            if (view == null) {
                view = onCreateView(mContext, appWidgetId, appWidget);
            }
            view.setAppWidget(appWidgetId, appWidget);
            view.switchToErrorView();
            return view;
        }
    }
}
Also used : LayoutInflater(android.view.LayoutInflater) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) DeferredAppWidgetHostView(com.android.launcher3.widget.DeferredAppWidgetHostView) ActivityNotFoundException(android.content.ActivityNotFoundException)

Aggregations

ActivityNotFoundException (android.content.ActivityNotFoundException)2 DeferredAppWidgetHostView (com.android.launcher3.widget.DeferredAppWidgetHostView)2 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)2 LayoutInflater (android.view.LayoutInflater)1