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


Java Utilities.getPrefs方法代码示例

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


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

示例1: onCreate

import com.android.launcher3.Utilities; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    SharedPreferences sp = Utilities.getPrefs(this);
    boolean show = sp.getBoolean(TestingUtils.SHOW_WEIGHT_WATCHER, true);

    show = !show;
    sp.edit().putBoolean(TestingUtils.SHOW_WEIGHT_WATCHER, show).apply();

    Launcher launcher = (Launcher) LauncherAppState.getInstance().getModel().getCallback();
    if (launcher != null && launcher.mWeightWatcher != null) {
        launcher.mWeightWatcher.setVisibility(show ? View.VISIBLE : View.GONE);
    }
    finish();
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:17,代码来源:ToggleWeightWatcher.java

示例2: hasWallpaperIdChanged

import com.android.launcher3.Utilities; //导入方法依赖的package包/类
private static boolean hasWallpaperIdChanged(Context context) {
    if (!Utilities.isNycOrAbove()) {
        // TODO: update an id in sharedprefs in onWallpaperChanged broadcast, and read it here.
        return false;
    }
    final SharedPreferences sharedPrefs = Utilities.getPrefs(context);
    int wallpaperId = getWallpaperId(WallpaperManager.getInstance(context));
    int savedWallpaperId = sharedPrefs.getInt(ExtractionUtils.WALLPAPER_ID_PREFERENCE_KEY, -1);
    return wallpaperId != savedWallpaperId;
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:11,代码来源:ExtractionUtils.java

示例3: getUserCreationTime

import com.android.launcher3.Utilities; //导入方法依赖的package包/类
@Override
public long getUserCreationTime(UserHandleCompat user) {
    SharedPreferences prefs = Utilities.getPrefs(mContext);
    String key = USER_CREATION_TIME_KEY + getSerialNumberForUser(user);
    if (!prefs.contains(key)) {
        prefs.edit().putLong(key, System.currentTimeMillis()).apply();
    }
    return prefs.getLong(key, 0);
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:10,代码来源:UserManagerCompatVL.java

示例4: setUp

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

    mDevice = UiDevice.getInstance(getInstrumentation());
    mTargetContext = getInstrumentation().getTargetContext();
    mTargetPackage = mTargetContext.getPackageName();
    mPrefs = Utilities.getPrefs(mTargetContext);
    mOriginalRotationValue = mPrefs.getBoolean(Utilities.ALLOW_ROTATION_PREFERENCE_KEY, false);
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:11,代码来源:RotationPreferenceTest.java

示例5: migrateGridIfNeeded

import com.android.launcher3.Utilities; //导入方法依赖的package包/类
/**
 * Migrates the workspace and hotseat in case their sizes changed.
 * @return false if the migration failed.
 */
public static boolean migrateGridIfNeeded(Context context) {
    SharedPreferences prefs = Utilities.getPrefs(context);
    InvariantDeviceProfile idp = LauncherAppState.getInstance().getInvariantDeviceProfile();

    String gridSizeString = getPointString(idp.numColumns, idp.numRows);

    if (gridSizeString.equals(prefs.getString(KEY_MIGRATION_SRC_WORKSPACE_SIZE, "")) &&
            idp.numHotseatIcons != prefs.getInt(KEY_MIGRATION_SRC_HOTSEAT_COUNT, idp.numHotseatIcons)) {
        // Skip if workspace and hotseat sizes have not changed.
        return true;
    }

    long migrationStartTime = System.currentTimeMillis();
    try {
        boolean dbChanged = false;

        HashSet validPackages = getValidPackages(context);
        // Hotseat
        int srcHotseatCount = prefs.getInt(KEY_MIGRATION_SRC_HOTSEAT_COUNT, idp.numHotseatIcons);
        if (srcHotseatCount != idp.numHotseatIcons) {
            // Migrate hotseat.

            dbChanged = new GridSizeMigrationTask(context,
                    LauncherAppState.getInstance().getInvariantDeviceProfile(),
                    validPackages, srcHotseatCount, idp.numHotseatIcons).migrateHotseat();
        }

        // Grid size
        Point targetSize = new Point(idp.numColumns, idp.numRows);
        Point sourceSize = parsePoint(prefs.getString(
                KEY_MIGRATION_SRC_WORKSPACE_SIZE, gridSizeString));

        if (new MultiStepMigrationTask(validPackages, context).migrate(sourceSize, targetSize)) {
            dbChanged = true;
        }

        if (dbChanged) {
            // Make sure we haven't removed everything.
            final Cursor c = context.getContentResolver().query(
                    LauncherSettings.Favorites.CONTENT_URI, null, null, null, null);
            boolean hasData = c.moveToNext();
            c.close();
            if (!hasData) {
                throw new Exception("Removed every thing during grid resize");
            }
        }

        return true;
    } catch (Exception e) {
        Log.e(TAG, "Error during grid migration", e);

        return false;
    } finally {
        Log.v(TAG, "Workspace migration completed in "
                + (System.currentTimeMillis() - migrationStartTime));

        // Save current configuration, so that the migration does not run again.
        prefs.edit()
                .putString(KEY_MIGRATION_SRC_WORKSPACE_SIZE, gridSizeString)
                .putInt(KEY_MIGRATION_SRC_HOTSEAT_COUNT, idp.numHotseatIcons)
                .apply();
    }
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:68,代码来源:GridSizeMigrationTask.java


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