Add a factory method to create a Lifecycle.
Some unit tests in other packages want to override the mLifecycle member with their own value. When the Lifecycle class moves into SettingsLib, the classpath of ObservableDialogFragment and Lifecycle have to remain consistent. This change allows dependent classes to remain agnostic to Lifecycle's classpath. Test: make RunSettingsGoogleRoboTests && make RunSettingsLibRoboTests && make RunSettingsRoboTests Change-Id: I594e447741aeeb3ba95afb4044d496b1540bd92c
This commit is contained in:
@@ -17,6 +17,7 @@ package com.android.settings.core.lifecycle;
|
|||||||
|
|
||||||
import android.app.DialogFragment;
|
import android.app.DialogFragment;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.support.annotation.VisibleForTesting;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
@@ -26,7 +27,7 @@ import android.view.MenuItem;
|
|||||||
*/
|
*/
|
||||||
public class ObservableDialogFragment extends DialogFragment {
|
public class ObservableDialogFragment extends DialogFragment {
|
||||||
|
|
||||||
protected final Lifecycle mLifecycle = new Lifecycle();
|
protected final Lifecycle mLifecycle = createLifecycle();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAttach(Context context) {
|
public void onAttach(Context context) {
|
||||||
@@ -84,4 +85,10 @@ public class ObservableDialogFragment extends DialogFragment {
|
|||||||
}
|
}
|
||||||
return lifecycleHandled;
|
return lifecycleHandled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting(otherwise = VisibleForTesting.NONE)
|
||||||
|
/** @return a new lifecycle. */
|
||||||
|
public static Lifecycle createLifecycle() {
|
||||||
|
return new Lifecycle();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user