* commit '4168dc497ded7c697d972283db7c8579788c23d5': Initialize FastBitmapDrawable bounds with default bitmap dimensions. Updating LauncherModel filtering to use screen ids. (Bug 11685286)
This commit is contained in:
@@ -32,6 +32,7 @@ class FastBitmapDrawable extends Drawable {
|
|||||||
FastBitmapDrawable(Bitmap b) {
|
FastBitmapDrawable(Bitmap b) {
|
||||||
mAlpha = 255;
|
mAlpha = 255;
|
||||||
mBitmap = b;
|
mBitmap = b;
|
||||||
|
setBounds(0, 0, b.getWidth(), b.getHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -459,7 +459,7 @@ public class Launcher extends Activity
|
|||||||
} else {
|
} else {
|
||||||
// We only load the page synchronously if the user rotates (or triggers a
|
// We only load the page synchronously if the user rotates (or triggers a
|
||||||
// configuration change) while launcher is in the foreground
|
// configuration change) while launcher is in the foreground
|
||||||
mModel.startLoader(true, mWorkspace.getCurrentPage());
|
mModel.startLoader(true, mWorkspace.getRestorePage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1801,7 +1801,8 @@ public class Launcher extends Activity
|
|||||||
@Override
|
@Override
|
||||||
protected void onSaveInstanceState(Bundle outState) {
|
protected void onSaveInstanceState(Bundle outState) {
|
||||||
if (mWorkspace.getChildCount() > 0) {
|
if (mWorkspace.getChildCount() > 0) {
|
||||||
outState.putInt(RUNTIME_STATE_CURRENT_SCREEN, mWorkspace.getRestorePage());
|
outState.putInt(RUNTIME_STATE_CURRENT_SCREEN,
|
||||||
|
mWorkspace.getCurrentPageOffsetFromCustomContent());
|
||||||
}
|
}
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
|
|
||||||
|
|||||||
@@ -2026,7 +2026,7 @@ public class LauncherModel extends BroadcastReceiver {
|
|||||||
|
|
||||||
/** Filters the set of items who are directly or indirectly (via another container) on the
|
/** Filters the set of items who are directly or indirectly (via another container) on the
|
||||||
* specified screen. */
|
* specified screen. */
|
||||||
private void filterCurrentWorkspaceItems(int currentScreen,
|
private void filterCurrentWorkspaceItems(long currentScreenId,
|
||||||
ArrayList<ItemInfo> allWorkspaceItems,
|
ArrayList<ItemInfo> allWorkspaceItems,
|
||||||
ArrayList<ItemInfo> currentScreenItems,
|
ArrayList<ItemInfo> currentScreenItems,
|
||||||
ArrayList<ItemInfo> otherScreenItems) {
|
ArrayList<ItemInfo> otherScreenItems) {
|
||||||
@@ -2041,8 +2041,8 @@ public class LauncherModel extends BroadcastReceiver {
|
|||||||
|
|
||||||
// If we aren't filtering on a screen, then the set of items to load is the full set of
|
// If we aren't filtering on a screen, then the set of items to load is the full set of
|
||||||
// items given.
|
// items given.
|
||||||
if (currentScreen < 0) {
|
if (currentScreenId < 0) {
|
||||||
currentScreenItems.addAll(allWorkspaceItems);
|
throw new RuntimeException("Unexpected screen id");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Order the set of items by their containers first, this allows use to walk through the
|
// Order the set of items by their containers first, this allows use to walk through the
|
||||||
@@ -2057,7 +2057,7 @@ public class LauncherModel extends BroadcastReceiver {
|
|||||||
});
|
});
|
||||||
for (ItemInfo info : allWorkspaceItems) {
|
for (ItemInfo info : allWorkspaceItems) {
|
||||||
if (info.container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {
|
if (info.container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {
|
||||||
if (info.screenId == currentScreen) {
|
if (info.screenId == currentScreenId) {
|
||||||
currentScreenItems.add(info);
|
currentScreenItems.add(info);
|
||||||
itemsOnScreen.add(info.id);
|
itemsOnScreen.add(info.id);
|
||||||
} else {
|
} else {
|
||||||
@@ -2078,20 +2078,20 @@ public class LauncherModel extends BroadcastReceiver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Filters the set of widgets which are on the specified screen. */
|
/** Filters the set of widgets which are on the specified screen. */
|
||||||
private void filterCurrentAppWidgets(int currentScreen,
|
private void filterCurrentAppWidgets(long currentScreenId,
|
||||||
ArrayList<LauncherAppWidgetInfo> appWidgets,
|
ArrayList<LauncherAppWidgetInfo> appWidgets,
|
||||||
ArrayList<LauncherAppWidgetInfo> currentScreenWidgets,
|
ArrayList<LauncherAppWidgetInfo> currentScreenWidgets,
|
||||||
ArrayList<LauncherAppWidgetInfo> otherScreenWidgets) {
|
ArrayList<LauncherAppWidgetInfo> otherScreenWidgets) {
|
||||||
// If we aren't filtering on a screen, then the set of items to load is the full set of
|
// If we aren't filtering on a screen, then the set of items to load is the full set of
|
||||||
// widgets given.
|
// widgets given.
|
||||||
if (currentScreen < 0) {
|
if (currentScreenId < 0) {
|
||||||
currentScreenWidgets.addAll(appWidgets);
|
throw new RuntimeException("Unexpected screen id");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (LauncherAppWidgetInfo widget : appWidgets) {
|
for (LauncherAppWidgetInfo widget : appWidgets) {
|
||||||
if (widget == null) continue;
|
if (widget == null) continue;
|
||||||
if (widget.container == LauncherSettings.Favorites.CONTAINER_DESKTOP &&
|
if (widget.container == LauncherSettings.Favorites.CONTAINER_DESKTOP &&
|
||||||
widget.screenId == currentScreen) {
|
widget.screenId == currentScreenId) {
|
||||||
currentScreenWidgets.add(widget);
|
currentScreenWidgets.add(widget);
|
||||||
} else {
|
} else {
|
||||||
otherScreenWidgets.add(widget);
|
otherScreenWidgets.add(widget);
|
||||||
@@ -2100,15 +2100,15 @@ public class LauncherModel extends BroadcastReceiver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Filters the set of folders which are on the specified screen. */
|
/** Filters the set of folders which are on the specified screen. */
|
||||||
private void filterCurrentFolders(int currentScreen,
|
private void filterCurrentFolders(long currentScreenId,
|
||||||
HashMap<Long, ItemInfo> itemsIdMap,
|
HashMap<Long, ItemInfo> itemsIdMap,
|
||||||
HashMap<Long, FolderInfo> folders,
|
HashMap<Long, FolderInfo> folders,
|
||||||
HashMap<Long, FolderInfo> currentScreenFolders,
|
HashMap<Long, FolderInfo> currentScreenFolders,
|
||||||
HashMap<Long, FolderInfo> otherScreenFolders) {
|
HashMap<Long, FolderInfo> otherScreenFolders) {
|
||||||
// If we aren't filtering on a screen, then the set of items to load is the full set of
|
// If we aren't filtering on a screen, then the set of items to load is the full set of
|
||||||
// widgets given.
|
// widgets given.
|
||||||
if (currentScreen < 0) {
|
if (currentScreenId < 0) {
|
||||||
currentScreenFolders.putAll(folders);
|
throw new RuntimeException("Unexpected screen id");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (long id : folders.keySet()) {
|
for (long id : folders.keySet()) {
|
||||||
@@ -2116,7 +2116,7 @@ public class LauncherModel extends BroadcastReceiver {
|
|||||||
FolderInfo folder = folders.get(id);
|
FolderInfo folder = folders.get(id);
|
||||||
if (info == null || folder == null) continue;
|
if (info == null || folder == null) continue;
|
||||||
if (info.container == LauncherSettings.Favorites.CONTAINER_DESKTOP &&
|
if (info.container == LauncherSettings.Favorites.CONTAINER_DESKTOP &&
|
||||||
info.screenId == currentScreen) {
|
info.screenId == currentScreenId) {
|
||||||
currentScreenFolders.put(id, folder);
|
currentScreenFolders.put(id, folder);
|
||||||
} else {
|
} else {
|
||||||
otherScreenFolders.put(id, folder);
|
otherScreenFolders.put(id, folder);
|
||||||
@@ -2243,13 +2243,7 @@ public class LauncherModel extends BroadcastReceiver {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final boolean isLoadingSynchronously = (synchronizeBindPage > -1);
|
// Save a copy of all the bg-thread collections
|
||||||
final int currentScreen = isLoadingSynchronously ? synchronizeBindPage :
|
|
||||||
oldCallbacks.getCurrentWorkspaceScreen();
|
|
||||||
|
|
||||||
// Load all the items that are on the current page first (and in the process, unbind
|
|
||||||
// all the existing workspace items before we call startBinding() below.
|
|
||||||
unbindWorkspaceItemsOnMainThread();
|
|
||||||
ArrayList<ItemInfo> workspaceItems = new ArrayList<ItemInfo>();
|
ArrayList<ItemInfo> workspaceItems = new ArrayList<ItemInfo>();
|
||||||
ArrayList<LauncherAppWidgetInfo> appWidgets =
|
ArrayList<LauncherAppWidgetInfo> appWidgets =
|
||||||
new ArrayList<LauncherAppWidgetInfo>();
|
new ArrayList<LauncherAppWidgetInfo>();
|
||||||
@@ -2264,6 +2258,20 @@ public class LauncherModel extends BroadcastReceiver {
|
|||||||
orderedScreenIds.addAll(sBgWorkspaceScreens);
|
orderedScreenIds.addAll(sBgWorkspaceScreens);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final boolean isLoadingSynchronously = (synchronizeBindPage > -1);
|
||||||
|
final int currentScreen = isLoadingSynchronously ? synchronizeBindPage :
|
||||||
|
oldCallbacks.getCurrentWorkspaceScreen();
|
||||||
|
if (currentScreen >= orderedScreenIds.size()) {
|
||||||
|
Log.w(TAG, "Invalid screen id to synchronously load");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final long currentScreenId = orderedScreenIds.get(currentScreen);
|
||||||
|
|
||||||
|
// Load all the items that are on the current page first (and in the process, unbind
|
||||||
|
// all the existing workspace items before we call startBinding() below.
|
||||||
|
unbindWorkspaceItemsOnMainThread();
|
||||||
|
|
||||||
|
// Separate the items that are on the current screen, and all the other remaining items
|
||||||
ArrayList<ItemInfo> currentWorkspaceItems = new ArrayList<ItemInfo>();
|
ArrayList<ItemInfo> currentWorkspaceItems = new ArrayList<ItemInfo>();
|
||||||
ArrayList<ItemInfo> otherWorkspaceItems = new ArrayList<ItemInfo>();
|
ArrayList<ItemInfo> otherWorkspaceItems = new ArrayList<ItemInfo>();
|
||||||
ArrayList<LauncherAppWidgetInfo> currentAppWidgets =
|
ArrayList<LauncherAppWidgetInfo> currentAppWidgets =
|
||||||
@@ -2273,12 +2281,11 @@ public class LauncherModel extends BroadcastReceiver {
|
|||||||
HashMap<Long, FolderInfo> currentFolders = new HashMap<Long, FolderInfo>();
|
HashMap<Long, FolderInfo> currentFolders = new HashMap<Long, FolderInfo>();
|
||||||
HashMap<Long, FolderInfo> otherFolders = new HashMap<Long, FolderInfo>();
|
HashMap<Long, FolderInfo> otherFolders = new HashMap<Long, FolderInfo>();
|
||||||
|
|
||||||
// Separate the items that are on the current screen, and all the other remaining items
|
filterCurrentWorkspaceItems(currentScreenId, workspaceItems, currentWorkspaceItems,
|
||||||
filterCurrentWorkspaceItems(currentScreen, workspaceItems, currentWorkspaceItems,
|
|
||||||
otherWorkspaceItems);
|
otherWorkspaceItems);
|
||||||
filterCurrentAppWidgets(currentScreen, appWidgets, currentAppWidgets,
|
filterCurrentAppWidgets(currentScreenId, appWidgets, currentAppWidgets,
|
||||||
otherAppWidgets);
|
otherAppWidgets);
|
||||||
filterCurrentFolders(currentScreen, itemsIdMap, folders, currentFolders,
|
filterCurrentFolders(currentScreenId, itemsIdMap, folders, currentFolders,
|
||||||
otherFolders);
|
otherFolders);
|
||||||
sortWorkspaceItemsSpatially(currentWorkspaceItems);
|
sortWorkspaceItemsSpatially(currentWorkspaceItems);
|
||||||
sortWorkspaceItemsSpatially(otherWorkspaceItems);
|
sortWorkspaceItemsSpatially(otherWorkspaceItems);
|
||||||
|
|||||||
@@ -571,6 +571,9 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
|
|||||||
void setRestorePage(int restorePage) {
|
void setRestorePage(int restorePage) {
|
||||||
mRestorePage = restorePage;
|
mRestorePage = restorePage;
|
||||||
}
|
}
|
||||||
|
int getRestorePage() {
|
||||||
|
return mRestorePage;
|
||||||
|
}
|
||||||
|
|
||||||
protected void notifyPageSwitchListener() {
|
protected void notifyPageSwitchListener() {
|
||||||
if (mPageSwitchListener != null) {
|
if (mPageSwitchListener != null) {
|
||||||
|
|||||||
@@ -3961,7 +3961,7 @@ public class Workspace extends SmoothPagedView
|
|||||||
return mDragInfo;
|
return mDragInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getRestorePage() {
|
public int getCurrentPageOffsetFromCustomContent() {
|
||||||
return getNextPage() - numCustomPages();
|
return getNextPage() - numCustomPages();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user