summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/FolderPagedView.java
diff options
context:
space:
mode:
authorTyson Miller <tmiller@cyngn.com>2015-11-10 08:59:15 -0800
committerGerrit Code Review <gerrit@cyanogenmod.org>2016-01-28 17:00:28 -0800
commit7df0227f6a835641a3d41327a65845806ef070fb (patch)
tree3fcf92a1fba468facc675ad47accb08ec2f9f907 /src/com/android/launcher3/FolderPagedView.java
parent84dfd2a560442953af78aa77dbd6c909aed63589 (diff)
downloadandroid_packages_apps_Trebuchet-7df0227f6a835641a3d41327a65845806ef070fb.tar.gz
android_packages_apps_Trebuchet-7df0227f6a835641a3d41327a65845806ef070fb.tar.bz2
android_packages_apps_Trebuchet-7df0227f6a835641a3d41327a65845806ef070fb.zip
Port Remote Folder from 12.1 to 13.
Change-Id: If8cf9d5f054e8948ead702883b79f28db26c4d8b
Diffstat (limited to 'src/com/android/launcher3/FolderPagedView.java')
-rw-r--r--src/com/android/launcher3/FolderPagedView.java47
1 files changed, 46 insertions, 1 deletions
diff --git a/src/com/android/launcher3/FolderPagedView.java b/src/com/android/launcher3/FolderPagedView.java
index a7940d552..5d5ac3d5a 100644
--- a/src/com/android/launcher3/FolderPagedView.java
+++ b/src/com/android/launcher3/FolderPagedView.java
@@ -114,7 +114,7 @@ public class FolderPagedView extends PagedView {
* The grid size is calculated such that countY <= countX and countX = ceil(sqrt(count)) while
* maintaining the restrictions of {@link #mMaxCountX} &amp; {@link #mMaxCountY}.
*/
- private void setupContentDimensions(int count) {
+ public void setupContentDimensions(int count) {
mAllocatedContentSize = count;
boolean done;
if (count >= mMaxItemsPerPage) {
@@ -274,6 +274,51 @@ public class FolderPagedView extends PagedView {
}
}
+ public void removeAllItems() {
+ for (int i = 0; i < getChildCount(); i++) {
+ getPageAt(i).removeAllViews();
+ }
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ if (getChildCount() == 0) {
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ } else {
+ // We should only be as large as our pages, so measure all of them first.
+ View page = null;
+ for (int i = 0; i < getChildCount(); i++) {
+ page = getChildAt(i);
+ page.measure(widthMeasureSpec, heightMeasureSpec);
+ }
+
+ // And then set ourselves to their size.
+ int width = getPaddingLeft() + page.getMeasuredWidth() + getPaddingRight();
+ int height = getPaddingTop() + page.getMeasuredHeight() + getPaddingBottom();
+ mViewport.set(0, 0, width, height);
+ setMeasuredDimension(width, height);
+ }
+ }
+
+ /**
+ * Find the child view for the given rank.
+ * @param rank sorted index of child.
+ * @return view of child at given rank.
+ */
+ public View getChildAtRank(int rank) {
+ int pagePos = rank % mMaxItemsPerPage;
+ int pageNo = rank / mMaxItemsPerPage;
+ int cellX = pagePos % mGridCountX;
+ int cellY = pagePos / mGridCountX;
+
+ CellLayout page = getPageAt(pageNo);
+ if (page != null) {
+ return page.getChildAt(cellX, cellY);
+ } else {
+ return null;
+ }
+ }
+
/**
* Updates position and rank of all the children in the view.
* It essentially removes all views from all the pages and then adds them again in appropriate