diff options
author | Yorke Lee <yorkelee@google.com> | 2015-02-06 14:50:35 -0800 |
---|---|---|
committer | Yorke Lee <yorkelee@google.com> | 2015-02-17 13:48:55 -0800 |
commit | 2b94c39bb8e54ae2bd78e582e8161f783c9dc516 (patch) | |
tree | 5286346f4956ee4e1805825e39a3a66e29038dd2 /src/com/android/dialer/list/ListsFragment.java | |
parent | d9d409a86330c5fde0cc465562c6d3eb96ec10eb (diff) |
Remove shortcut cards list view
Remove ListView containing shortcut cards and replace it with a single
ShortcutCard card.
Rename ShortcutCardAdapter to ShortcutCardManager with slight refactor.
Some corresponding logic changes inside ListsFragment.
Reduces the number of getView calls at startup from 4 to 1.
Change-Id: I11787bdb1d04cc19634c21bfd398b7533c75d339
Diffstat (limited to 'src/com/android/dialer/list/ListsFragment.java')
-rw-r--r-- | src/com/android/dialer/list/ListsFragment.java | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/src/com/android/dialer/list/ListsFragment.java b/src/com/android/dialer/list/ListsFragment.java index e9ce57b85..b303d0011 100644 --- a/src/com/android/dialer/list/ListsFragment.java +++ b/src/com/android/dialer/list/ListsFragment.java @@ -76,7 +76,7 @@ public class ListsFragment extends Fragment implements CallLogQueryHandler.Liste private ViewPager mViewPager; private ViewPagerTabs mViewPagerTabs; private ViewPagerAdapter mViewPagerAdapter; - private ListView mShortcutCardsListView; + private SwipeableShortcutCard mShortcutCard; private RemoveView mRemoveView; private View mRemoveViewContent; private SpeedDialFragment mSpeedDialFragment; @@ -87,7 +87,6 @@ public class ListsFragment extends Fragment implements CallLogQueryHandler.Liste private String[] mTabTitles; - private ShortcutCardsAdapter mMergedAdapter; private CallLogAdapter mCallLogAdapter; private CallLogQueryHandler mCallLogQueryHandler; private OverlappingPaneLayout mOverlappingPaneLayout; @@ -112,16 +111,16 @@ public class ListsFragment extends Fragment implements CallLogQueryHandler.Liste // edge of the shortcut card, to achieve the animated effect of the shortcut card // being pushed out of view when the panel is slid upwards. slideOffset is 1 when // the shortcut card is fully exposed, and 0 when completely hidden. - float ratioCardHidden = (1 - slideOffset); - if (mShortcutCardsListView.getChildCount() > 0) { - final SwipeableShortcutCard v = - (SwipeableShortcutCard) mShortcutCardsListView.getChildAt(0); - v.clipCard(ratioCardHidden); + if (mShortcutCard.isShown()) { + float ratioCardHidden = (1 - slideOffset); + mShortcutCard.clipCard(ratioCardHidden); } if (mActionBar != null) { // Amount of available space that is not being hidden by the bottom pane - final int topPaneHeight = (int) (slideOffset * mShortcutCardsListView.getHeight()); + final int shortcutCardHeight = + mShortcutCard.isShown() ? mShortcutCard.getHeight() : 0; + final int topPaneHeight = (int) (slideOffset * shortcutCardHeight); final int availableActionBarHeight = Math.min(mActionBar.getHeight(), topPaneHeight); @@ -250,7 +249,6 @@ public class ListsFragment extends Fragment implements CallLogQueryHandler.Liste mCallLogAdapter = ObjectFactory.newCallLogAdapter(getActivity(), this, new ContactInfoHelper(getActivity(), currentCountryIso), null, null, false); - mMergedAdapter = new ShortcutCardsAdapter(getActivity(), this, mCallLogAdapter); Trace.endSection(); Trace.endSection(); } @@ -309,8 +307,8 @@ public class ListsFragment extends Fragment implements CallLogQueryHandler.Liste mViewPagerTabs.setViewPager(mViewPager); addOnPageChangeListener(mViewPagerTabs); - mShortcutCardsListView = (ListView) parentView.findViewById(R.id.shortcut_card_list); - mShortcutCardsListView.setAdapter(mMergedAdapter); + mShortcutCard = (SwipeableShortcutCard) parentView.findViewById(R.id.shortcut_card); + new ShortcutCardsManager(getActivity(), this, mCallLogAdapter, mShortcutCard); mRemoveView = (RemoveView) parentView.findViewById(R.id.remove_view); mRemoveViewContent = parentView.findViewById(R.id.remove_view_content); @@ -337,7 +335,6 @@ public class ListsFragment extends Fragment implements CallLogQueryHandler.Liste } mCallLogAdapter.changeCursor(cursor); - mMergedAdapter.notifyDataSetChanged(); // Refresh the overlapping pane to ensure that any changes in the shortcut card height // are appropriately reflected in the overlap position. @@ -398,11 +395,12 @@ public class ListsFragment extends Fragment implements CallLogQueryHandler.Liste mRemoveView.setAlpha(show ? 0 : 1); mRemoveView.animate().alpha(show ? 1 : 0).start(); - if (mShortcutCardsListView.getChildCount() > 0) { - View v = mShortcutCardsListView.getChildAt(0); - v.animate().withLayer() - .alpha(show ? REMOVE_VIEW_SHOWN_ALPHA : REMOVE_VIEW_HIDDEN_ALPHA) - .start(); + if (mShortcutCard.isShown()) { + final View child = mShortcutCard.getChildAt(0); + if (child != null) { + child.animate().withLayer() + .alpha(show ? REMOVE_VIEW_SHOWN_ALPHA : REMOVE_VIEW_HIDDEN_ALPHA).start(); + } } } |