Add lifecycle observers for future mixin structures.

- Converted VisibilityLoggerMixin into a LifecyclerObservable so we
  don't have to call logger.onResume/onPause manually in most fragments.
- Observable will be useful when we provide logics across all
  fragment/activity, eg log lifecycle event latencies.
- Also added new tests for lifecycle component.

Bug: 30681529
Test: RunSettingsRoboTests

Change-Id: Ida39300aeb42f71b2e0bbfaebd0c51dc468cb5e8
This commit is contained in:
Fan Zhang
2016-08-22 15:20:22 -07:00
parent 141c20c5e3
commit ea024155fb
19 changed files with 583 additions and 53 deletions

View File

@@ -58,7 +58,8 @@ public class ZonePicker extends ListFragment implements Instrumentable {
private static final int MENU_TIMEZONE = Menu.FIRST+1;
private static final int MENU_ALPHABETICAL = Menu.FIRST;
private final VisibilityLoggerMixin mVisibilityLoggerMixin = new VisibilityLoggerMixin(this);
private final VisibilityLoggerMixin mVisibilityLoggerMixin =
new VisibilityLoggerMixin(getMetricsCategory());
private boolean mSortedByTimezone;
@@ -185,7 +186,7 @@ public class ZonePicker extends ListFragment implements Instrumentable {
@Override
public void onResume() {
super.onResume();
mVisibilityLoggerMixin.onResume(getActivity());
mVisibilityLoggerMixin.onResume();
}
@Override
@@ -242,7 +243,7 @@ public class ZonePicker extends ListFragment implements Instrumentable {
@Override
public void onPause() {
super.onPause();
mVisibilityLoggerMixin.onPause(getActivity());
mVisibilityLoggerMixin.onPause();
}
private static class MyComparator implements Comparator<Map<?, ?>> {