From 20bf4bd9539e7e1038b7a3f53b3593b37fb184be Mon Sep 17 00:00:00 2001 From: Linus Lee Date: Thu, 28 May 2015 19:16:11 -0700 Subject: Trebuchet: fix excessive drawing with folders Change-Id: I0a33bfd3b18fe8b4d2c57e38fe7eb2dc247a9219 --- src/com/android/launcher3/FolderIcon.java | 78 +++++++++++++++++++------------ 1 file changed, 49 insertions(+), 29 deletions(-) diff --git a/src/com/android/launcher3/FolderIcon.java b/src/com/android/launcher3/FolderIcon.java index 34603b90f..03bb1e34a 100644 --- a/src/com/android/launcher3/FolderIcon.java +++ b/src/com/android/launcher3/FolderIcon.java @@ -181,6 +181,55 @@ public class FolderIcon extends FrameLayout implements FolderListener { icon.setOnFocusChangeListener(launcher.mFocusHandler); icon.setDrawingCacheEnabled(true); + + // get dimen for the icon size + // ratio: iconsize = 3*padding + 2*small_icon_size + // padding*6.5 = small_icon_size + // so padding = folderIconSize / 16 + int padding = grid.iconSizePx / 16; + int smallIconSize = (int) (padding * 6.5); + + for (int i = NUM_ITEMS_IN_PREVIEW; i >= 0; i--) { + ImageView appIcon = null; + int marginLeft = 0, marginRight = 0, marginTop = 0, marginBottom = 0; + switch(i) { + case 0: + appIcon = (ImageView) icon.findViewById(R.id.app_0); + marginLeft = padding; + marginTop = padding; + break; + case 1: + appIcon = (ImageView) icon.findViewById(R.id.app_1); + marginTop = padding; + marginRight = padding; + break; + case 2: + appIcon = (ImageView) icon.findViewById(R.id.app_2); + marginBottom = padding; + marginLeft = padding; + break; + case 3: + appIcon = (ImageView) icon.findViewById(R.id.app_3); + marginBottom = padding; + marginRight = padding; + break; + } + + if (appIcon != null) { + RelativeLayout.LayoutParams layoutParams + = (RelativeLayout.LayoutParams) appIcon.getLayoutParams(); + + layoutParams.width = smallIconSize; + layoutParams.height = smallIconSize; + layoutParams.leftMargin = marginLeft; + layoutParams.rightMargin = marginRight; + layoutParams.topMargin = marginTop; + layoutParams.bottomMargin = marginBottom; + + appIcon.setLayoutParams(layoutParams); + } + } + return icon; } @@ -681,16 +730,6 @@ public class FolderIcon extends FrameLayout implements FolderListener { } if (!mAnimating) { - LauncherAppState app = LauncherAppState.getInstance(); - DeviceProfile grid = app.getDynamicGrid().getDeviceProfile(); - - // get dimen for the icon size - // ratio: iconsize = 3*padding + 2*small_icon_size - // padding*6.5 = small_icon_size - // so padding = folderIconSize / 16 - int padding = grid.iconSizePx / 16; - int smallIconSize = (int) (padding * 6.5); - for (int i = NUM_ITEMS_IN_PREVIEW; i >= 0; i--) { d = null; if (i < items.size()) { @@ -703,42 +742,23 @@ public class FolderIcon extends FrameLayout implements FolderListener { } ImageView appIcon = null; - int marginLeft = 0, marginRight = 0, marginTop = 0, marginBottom = 0; switch(i) { case 0: appIcon = (ImageView) findViewById(R.id.app_0); - marginLeft = padding; - marginTop = padding; break; case 1: appIcon = (ImageView) findViewById(R.id.app_1); - marginTop = padding; - marginRight = padding; break; case 2: appIcon = (ImageView) findViewById(R.id.app_2); - marginBottom = padding; - marginLeft = padding; break; case 3: appIcon = (ImageView) findViewById(R.id.app_3); - marginBottom = padding; - marginRight = padding; break; } if (appIcon != null) { appIcon.setImageDrawable(d); - RelativeLayout.LayoutParams layoutParams - = (RelativeLayout.LayoutParams) appIcon.getLayoutParams(); - layoutParams.width = smallIconSize; - layoutParams.height = smallIconSize; - layoutParams.leftMargin = marginLeft; - layoutParams.rightMargin = marginRight; - layoutParams.topMargin = marginTop; - layoutParams.bottomMargin = marginBottom; - - appIcon.setLayoutParams(layoutParams); } } } else { -- cgit v1.2.3