当前位置: 首页>>代码示例>>Java>>正文


Java AppWidgetManagerCompat.getInstance方法代码示例

本文整理汇总了Java中com.android.launcher3.compat.AppWidgetManagerCompat.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java AppWidgetManagerCompat.getInstance方法的具体用法?Java AppWidgetManagerCompat.getInstance怎么用?Java AppWidgetManagerCompat.getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.android.launcher3.compat.AppWidgetManagerCompat的用法示例。


在下文中一共展示了AppWidgetManagerCompat.getInstance方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: WidgetsModel

import com.android.launcher3.compat.AppWidgetManagerCompat; //导入方法依赖的package包/类
public WidgetsModel(Context context,  IconCache iconCache, AppFilter appFilter) {
    mAppWidgetMgr = AppWidgetManagerCompat.getInstance(context);
    mAppNameComparator = (new AppNameComparator(context)).getAppInfoComparator();
    mIconCache = iconCache;
    mAppFilter = appFilter;
    mIndexer = new AlphabeticIndexCompat(context);
    mPackageItemInfos = new ArrayList<>();
    mWidgetsList = new HashMap<>();

    mRawList = new ArrayList<>();
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:12,代码来源:WidgetsModel.java

示例2: updateAndClone

import com.android.launcher3.compat.AppWidgetManagerCompat; //导入方法依赖的package包/类
public WidgetsModel updateAndClone(Context context) {
    Preconditions.assertWorkerThread();

    try {
        final ArrayList<WidgetItem> widgetsAndShortcuts = new ArrayList<>();
        // Widgets
        AppWidgetManagerCompat widgetManager = AppWidgetManagerCompat.getInstance(context);
        for (AppWidgetProviderInfo widgetInfo : widgetManager.getAllProviders()) {
            widgetsAndShortcuts.add(new WidgetItem(
                    LauncherAppWidgetProviderInfo.fromProviderInfo(context, widgetInfo),
                    widgetManager));
        }

        // Shortcuts
        PackageManager pm = context.getPackageManager();
        for (ResolveInfo info :
                pm.queryIntentActivities(new Intent(Intent.ACTION_CREATE_SHORTCUT), 0)) {
            widgetsAndShortcuts.add(new WidgetItem(info, pm));
        }
        setWidgetsAndShortcuts(widgetsAndShortcuts);
    } catch (Exception e) {
        if (!ProviderConfig.IS_DOGFOOD_BUILD &&
                (e.getCause() instanceof TransactionTooLargeException ||
                        e.getCause() instanceof DeadObjectException)) {
            // the returned value may be incomplete and will not be refreshed until the next
            // time Launcher starts.
            // TODO: after figuring out a repro step, introduce a dirty bit to check when
            // onResume is called to refresh the widget provider list.
        } else {
            throw e;
        }
    }
    return clone();
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:35,代码来源:WidgetsModel.java

示例3: WidgetPreviewLoader

import com.android.launcher3.compat.AppWidgetManagerCompat; //导入方法依赖的package包/类
public WidgetPreviewLoader(Context context, IconCache iconCache) {
    mContext = context;
    mIconCache = iconCache;
    mWidgetManager = AppWidgetManagerCompat.getInstance(context);
    mUserManager = UserManagerCompat.getInstance(context);
    mDb = new CacheDb(context);
    mWorkerHandler = new Handler(LauncherModel.getWorkerLooper());
    mProfileBadgeMargin = context.getResources()
            .getDimensionPixelSize(R.dimen.profile_badge_margin);
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:11,代码来源:WidgetPreviewLoader.java

示例4: setUp

import com.android.launcher3.compat.AppWidgetManagerCompat; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
    super.setUp();

    mResolver = mTargetContext.getContentResolver();
    mWidgetManager = AppWidgetManagerCompat.getInstance(mTargetContext);
    grantWidgetPermission();

    // Clear all existing data
    LauncherSettings.Settings.call(mResolver, LauncherSettings.Settings.METHOD_CREATE_EMPTY_DB);
    LauncherSettings.Settings.call(mResolver, LauncherSettings.Settings.METHOD_CLEAR_EMPTY_DB_FLAG);
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:13,代码来源:BindWidgetTest.java

示例5: WidgetsAndShortcutNameComparator

import com.android.launcher3.compat.AppWidgetManagerCompat; //导入方法依赖的package包/类
public WidgetsAndShortcutNameComparator(Context context) {
    mManager = AppWidgetManagerCompat.getInstance(context);
    mPackageManager = context.getPackageManager();
    mLabelCache = new HashMap<>();
    mCollator = Collator.getInstance();
    mMainHandle = UserHandleCompat.myUserHandle();
}
 
开发者ID:talentlo,项目名称:Trebuchet,代码行数:8,代码来源:WidgetsAndShortcutNameComparator.java

示例6: WidgetsModel

import com.android.launcher3.compat.AppWidgetManagerCompat; //导入方法依赖的package包/类
public WidgetsModel(Context context,  IconCache iconCache, AppFilter appFilter) {
    mContext = context;
    mAppWidgetMgr = AppWidgetManagerCompat.getInstance(context);
    mWidgetAndShortcutNameComparator = new WidgetsAndShortcutNameComparator(context);
    mAppNameComparator = (new AppNameComparator(context)).getAppInfoComparator();
    mIconCache = iconCache;
    mAppFilter = appFilter;
    mIndexer = new AlphabeticIndexCompat(context);
}
 
开发者ID:talentlo,项目名称:Trebuchet,代码行数:10,代码来源:WidgetsModel.java

示例7: WidgetPreviewLoader

import com.android.launcher3.compat.AppWidgetManagerCompat; //导入方法依赖的package包/类
public WidgetPreviewLoader(Context context, IconCache iconCache) {
    mContext = context;
    mIconCache = iconCache;
    mManager = AppWidgetManagerCompat.getInstance(context);
    mUserManager = UserManagerCompat.getInstance(context);
    mDb = new CacheDb(context);
    mWorkerHandler = new Handler(LauncherModel.getWorkerLooper());
    mProfileBadgeMargin = context.getResources()
            .getDimensionPixelSize(R.dimen.profile_badge_margin);
}
 
开发者ID:talentlo,项目名称:Trebuchet,代码行数:11,代码来源:WidgetPreviewLoader.java

示例8: createQsb

import com.android.launcher3.compat.AppWidgetManagerCompat; //导入方法依赖的package包/类
private View createQsb(LayoutInflater inflater, ViewGroup container) {
    Launcher launcher = Launcher.getLauncher(getActivity());
    mWidgetInfo = getSearchWidgetProvider(launcher);
    if (mWidgetInfo == null) {
        // There is no search provider, just show the default widget.
        return getDefaultView(inflater, container, false);
    }

    SharedPreferences prefs = Utilities.getPrefs(launcher);
    AppWidgetManagerCompat widgetManager = AppWidgetManagerCompat.getInstance(launcher);
    LauncherAppWidgetHost widgetHost = launcher.getAppWidgetHost();
    InvariantDeviceProfile idp = LauncherAppState.getInstance().getInvariantDeviceProfile();

    Bundle opts = new Bundle();
    Rect size = AppWidgetResizeFrame.getWidgetSizeRanges(launcher, idp.numColumns, 1, null);
    opts.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH, size.left);
    opts.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT, size.top);
    opts.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH, size.right);
    opts.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT, size.bottom);

    int widgetId = prefs.getInt(QSB_WIDGET_ID, -1);
    AppWidgetProviderInfo widgetInfo = widgetManager.getAppWidgetInfo(widgetId);
    boolean isWidgetBound = (widgetInfo != null) &&
            widgetInfo.provider.equals(mWidgetInfo.provider);

    if (!isWidgetBound) {
        // widgetId is already bound and its not the correct provider.
        // Delete the widget id.
        if (widgetId > -1) {
            widgetHost.deleteAppWidgetId(widgetId);
            widgetId = -1;
        }

        widgetId = widgetHost.allocateAppWidgetId();
        isWidgetBound = widgetManager.bindAppWidgetIdIfAllowed(widgetId, mWidgetInfo, opts);
        if (!isWidgetBound) {
            widgetHost.deleteAppWidgetId(widgetId);
            widgetId = -1;
        }
    }

    if (isWidgetBound) {
        mQsb = (LauncherAppWidgetHostView)
                widgetHost.createView(launcher, widgetId, mWidgetInfo);
        mQsb.setId(R.id.qsb_widget);
        mQsb.mErrorViewId = R.layout.qsb_default_view;

        if (!Utilities.containsAll(AppWidgetManager.getInstance(launcher)
                .getAppWidgetOptions(widgetId), opts)) {
            mQsb.updateAppWidgetOptions(opts);
        }
        mQsb.setPadding(0, 0, 0, 0);
        return mQsb;
    }

    // Return a default widget with setup icon.
    return getDefaultView(inflater, container, true);
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:59,代码来源:QsbContainerView.java


注:本文中的com.android.launcher3.compat.AppWidgetManagerCompat.getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。