summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanesh Mondegarian <daneshm90@gmail.com>2015-04-04 19:12:59 -0700
committerDanesh Mondegarian <daneshm90@gmail.com>2015-04-05 12:10:38 -0700
commitdaf8076896b9ceb05b74f1d9dbcbc5b8c33c42ae (patch)
tree2734c2a57ce5e12395260b08d63446a659554e44
parent4925832e64c8e5f258ff57d39e8ab80a6cdf79cc (diff)
downloadandroid_external_cyanogen_UICommon-daf8076896b9ceb05b74f1d9dbcbc5b8c33c42ae.tar.gz
android_external_cyanogen_UICommon-daf8076896b9ceb05b74f1d9dbcbc5b8c33c42ae.tar.bz2
android_external_cyanogen_UICommon-daf8076896b9ceb05b74f1d9dbcbc5b8c33c42ae.zip
UiCommon : Use position + id for tracking collapse/expand state
Change-Id: Ie85f58f5c1d5bbee5651798068b79b93c0f25ce9
-rw-r--r--src/com/cyngn/uicommon/view/ExpandingCard.java18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/com/cyngn/uicommon/view/ExpandingCard.java b/src/com/cyngn/uicommon/view/ExpandingCard.java
index f1e0d56..e69b755 100644
--- a/src/com/cyngn/uicommon/view/ExpandingCard.java
+++ b/src/com/cyngn/uicommon/view/ExpandingCard.java
@@ -376,7 +376,7 @@ public class ExpandingCard extends FrameLayout {
* @param card
* @param cardId
*/
- public void onBindExpandingCard(final ExpandingCard card, final long cardId) {
+ public void onBindExpandingCard(final ExpandingCard card, final long cardId, final int position) {
card.reset();
card.setOnClickListener(new View.OnClickListener() {
@Override
@@ -386,10 +386,20 @@ public class ExpandingCard extends FrameLayout {
mSelectedCardId = -1;
mSelectedCard = null;
} else {
+ int selectedCardPosition = -1;
// 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 (mSelectedCardId >= 0 && cardId > mSelectedCardId) {
+ if (mSelectedCardId >= 0) {
+ for (int i = mList.getFirstVisiblePosition(); i <= mList.getLastVisiblePosition(); i++) {
+ long id = mList.getAdapter().getItemId(i);
+ if (id == mSelectedCardId) {
+ selectedCardPosition = i;
+ break;
+ }
+ }
+ }
+ if (position > selectedCardPosition) {
card.expand(AnimationType.ANCHOR_BOTTOM);
} else {
card.expand(AnimationType.ANCHOR_TOP);
@@ -398,9 +408,7 @@ 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 (mSelectedCardId >= mList.getFirstVisiblePosition() &&
- mSelectedCardId <= mList.getLastVisiblePosition() &&
- mSelectedCard != null) {
+ if (mSelectedCard != null && selectedCardPosition >= 0) {
mSelectedCard.collapse();
}