Add check for loading ever applied in check for page scrolls initialized
When "Don't keep activities" is enabled in developer settings, the RecentsView gets re-initialized every home gesture. The home animation can often finish before the load plan ever gets applied, so the page scrolls can be used before the RecentsView has had a chance to add all its TaskViews and recalculate its page scroll.
Fixes: 249020573
Test: launched an app and went home
Change-Id: I83ca9de60b50693f7a22b08534ec36973cd6a0fc
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index eb68adb..4f5cc4a 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -699,7 +699,7 @@
}
/** Returns true iff this PagedView's scroll amounts are initialized to each page index. */
- protected boolean pageScrollsInitialized() {
+ protected boolean isPageScrollsInitialized() {
return mPageScrolls != null && mPageScrolls.length == getChildCount();
}
@@ -708,12 +708,12 @@
*/
public void runOnPageScrollsInitialized(Runnable callback) {
mOnPageScrollsInitializedCallbacks.add(callback);
- if (pageScrollsInitialized()) {
+ if (isPageScrollsInitialized()) {
onPageScrollsInitialized();
}
}
- private void onPageScrollsInitialized() {
+ protected void onPageScrollsInitialized() {
for (Runnable callback : mOnPageScrollsInitializedCallbacks) {
callback.run();
}
@@ -727,7 +727,7 @@
final int childCount = getChildCount();
int[] pageScrolls = mPageScrolls;
boolean pageScrollChanged = false;
- if (!pageScrollsInitialized()) {
+ if (!isPageScrollsInitialized()) {
pageScrolls = new int[childCount];
pageScrollChanged = true;
}
@@ -1199,7 +1199,7 @@
}
public int getScrollForPage(int index) {
- if (!pageScrollsInitialized() || index >= mPageScrolls.length || index < 0) {
+ if (!isPageScrollsInitialized() || index >= mPageScrolls.length || index < 0) {
return 0;
} else {
return mPageScrolls[index];
@@ -1209,7 +1209,7 @@
// While layout transitions are occurring, a child's position may stray from its baseline
// position. This method returns the magnitude of this stray at any given time.
public int getLayoutTransitionOffsetForPage(int index) {
- if (!pageScrollsInitialized() || index >= mPageScrolls.length || index < 0) {
+ if (!isPageScrollsInitialized() || index >= mPageScrolls.length || index < 0) {
return 0;
} else {
View child = getChildAt(index);