summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authored.mancebo <edmancebo@gmail.com>2015-04-12 15:19:56 -0700
committered.mancebo <edmancebo@gmail.com>2015-04-13 08:49:02 -0700
commit8817624b02fe275ef93522f2405908363e7383a8 (patch)
tree61ab4845f3bd728d355016c8335e7a423f440df6
parentdaf8076896b9ceb05b74f1d9dbcbc5b8c33c42ae (diff)
downloadandroid_external_cyanogen_UICommon-8817624b02fe275ef93522f2405908363e7383a8.tar.gz
android_external_cyanogen_UICommon-8817624b02fe275ef93522f2405908363e7383a8.tar.bz2
android_external_cyanogen_UICommon-8817624b02fe275ef93522f2405908363e7383a8.zip
Fix jank when resuming recent card fragment
- anchor top when no other cards are expanded - aux view height in dimens is no longer used, have to calculate dynamically Change-Id: I721a44fe689862a021c97ff0968a326b0366e212
-rw-r--r--res/values/dimens.xml1
-rw-r--r--src/com/cyngn/uicommon/view/ExpandingCard.java33
2 files changed, 8 insertions, 26 deletions
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index fb1200e..4d10050 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
- <dimen name="expanding_card_aux_height">50dp</dimen>
<dimen name="expanding_card_elevation">5dp</dimen>
</resources>
diff --git a/src/com/cyngn/uicommon/view/ExpandingCard.java b/src/com/cyngn/uicommon/view/ExpandingCard.java
index e69b755..b3b32b6 100644
--- a/src/com/cyngn/uicommon/view/ExpandingCard.java
+++ b/src/com/cyngn/uicommon/view/ExpandingCard.java
@@ -59,7 +59,6 @@ public class ExpandingCard extends FrameLayout {
private View mAuxView;
private int mAuxTop = -1;
- private int mAuxHeight;
private int mMainBottom = -1;
private ColorDrawable mColor;
private GradientDrawable mColorSelected;
@@ -88,7 +87,6 @@ public class ExpandingCard extends FrameLayout {
mAuxView = findViewById(R.id.auxiliaryView);
Resources res = getResources();
- mAuxHeight = res.getDimensionPixelSize(R.dimen.expanding_card_aux_height);
mCardElevation = res.getDimensionPixelSize(R.dimen.expanding_card_elevation);
mColor = new ColorDrawable(res.getColor(R.color.expanding_card_color));
mColorSelected = new GradientDrawable(GradientDrawable.Orientation.BOTTOM_TOP,
@@ -103,8 +101,8 @@ public class ExpandingCard extends FrameLayout {
public void expand(AnimationType type) {
mAuxView.setVisibility(View.VISIBLE);
- int mid = getAuxTop();
- int bottom = getMainBottom();
+ int mid = mMainView.getHeight() - mAuxView.getHeight();
+ int bottom = mMainView.getHeight();
ValueAnimator anim = null;
switch(type) {
@@ -142,7 +140,8 @@ public class ExpandingCard extends FrameLayout {
scrollingNeeded = mRowContainer.getTop(); // view at top/partially visible
} else {
int listViewHeight = mList.getHeight();
- int offset = mRowContainer.getTop() + mRowContainer.getHeight() + mAuxHeight - listViewHeight;
+ int offset = mRowContainer.getTop() + mRowContainer.getHeight()
+ + mAuxView.getHeight() - listViewHeight;
if (offset > 0) {
scrollingNeeded = offset;
}
@@ -224,13 +223,13 @@ public class ExpandingCard extends FrameLayout {
@Override
public void onAnimationEnd(Animator animation) {
- mAuxView.setVisibility(View.GONE);
+ mAuxView.setVisibility(View.INVISIBLE);
}
});
set.start();
} else {
// layouts are already collapsed. reset colors/visibility for completeness
- mAuxView.setVisibility(View.GONE);
+ mAuxView.setVisibility(View.INVISIBLE);
resetColors();
}
}
@@ -286,7 +285,7 @@ public class ExpandingCard extends FrameLayout {
if (mRowContainer != null) {
mRowContainer.setTranslationZ(0);
}
- mAuxView.setVisibility(View.GONE);
+ mAuxView.setVisibility(View.INVISIBLE);
new BottomMarginSetter().setMargin(mMainView, 0);
new TopMarginSetter().setMargin(mAuxView, 0);
mAuxTop = -1;
@@ -315,22 +314,6 @@ public class ExpandingCard extends FrameLayout {
}
}
- private int getAuxTop() {
- if (mAuxTop < 0) {
- mAuxTop = getMainBottom() - mAuxHeight;
- }
- return mAuxTop;
- }
-
- private int getMainBottom() {
- if (mMainBottom < 0) {
- // assumption: main view is bigger than aux view. We could use getBottom here,
- // but getHeight seems more robust since the height never changes
- mMainBottom = mMainView.getHeight();
- }
- return mMainBottom;
- }
-
private static interface MarginSetter {
public void setMargin(View v, int margin);
}
@@ -399,7 +382,7 @@ public class ExpandingCard extends FrameLayout {
}
}
}
- if (position > selectedCardPosition) {
+ if (selectedCardPosition != -1 && position > selectedCardPosition) {
card.expand(AnimationType.ANCHOR_BOTTOM);
} else {
card.expand(AnimationType.ANCHOR_TOP);