LoaderLifecycleTest.java revision 180202f2211d8c6bbb7a7057e61dafc90fe31930
1180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell/*
2180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell * Copyright (C) 2016 The Android Open Source Project
3180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell *
4180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell * Licensed under the Apache License, Version 2.0 (the "License");
5180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell * you may not use this file except in compliance with the License.
6180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell * You may obtain a copy of the License at
7180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell *
8180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell *      http://www.apache.org/licenses/LICENSE-2.0
9180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell *
10180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell * Unless required by applicable law or agreed to in writing, software
11180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell * distributed under the License is distributed on an "AS IS" BASIS,
12180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell * See the License for the specific language governing permissions and
14180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell * limitations under the License.
15180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell */
16180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell
17180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell
18180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powellpackage android.app;
19180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell
20180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powellimport android.content.Context;
21180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powellimport android.os.Handler;
22180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powellimport android.os.Parcelable;
23180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powellimport android.support.test.filters.MediumTest;
24180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powellimport android.support.test.rule.ActivityTestRule;
25180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powellimport android.support.test.runner.AndroidJUnit4;
26180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powellimport android.util.ArrayMap;
27180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powellimport org.junit.Rule;
28180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powellimport org.junit.Test;
29180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powellimport org.junit.runner.RunWith;
30180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell
31180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powellimport static junit.framework.TestCase.assertNotNull;
32180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powellimport static junit.framework.TestCase.assertNotSame;
33180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powellimport static junit.framework.TestCase.assertSame;
34180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell
35180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell@RunWith(AndroidJUnit4.class)
36180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powellpublic class LoaderLifecycleTest {
37180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell    @Rule
38180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell    public ActivityTestRule<EmptyActivity> mActivityRule =
39180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            new ActivityTestRule<>(EmptyActivity.class);
40180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell    @Test
41180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell    @MediumTest
42180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell    public void loaderIdentityTest() throws Throwable{
43180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell        mActivityRule.runOnUiThread(() -> {
44180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            final Handler h = new Handler();
45180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            final FragmentController fc1 = FragmentController.createController(
46180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell                    new TestFragmentHostCallback(mActivityRule.getActivity(), h, 0));
47180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell
48180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc1.attachHost(null);
49180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc1.dispatchCreate();
50180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell
51180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            final FragmentManager fm1 = fc1.getFragmentManager();
52180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell
53180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            final Fragment f1 = new Fragment();
54180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fm1.beginTransaction().add(f1, "one").commitNow();
55180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell
56180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            // Removing and re-adding a fragment completely will destroy its LoaderManager.
57180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            // Keep the first one here to confirm this later.
58180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            final LoaderManager lm1 = f1.getLoaderManager();
59180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell
60180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            // Remove the fragment, add a second one, and re-add the first to
61180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            // force its internal index to change. The tests below should still remain consistent.
62180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            final Fragment f2 = new Fragment();
63180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fm1.beginTransaction().remove(f1).commitNow();
64180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fm1.beginTransaction().add(f2, "two").commitNow();
65180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fm1.beginTransaction().add(f1, "one").commitNow();
66180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell
67180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            // We'll check this to see if we get the same instance back later
68180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            // as passed through NonConfigurationInstance. If the keys stay consistent
69180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            // across fragment remove/re-add, this will be consistent.
70180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            final LoaderManager lm12 = f1.getLoaderManager();
71180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell
72180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            assertNotSame("fully removed and re-added fragment got same LoaderManager", lm1, lm12);
73180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell
74180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc1.dispatchActivityCreated();
75180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc1.noteStateNotSaved();
76180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc1.execPendingActions();
77180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc1.doLoaderStart();
78180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc1.dispatchStart();
79180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc1.reportLoaderStart();
80180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc1.dispatchResume();
81180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc1.execPendingActions();
82180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell
83180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            // Bring the state back down to destroyed, simulating an activity restart
84180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc1.dispatchPause();
85180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            final Parcelable savedState = fc1.saveAllState();
86180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc1.doLoaderStop(true);
87180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc1.dispatchStop();
88180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            final FragmentManagerNonConfig nonconf = fc1.retainNestedNonConfig();
89180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell
90180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            final ArrayMap<String, LoaderManager> loaderNonConfig = fc1.retainLoaderNonConfig();
91180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            assertNotNull("loaderNonConfig was null", loaderNonConfig);
92180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell
93180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc1.dispatchDestroy();
94180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell
95180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            // Create the new controller and restore state
96180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            final FragmentController fc2 = FragmentController.createController(
97180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell                    new TestFragmentHostCallback(mActivityRule.getActivity(), h, 0));
98180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell
99180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            final FragmentManager fm2 = fc2.getFragmentManager();
100180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell
101180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc2.attachHost(null);
102180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc2.restoreLoaderNonConfig(loaderNonConfig);
103180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc2.restoreAllState(savedState, nonconf);
104180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc2.dispatchCreate();
105180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell
106180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell
107180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc2.dispatchActivityCreated();
108180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc2.noteStateNotSaved();
109180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc2.execPendingActions();
110180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc2.doLoaderStart();
111180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc2.dispatchStart();
112180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc2.reportLoaderStart();
113180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc2.dispatchResume();
114180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc2.execPendingActions();
115180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell
116180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            // Test that the fragments are in the configuration we expect
117180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            final Fragment restoredOne = fm2.findFragmentByTag("one");
118180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            final LoaderManager lm2 = restoredOne.getLoaderManager();
119180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell
120180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            assertSame("didn't get same LoaderManager instance back", lm2, lm12);
121180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell
122180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            // Bring the state back down to destroyed before we finish the test
123180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc2.dispatchPause();
124180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc2.saveAllState();
125180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc2.dispatchStop();
126180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc2.dispatchDestroy();
127180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell        });
128180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell    }
129180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell
130180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell    @Test
131180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell    @MediumTest
132180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell    public void backStackLoaderIdentityTest() throws Throwable{
133180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell        mActivityRule.runOnUiThread(() -> {
134180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            final Handler h = new Handler();
135180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            final FragmentHostCallback host1 =
136180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell                    new TestFragmentHostCallback(mActivityRule.getActivity(), h, 0);
137180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            final FragmentController fc1 = FragmentController.createController(host1);
138180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell
139180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc1.attachHost(null);
140180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc1.dispatchCreate();
141180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell
142180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            final FragmentManager fm1 = fc1.getFragmentManager();
143180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell
144180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            final Fragment f1 = new Fragment();
145180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fm1.beginTransaction().add(f1, "one").commitNow();
146180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell
147180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            final LoaderManager lm1 = f1.getLoaderManager();
148180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell
149180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            // Put the fragment on the back stack.
150180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fm1.beginTransaction().remove(f1).addToBackStack("backentry").commit();
151180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fm1.executePendingTransactions();
152180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell
153180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc1.dispatchActivityCreated();
154180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc1.noteStateNotSaved();
155180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc1.execPendingActions();
156180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc1.doLoaderStart();
157180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc1.dispatchStart();
158180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc1.reportLoaderStart();
159180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc1.dispatchResume();
160180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc1.execPendingActions();
161180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell
162180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            // Bring the state back down to destroyed, simulating an activity restart
163180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc1.dispatchPause();
164180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            final Parcelable savedState = fc1.saveAllState();
165180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc1.doLoaderStop(true);
166180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc1.dispatchStop();
167180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            final FragmentManagerNonConfig nonconf = fc1.retainNestedNonConfig();
168180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell
169180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            final ArrayMap<String, LoaderManager> loaderNonConfig = fc1.retainLoaderNonConfig();
170180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            assertNotNull("loaderNonConfig was null", loaderNonConfig);
171180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell
172180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc1.dispatchDestroy();
173180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell
174180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            // Create the new controller and restore state
175180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            final FragmentHostCallback host2 =
176180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell                    new TestFragmentHostCallback(mActivityRule.getActivity(), h, 0);
177180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            final FragmentController fc2 = FragmentController.createController(host2);
178180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell
179180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            final FragmentManager fm2 = fc2.getFragmentManager();
180180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell
181180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc2.attachHost(null);
182180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc2.restoreLoaderNonConfig(loaderNonConfig);
183180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc2.restoreAllState(savedState, nonconf);
184180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc2.dispatchCreate();
185180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell
186180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell
187180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc2.dispatchActivityCreated();
188180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc2.noteStateNotSaved();
189180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc2.execPendingActions();
190180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc2.doLoaderStart();
191180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc2.dispatchStart();
192180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc2.reportLoaderStart();
193180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc2.dispatchResume();
194180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc2.execPendingActions();
195180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell
196180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            assertNotSame("LoaderManager kept reference to old FragmentHostCallback",
197180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell                    host1, lm1.getFragmentHostCallback());
198180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            assertSame("LoaderManager did not refrence new FragmentHostCallback",
199180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell                    host2, lm1.getFragmentHostCallback());
200180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell
201180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            // Test that the fragments are in the configuration we expect
202180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            final Fragment restoredOne = fm2.findFragmentByTag("one");
203180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            final LoaderManager lm2 = restoredOne.getLoaderManager();
204180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell
205180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            assertSame("didn't get same LoaderManager instance back", lm2, lm1);
206180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell
207180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            // Bring the state back down to destroyed before we finish the test
208180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc2.dispatchPause();
209180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc2.saveAllState();
210180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc2.dispatchStop();
211180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            fc2.dispatchDestroy();
212180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell        });
213180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell    }
214180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell
215180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell    public class TestFragmentHostCallback extends FragmentHostCallback<LoaderLifecycleTest> {
216180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell        public TestFragmentHostCallback(Context context, Handler handler, int windowAnimations) {
217180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            super(context, handler, windowAnimations);
218180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell        }
219180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell
220180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell        @Override
221180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell        public LoaderLifecycleTest onGetHost() {
222180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell            return LoaderLifecycleTest.this;
223180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell        }
224180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell    }
225180202f2211d8c6bbb7a7057e61dafc90fe31930Adam Powell}
226