summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/PagedView.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/launcher3/PagedView.java')
-rw-r--r--src/com/android/launcher3/PagedView.java31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index 5cc2e8fc5..62b581f83 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -152,6 +152,8 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
// Similar to the platform implementation of isLayoutValid();
protected boolean mIsLayoutValid;
+ private int[] mTmpIntPair = new int[2];
+
public PagedView(Context context) {
this(context, null);
}
@@ -1600,4 +1602,33 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
boolean shouldIncludeView(View view);
}
+
+ public int[] getVisibleChildrenRange() {
+ float visibleLeft = 0;
+ float visibleRight = visibleLeft + getMeasuredWidth();
+ float scaleX = getScaleX();
+ if (scaleX < 1 && scaleX > 0) {
+ float mid = getMeasuredWidth() / 2;
+ visibleLeft = mid - ((mid - visibleLeft) / scaleX);
+ visibleRight = mid + ((visibleRight - mid) / scaleX);
+ }
+
+ int leftChild = -1;
+ int rightChild = -1;
+ final int childCount = getChildCount();
+ for (int i = 0; i < childCount; i++) {
+ final View child = getPageAt(i);
+
+ float left = child.getLeft() + child.getTranslationX() - getScrollX();
+ if (left <= visibleRight && (left + child.getMeasuredWidth()) >= visibleLeft) {
+ if (leftChild == -1) {
+ leftChild = i;
+ }
+ rightChild = i;
+ }
+ }
+ mTmpIntPair[0] = leftChild;
+ mTmpIntPair[1] = rightChild;
+ return mTmpIntPair;
+ }
}