From 444b5107e3905641cdeacdad465aed78472649c9 Mon Sep 17 00:00:00 2001 From: Fan Zhang Date: Fri, 26 Oct 2018 11:34:00 -0700 Subject: [PATCH] Animate contextual cards in after loading. After initial loading, all cards slide down per material guideline. Test: visual Change-Id: I115e086a43fc9a2d4b4da3acad20be689fdee09d --- res/anim/item_animation_fall_down.xml | 42 +++++++++++++++++++ res/anim/layout_animation_fall_down.xml | 22 ++++++++++ res/layout/settings_homepage.xml | 3 +- .../ContextualCardsAdapter.java | 10 +++++ 4 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 res/anim/item_animation_fall_down.xml create mode 100644 res/anim/layout_animation_fall_down.xml diff --git a/res/anim/item_animation_fall_down.xml b/res/anim/item_animation_fall_down.xml new file mode 100644 index 00000000000..df2451cf638 --- /dev/null +++ b/res/anim/item_animation_fall_down.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/anim/layout_animation_fall_down.xml b/res/anim/layout_animation_fall_down.xml new file mode 100644 index 00000000000..f39735c157b --- /dev/null +++ b/res/anim/layout_animation_fall_down.xml @@ -0,0 +1,22 @@ + + + + \ No newline at end of file diff --git a/res/layout/settings_homepage.xml b/res/layout/settings_homepage.xml index 0ba36096672..bd54717367b 100644 --- a/res/layout/settings_homepage.xml +++ b/res/layout/settings_homepage.xml @@ -24,7 +24,8 @@ + android:layout_height="match_parent" + android:layoutAnimation="@anim/layout_animation_fall_down"/> mContextualCards; private final LifecycleOwner mLifecycleOwner; + private RecyclerView mRecyclerView; + public ContextualCardsAdapter(Context context, LifecycleOwner lifecycleOwner, ContextualCardManager manager) { mContext = context; @@ -89,6 +91,7 @@ public class ContextualCardsAdapter extends RecyclerView.Adapter> cards) { final List contextualCards = cards.get(ContextualCard.CardType.DEFAULT); + final boolean previouslyEmpty = mContextualCards.isEmpty(); + final boolean nowEmpty = contextualCards == null || contextualCards.isEmpty(); if (contextualCards == null) { mContextualCards.clear(); notifyDataSetChanged(); @@ -119,5 +124,10 @@ public class ContextualCardsAdapter extends RecyclerView.Adapter