diff options
author | Yorke Lee <yorkelee@google.com> | 2014-10-28 16:12:05 -0700 |
---|---|---|
committer | Yorke Lee <yorkelee@google.com> | 2014-10-28 16:12:05 -0700 |
commit | c98a5bb2d806dde99325a15466a2bf144d216ae8 (patch) | |
tree | 01189516a8fe7750162c9c5d9d2b648ef632c185 /src/com/android/dialer/list | |
parent | b4aac521569a933a6e7789e9dc25014bdd82d57c (diff) |
Refactor ActionBarController and tests
The original CL to fix ActionBarControllerTest by using an
ActivityInstrumentationTestCase was too heavyweight and caused flaky
test. It was also indicative of a flaw in the original design that
ActionBar couldn't be mocked out easily.
Refactor the code so that:
1) getActionBar() is no longer needed
2) Respect the invariant that all access to the actionBar goes through the
ActionBarController (see the changes in ListsFragment) so that any change to
the ActionBar's hide offset can be tracked appropriately.
Bug: 17487016
Change-Id: I935b683ddb301ca5d3952889af1381bdbdcc97d3
Diffstat (limited to 'src/com/android/dialer/list')
-rw-r--r-- | src/com/android/dialer/list/ListsFragment.java | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/com/android/dialer/list/ListsFragment.java b/src/com/android/dialer/list/ListsFragment.java index de501f47e..8e2500aa8 100644 --- a/src/com/android/dialer/list/ListsFragment.java +++ b/src/com/android/dialer/list/ListsFragment.java @@ -30,6 +30,7 @@ import com.android.dialer.calllog.CallLogQueryHandler; import com.android.dialer.calllog.ContactInfoHelper; import com.android.dialer.list.ShortcutCardsAdapter.SwipeableShortcutCard; import com.android.dialer.util.DialerUtils; +import com.android.dialer.widget.ActionBarController; import com.android.dialer.widget.OverlappingPaneLayout; import com.android.dialer.widget.OverlappingPaneLayout.PanelSlideCallbacks; import com.android.dialerbind.ObjectFactory; @@ -68,8 +69,7 @@ public class ListsFragment extends AnalyticsFragment implements CallLogQueryHand public interface HostInterface { public void showCallHistory(); - public int getActionBarHeight(); - public void setActionBarHideOffset(int offset); + public ActionBarController getActionBarController(); } private ActionBar mActionBar; @@ -124,8 +124,9 @@ public class ListsFragment extends AnalyticsFragment implements CallLogQueryHand final int availableActionBarHeight = Math.min(mActionBar.getHeight(), topPaneHeight); - ((HostInterface) getActivity()).setActionBarHideOffset( - mActionBar.getHeight() - availableActionBarHeight); + final ActionBarController controller = + ((HostInterface) getActivity()).getActionBarController(); + controller.setHideOffset(mActionBar.getHeight() - availableActionBarHeight); if (!mActionBar.isShowing()) { mActionBar.show(); @@ -407,7 +408,7 @@ public class ListsFragment extends AnalyticsFragment implements CallLogQueryHand paneLayout.openPane(); paneLayout.setPanelSlideCallbacks(mPanelSlideCallbacks); paneLayout.setIntermediatePinnedOffset( - ((HostInterface) getActivity()).getActionBarHeight()); + ((HostInterface) getActivity()).getActionBarController().getActionBarHeight()); LayoutTransition transition = paneLayout.getLayoutTransition(); // Turns on animations for all types of layout changes so that they occur for |