Use "mid" stable id for condition cards conditionally.

When there is no suggestion, use "mid" stableId instead of "top"
stableId for the header card.

This avoid an animation jank: when user swipes away a suggestion, the
condition summary header moves up instead of disappears then reappears.

Old behavior:

---  Suggestion ---   --swipe-->     /// Top Header ///
///  Mid Header ///

New behavior:

--- Suggestion ---   -- swipe -->   /// Mid Header ///
/// Mid Header ///

(Notice the header id change)

Change-Id: I63512d3d21382488e43dddb8819fabe4af40d101
Fixes: 65729560
Test: robotests
This commit is contained in:
Fan Zhang
2017-09-15 13:22:04 -07:00
parent d52c17c765
commit 135fecbee3
2 changed files with 52 additions and 15 deletions

View File

@@ -222,15 +222,22 @@ public class DashboardData {
final int hiddenSuggestion =
hasSuggestions ? sizeOf(mSuggestions) - sizeOf(suggestions) : 0;
final boolean hasSuggestionAndCollapsed = hasSuggestions
&& mSuggestionConditionMode == HEADER_MODE_COLLAPSED;
final boolean onlyHasConditionAndCollapsed = !hasSuggestions
&& hasConditions
&& mSuggestionConditionMode != HEADER_MODE_FULLY_EXPANDED;
/* Top suggestion/condition header. This will be present when there is any suggestion
* and the mode is collapsed, or it only has conditions and the mode is not fully
* expanded. */
* and the mode is collapsed */
addToItemList(new SuggestionConditionHeaderData(conditions, hiddenSuggestion),
R.layout.suggestion_condition_header,
STABLE_ID_SUGGESTION_CONDITION_TOP_HEADER,
hasSuggestions && mSuggestionConditionMode == HEADER_MODE_COLLAPSED
|| !hasSuggestions && hasConditions
&& mSuggestionConditionMode != HEADER_MODE_FULLY_EXPANDED);
STABLE_ID_SUGGESTION_CONDITION_TOP_HEADER, hasSuggestionAndCollapsed);
/* Use mid header if there is only condition & it's in collapsed mode */
addToItemList(new SuggestionConditionHeaderData(conditions, hiddenSuggestion),
R.layout.suggestion_condition_header,
STABLE_ID_SUGGESTION_CONDITION_MIDDLE_HEADER, onlyHasConditionAndCollapsed);
/* Suggestion container. This is the card view that contains the list of suggestions.
* This will be added whenever the suggestion list is not empty */