summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanesh M <daneshm90@gmail.com>2015-04-02 22:05:43 -0700
committerDanesh M <daneshm90@gmail.com>2015-04-03 11:28:20 -0700
commit9dd03b41452ec2b6f920cfdb04f8b75cb9d29f17 (patch)
treeac9bf5672b8a014828e3208f560938d49a569f2c
parentc573162e299436e08551fdc71ad481a9919fbcea (diff)
downloadandroid_external_cyanogen_UICommon-9dd03b41452ec2b6f920cfdb04f8b75cb9d29f17.tar.gz
android_external_cyanogen_UICommon-9dd03b41452ec2b6f920cfdb04f8b75cb9d29f17.tar.bz2
android_external_cyanogen_UICommon-9dd03b41452ec2b6f920cfdb04f8b75cb9d29f17.zip
UiCommon : Change to id instead of position
Position is unstable, switch to id Change-Id: I9829a131b1a0f70dbcf009a493a2135d066635c3
-rw-r--r--src/com/cyngn/uicommon/view/ExpandingCard.java21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/com/cyngn/uicommon/view/ExpandingCard.java b/src/com/cyngn/uicommon/view/ExpandingCard.java
index 1531166..f1e0d56 100644
--- a/src/com/cyngn/uicommon/view/ExpandingCard.java
+++ b/src/com/cyngn/uicommon/view/ExpandingCard.java
@@ -3,7 +3,6 @@ package com.cyngn.uicommon.view;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
-import android.animation.ArgbEvaluator;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.Context;
@@ -362,7 +361,7 @@ public class ExpandingCard extends FrameLayout {
* handler to manage expanding/collpasing.
*/
public static class ExpandingCardManager {
- private int mSelectedPosition = -1;
+ private long mSelectedCardId = -1;
private ExpandingCard mSelectedCard;
private ListView mList;
@@ -375,22 +374,22 @@ public class ExpandingCard extends FrameLayout {
* in the list
*
* @param card
- * @param position
+ * @param cardId
*/
- public void onBindExpandingCard(final ExpandingCard card, final int position) {
+ public void onBindExpandingCard(final ExpandingCard card, final long cardId) {
card.reset();
card.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- if (position == mSelectedPosition) {
+ if (cardId == mSelectedCardId) {
card.collapse();
- mSelectedPosition = -1;
+ mSelectedCardId = -1;
mSelectedCard = null;
} else {
// when the selection is moved from one card to another, we want the
// newly selected card to expand into the space left by the collpasing
// one.
- if (mSelectedPosition >= 0 && position > mSelectedPosition) {
+ if (mSelectedCardId >= 0 && cardId > mSelectedCardId) {
card.expand(AnimationType.ANCHOR_BOTTOM);
} else {
card.expand(AnimationType.ANCHOR_TOP);
@@ -399,18 +398,18 @@ public class ExpandingCard extends FrameLayout {
// If the currently selected card is in view, animate it closing.
// We're assuming that our reference to the selected card view is still
// valid is long as it is visible.
- if (mSelectedPosition >= mList.getFirstVisiblePosition() &&
- mSelectedPosition <= mList.getLastVisiblePosition() &&
+ if (mSelectedCardId >= mList.getFirstVisiblePosition() &&
+ mSelectedCardId <= mList.getLastVisiblePosition() &&
mSelectedCard != null) {
mSelectedCard.collapse();
}
- mSelectedPosition = position;
+ mSelectedCardId = cardId;
mSelectedCard = card;
}
}
});
- if (position == mSelectedPosition) {
+ if (cardId == mSelectedCardId) {
// selected card is coming back into view on a scroll, show selected
// state without animation
mSelectedCard = card;