summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authord34d <clark@cyngn.com>2016-02-19 16:25:50 -0800
committerClark Scheff <clark@cyngn.com>2016-02-22 19:54:11 +0000
commit9ba2bc96d84cdf363475225c1059efe2d2380835 (patch)
tree2f8aab95959d0e7a673bf813f38a71f8457f1b80
parent696489d92bc842a89ed53936632c28fef8eb7e23 (diff)
downloadpackages_apps_ThemeChooser-9ba2bc96d84cdf363475225c1059efe2d2380835.zip
packages_apps_ThemeChooser-9ba2bc96d84cdf363475225c1059efe2d2380835.tar.gz
packages_apps_ThemeChooser-9ba2bc96d84cdf363475225c1059efe2d2380835.tar.bz2
Reuse space view when available
The additional Space we add to the additional cards layout was being created and added multiple times. We should be re-using it if it is already in the parent layout. Change-Id: Idfbb7889836175c39408bead193ea6125e124e69 TICKET: CYNGNOS-2117
-rw-r--r--src/com/cyngn/theme/chooser/ThemeFragment.java19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/com/cyngn/theme/chooser/ThemeFragment.java b/src/com/cyngn/theme/chooser/ThemeFragment.java
index 5ef7b61..7cd04ff 100644
--- a/src/com/cyngn/theme/chooser/ThemeFragment.java
+++ b/src/com/cyngn/theme/chooser/ThemeFragment.java
@@ -2813,11 +2813,20 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb
* @param selectorHeight
*/
public void slideContentIntoView(final int yDelta, int selectorHeight) {
- Space space = new Space(getActivity());
- space.setId(ADDITIONAL_CONTENT_SPACE_ID);
- mAdditionalCards.addView(space,
- new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
- selectorHeight));
+ Space space = (Space) mAdditionalCards.findViewById(ADDITIONAL_CONTENT_SPACE_ID);
+ if (space == null) {
+ // No space view yet so lets create it one
+ space = new Space(getActivity());
+ space.setId(ADDITIONAL_CONTENT_SPACE_ID);
+ mAdditionalCards.addView(space,
+ new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
+ selectorHeight));
+ } else {
+ // Space view already exists so just update the LayoutParams
+ LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) space.getLayoutParams();
+ params.height = selectorHeight;
+ space.setLayoutParams(params);
+ }
final int startY = mScrollView.getScrollY();
final ValueAnimator scrollAnimator =
ValueAnimator.ofInt(startY, startY + yDelta);