本文整理汇总了Java中com.android.launcher3.LauncherSettings.WorkspaceScreens类的典型用法代码示例。如果您正苦于以下问题:Java WorkspaceScreens类的具体用法?Java WorkspaceScreens怎么用?Java WorkspaceScreens使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WorkspaceScreens类属于com.android.launcher3.LauncherSettings包,在下文中一共展示了WorkspaceScreens类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: loadFavorites
import com.android.launcher3.LauncherSettings.WorkspaceScreens; //导入依赖的package包/类
@Thunk int loadFavorites(SQLiteDatabase db, AutoInstallsLayout loader) {
ArrayList<Long> screenIds = new ArrayList<Long>();
// TODO: Use multiple loaders with fall-back and transaction.
int count = loader.loadLayout(db, screenIds);
// Add the screens specified by the items above
Collections.sort(screenIds);
int rank = 0;
ContentValues values = new ContentValues();
for (Long id : screenIds) {
values.clear();
values.put(LauncherSettings.WorkspaceScreens._ID, id);
values.put(LauncherSettings.WorkspaceScreens.SCREEN_RANK, rank);
if (dbInsertAndCheck(this, db, WorkspaceScreens.TABLE_NAME, null, values) < 0) {
throw new RuntimeException("Failed initialize screen table"
+ "from default layout");
}
rank++;
}
// Ensure that the max ids are initialized
mMaxItemId = initializeMaxItemId(db);
mMaxScreenId = initializeMaxScreenId(db);
return count;
}
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:27,代码来源:LauncherProvider.java
示例2: getScreenIdsFromCursor
import com.android.launcher3.LauncherSettings.WorkspaceScreens; //导入依赖的package包/类
/**
* Parses the cursor containing workspace screens table and returns the list of screen IDs
*/
public static ArrayList<Long> getScreenIdsFromCursor(Cursor sc) {
ArrayList<Long> screenIds = new ArrayList<Long>();
try {
final int idIndex = sc.getColumnIndexOrThrow(WorkspaceScreens._ID);
while (sc.moveToNext()) {
try {
screenIds.add(sc.getLong(idIndex));
} catch (Exception e) {
FileLog.d(TAG, "Invalid screen id", e);
}
}
} finally {
sc.close();
}
return screenIds;
}
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:20,代码来源:LauncherDbUtils.java
示例3: backupScreens
import com.android.launcher3.LauncherSettings.WorkspaceScreens; //导入依赖的package包/类
/**
* Write all modified screens to the data stream.
*
* @param data output stream for key/value pairs
* @throws IOException
*/
private void backupScreens(BackupDataOutput data) throws IOException {
// persist things that have changed since the last backup
ContentResolver cr = mContext.getContentResolver();
Cursor cursor = cr.query(WorkspaceScreens.CONTENT_URI, SCREEN_PROJECTION,
null, null, null);
try {
cursor.moveToPosition(-1);
if (DEBUG) Log.d(TAG, "dumping screens after: " + mLastBackupRestoreTime);
while(cursor.moveToNext()) {
final long id = cursor.getLong(ID_INDEX);
final long updateTime = cursor.getLong(ID_MODIFIED);
Key key = getKey(Key.SCREEN, id);
mKeys.add(key);
final String backupKey = keyToBackupKey(key);
if (!mExistingKeys.contains(backupKey) || updateTime >= mLastBackupRestoreTime) {
writeRowToBackup(key, packScreen(cursor), data);
} else {
if (VERBOSE) Log.v(TAG, "screen already backup up " + id);
}
}
} finally {
cursor.close();
}
}
开发者ID:talentlo,项目名称:Trebuchet,代码行数:31,代码来源:LauncherBackupHelper.java
示例4: addWorkspacesTable
import com.android.launcher3.LauncherSettings.WorkspaceScreens; //导入依赖的package包/类
private void addWorkspacesTable(SQLiteDatabase db, boolean optional) {
String ifNotExists = optional ? " IF NOT EXISTS " : "";
db.execSQL("CREATE TABLE " + ifNotExists + WorkspaceScreens.TABLE_NAME + " (" +
LauncherSettings.WorkspaceScreens._ID + " INTEGER PRIMARY KEY," +
LauncherSettings.WorkspaceScreens.SCREEN_RANK + " INTEGER," +
LauncherSettings.ChangeLogColumns.MODIFIED + " INTEGER NOT NULL DEFAULT 0" +
");");
}
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:9,代码来源:LauncherProvider.java
示例5: checkId
import com.android.launcher3.LauncherSettings.WorkspaceScreens; //导入依赖的package包/类
public void checkId(String table, ContentValues values) {
long id = values.getAsLong(LauncherSettings.BaseLauncherColumns._ID);
if (table == WorkspaceScreens.TABLE_NAME) {
mMaxScreenId = Math.max(id, mMaxScreenId);
} else {
mMaxItemId = Math.max(id, mMaxItemId);
}
}
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:9,代码来源:LauncherProvider.java
示例6: importWorkspace
import com.android.launcher3.LauncherSettings.WorkspaceScreens; //导入依赖的package包/类
public boolean importWorkspace() throws Exception {
ArrayList<Long> allScreens = LauncherDbUtils.getScreenIdsFromCursor(
mContext.getContentResolver().query(mOtherScreensUri, null, null, null,
LauncherSettings.WorkspaceScreens.SCREEN_RANK));
// During import we reset the screen IDs to 0-indexed values.
if (allScreens.isEmpty()) {
// No thing to migrate
return false;
}
mHotseatSize = mMaxGridSizeX = mMaxGridSizeY = 0;
// Build screen update
ArrayList<ContentProviderOperation> screenOps = new ArrayList<>();
int count = allScreens.size();
LongSparseArray<Long> screenIdMap = new LongSparseArray<>(count);
for (int i = 0; i < count; i++) {
ContentValues v = new ContentValues();
v.put(LauncherSettings.WorkspaceScreens._ID, i);
v.put(LauncherSettings.WorkspaceScreens.SCREEN_RANK, i);
screenIdMap.put(allScreens.get(i), (long) i);
screenOps.add(ContentProviderOperation.newInsert(
LauncherSettings.WorkspaceScreens.CONTENT_URI).withValues(v).build());
}
mContext.getContentResolver().applyBatch(ProviderConfig.AUTHORITY, screenOps);
importWorkspaceItems(allScreens.get(0), screenIdMap);
GridSizeMigrationTask.markForMigration(mContext, mMaxGridSizeX, mMaxGridSizeY, mHotseatSize);
// Create empty DB flag.
LauncherSettings.Settings.call(mContext.getContentResolver(),
LauncherSettings.Settings.METHOD_CLEAR_EMPTY_DB_FLAG);
return true;
}
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:36,代码来源:ImportDataTask.java
示例7: DatabaseHelper
import com.android.launcher3.LauncherSettings.WorkspaceScreens; //导入依赖的package包/类
DatabaseHelper(Context context, Handler widgetHostResetHandler) {
this(context, widgetHostResetHandler, LauncherFiles.LAUNCHER_DB);
// Table creation sometimes fails silently, which leads to a crash loop.
// This way, we will try to create a table every time after crash, so the device
// would eventually be able to recover.
if (!tableExists(Favorites.TABLE_NAME) || !tableExists(WorkspaceScreens.TABLE_NAME)) {
Log.e(TAG, "Tables are missing after onCreate has been called. Trying to recreate");
// This operation is a no-op if the table already exists.
addFavoritesTable(getWritableDatabase(), true);
addWorkspacesTable(getWritableDatabase(), true);
}
initIds();
}
开发者ID:TeamBrainStorm,项目名称:SimpleUILauncher,代码行数:15,代码来源:LauncherProvider.java
示例8: removeOrphanedItems
import com.android.launcher3.LauncherSettings.WorkspaceScreens; //导入依赖的package包/类
private void removeOrphanedItems(SQLiteDatabase db) {
// Delete items directly on the workspace who's screen id doesn't exist
// "DELETE FROM favorites WHERE screen NOT IN (SELECT _id FROM workspaceScreens)
// AND container = -100"
String removeOrphanedDesktopItems = "DELETE FROM " + Favorites.TABLE_NAME +
" WHERE " +
LauncherSettings.Favorites.SCREEN + " NOT IN (SELECT " +
LauncherSettings.WorkspaceScreens._ID + " FROM " + WorkspaceScreens.TABLE_NAME + ")" +
" AND " +
LauncherSettings.Favorites.CONTAINER + " = " +
LauncherSettings.Favorites.CONTAINER_DESKTOP;
db.execSQL(removeOrphanedDesktopItems);
// Delete items contained in folders which no longer exist (after above statement)
// "DELETE FROM favorites WHERE container <> -100 AND container <> -101 AND container
// NOT IN (SELECT _id FROM favorites WHERE itemType = 2)"
String removeOrphanedFolderItems = "DELETE FROM " + Favorites.TABLE_NAME +
" WHERE " +
LauncherSettings.Favorites.CONTAINER + " <> " +
LauncherSettings.Favorites.CONTAINER_DESKTOP +
" AND "
+ LauncherSettings.Favorites.CONTAINER + " <> " +
LauncherSettings.Favorites.CONTAINER_HOTSEAT +
" AND "
+ LauncherSettings.Favorites.CONTAINER + " NOT IN (SELECT " +
LauncherSettings.Favorites._ID + " FROM " + Favorites.TABLE_NAME +
" WHERE " + LauncherSettings.Favorites.ITEM_TYPE + " = " +
LauncherSettings.Favorites.ITEM_TYPE_FOLDER + ")";
db.execSQL(removeOrphanedFolderItems);
}
开发者ID:TeamBrainStorm,项目名称:SimpleUILauncher,代码行数:31,代码来源:LauncherProvider.java
示例9: renameScreen
import com.android.launcher3.LauncherSettings.WorkspaceScreens; //导入依赖的package包/类
private static void renameScreen(SQLiteDatabase db, long oldScreen, long newScreen) {
String[] whereParams = new String[] { Long.toString(oldScreen) };
ContentValues values = new ContentValues();
values.put(WorkspaceScreens._ID, newScreen);
db.update(WorkspaceScreens.TABLE_NAME, values, "_id = ?", whereParams);
values.clear();
values.put(Favorites.SCREEN, newScreen);
db.update(Favorites.TABLE_NAME, values, "container = -100 and screen = ?", whereParams);
}
开发者ID:TeamBrainStorm,项目名称:SimpleUILauncher,代码行数:12,代码来源:LauncherDbUtils.java
示例10: restoreScreen
import com.android.launcher3.LauncherSettings.WorkspaceScreens; //导入依赖的package包/类
/**
* Read a screen from the stream.
*
* <P>Keys arrive in any order, so children of this screen may already exist.
*
* @param key identifier for the row
* @param buffer the serialized proto from the stream, may be larger than dataSize
* @param dataSize the size of the proto from the stream
*/
private void restoreScreen(Key key, byte[] buffer, int dataSize) throws IOException {
if (VERBOSE) Log.v(TAG, "unpacking screen " + key.id);
if (DEBUG) Log.d(TAG, "read (" + buffer.length + "): " +
Base64.encodeToString(buffer, 0, dataSize, Base64.NO_WRAP));
ContentResolver cr = mContext.getContentResolver();
ContentValues values = unpackScreen(buffer, dataSize);
cr.insert(WorkspaceScreens.CONTENT_URI, values);
}
开发者ID:talentlo,项目名称:Trebuchet,代码行数:19,代码来源:LauncherBackupHelper.java
示例11: unpackScreen
import com.android.launcher3.LauncherSettings.WorkspaceScreens; //导入依赖的package包/类
/** Deserialize a Screen from persistence, after verifying checksum wrapper. */
private ContentValues unpackScreen(byte[] buffer, int dataSize)
throws InvalidProtocolBufferNanoException {
Screen screen = unpackProto(new Screen(), buffer, dataSize);
ContentValues values = new ContentValues();
values.put(WorkspaceScreens._ID, screen.id);
values.put(WorkspaceScreens.SCREEN_RANK, screen.rank);
return values;
}
开发者ID:talentlo,项目名称:Trebuchet,代码行数:10,代码来源:LauncherBackupHelper.java
示例12: createEmptyDB
import com.android.launcher3.LauncherSettings.WorkspaceScreens; //导入依赖的package包/类
/**
* Clears all the data for a fresh start.
*/
public void createEmptyDB(SQLiteDatabase db) {
db.execSQL("DROP TABLE IF EXISTS " + Favorites.TABLE_NAME);
db.execSQL("DROP TABLE IF EXISTS " + WorkspaceScreens.TABLE_NAME);
onCreate(db);
}
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:9,代码来源:LauncherProvider.java
示例13: recreateWorkspaceTable
import com.android.launcher3.LauncherSettings.WorkspaceScreens; //导入依赖的package包/类
/**
* Recreates workspace table and migrates data to the new table.
*/
public boolean recreateWorkspaceTable(SQLiteDatabase db) {
db.beginTransaction();
try {
Cursor c = db.query(WorkspaceScreens.TABLE_NAME,
new String[] {LauncherSettings.WorkspaceScreens._ID},
null, null, null, null,
LauncherSettings.WorkspaceScreens.SCREEN_RANK);
ArrayList<Long> sortedIDs = new ArrayList<Long>();
long maxId = 0;
try {
while (c.moveToNext()) {
Long id = c.getLong(0);
if (!sortedIDs.contains(id)) {
sortedIDs.add(id);
maxId = Math.max(maxId, id);
}
}
} finally {
c.close();
}
db.execSQL("DROP TABLE IF EXISTS " + WorkspaceScreens.TABLE_NAME);
addWorkspacesTable(db, false);
// Add all screen ids back
int total = sortedIDs.size();
for (int i = 0; i < total; i++) {
ContentValues values = new ContentValues();
values.put(LauncherSettings.WorkspaceScreens._ID, sortedIDs.get(i));
values.put(LauncherSettings.WorkspaceScreens.SCREEN_RANK, i);
addModifiedTime(values);
db.insertOrThrow(WorkspaceScreens.TABLE_NAME, null, values);
}
db.setTransactionSuccessful();
mMaxScreenId = maxId;
} catch (SQLException ex) {
// Old version remains, which means we wipe old data
Log.e(TAG, ex.getMessage(), ex);
return false;
} finally {
db.endTransaction();
}
return true;
}
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:48,代码来源:LauncherProvider.java
示例14: initializeMaxScreenId
import com.android.launcher3.LauncherSettings.WorkspaceScreens; //导入依赖的package包/类
private long initializeMaxScreenId(SQLiteDatabase db) {
return getMaxId(db, WorkspaceScreens.TABLE_NAME);
}
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:4,代码来源:LauncherProvider.java
示例15: prepareScreenZeroToHostQsb
import com.android.launcher3.LauncherSettings.WorkspaceScreens; //导入依赖的package包/类
/**
* Makes the first screen as screen 0 (if screen 0 already exists,
* renames it to some other number).
* If the first row of screen 0 is non empty, runs a 'lossy' GridMigrationTask to clear
* the first row. The items in the first screen are moved and resized but the carry-forward
* items are simply deleted.
*/
public static boolean prepareScreenZeroToHostQsb(SQLiteDatabase db) {
db.beginTransaction();
try {
// Get the existing screens
ArrayList<Long> screenIds = getScreenIdsFromCursor(db.query(WorkspaceScreens.TABLE_NAME,
null, null, null, null, null, WorkspaceScreens.SCREEN_RANK));
if (screenIds.isEmpty()) {
// No update needed
return true;
}
if (screenIds.get(0) != 0) {
// First screen is not 0, we need to rename screens
if (screenIds.indexOf(0L) > -1) {
// There is already a screen 0. First rename it to a differen screen.
long newScreenId = 1;
while (screenIds.indexOf(newScreenId) > -1) newScreenId++;
renameScreen(db, 0, newScreenId);
}
// Rename the first screen to 0.
renameScreen(db, screenIds.get(0), 0);
}
// Check if the first row is empty
try (Cursor c = db.query(Favorites.TABLE_NAME, null,
"container = -100 and screen = 0 and cellY = 0", null, null, null, null)) {
if (c.getCount() == 0) {
// First row is empty, no need to migrate.
return true;
}
}
LauncherAppState app = LauncherAppState.getInstance();
new LossyScreenMigrationTask(app.getContext(), app.getInvariantDeviceProfile(), db)
.migrateScreen0();
db.setTransactionSuccessful();
return true;
} catch (Exception e) {
Log.e(TAG, "Failed to update workspace size", e);
return false;
} finally {
db.endTransaction();
}
}
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:53,代码来源:LauncherDbUtils.java
示例16: ImportDataTask
import com.android.launcher3.LauncherSettings.WorkspaceScreens; //导入依赖的package包/类
private ImportDataTask(Context context, String sourceAuthority) {
mContext = context;
mOtherScreensUri = Uri.parse("content://" +
sourceAuthority + "/" + WorkspaceScreens.TABLE_NAME);
mOtherFavoritesUri = Uri.parse("content://" + sourceAuthority + "/" + Favorites.TABLE_NAME);
}
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:7,代码来源:ImportDataTask.java
注:本文中的com.android.launcher3.LauncherSettings.WorkspaceScreens类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论