FragmentTestActivity.java revision 2913b112d6089ea3e7ebe4a807394dd99f3ebc0f
1a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount/* 2a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount * Copyright (C) 2015 The Android Open Source Project 3a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount * 4a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount * Licensed under the Apache License, Version 2.0 (the "License"); 5a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount * you may not use this file except in compliance with the License. 6a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount * You may obtain a copy of the License at 7a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount * 8a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount * http://www.apache.org/licenses/LICENSE-2.0 9a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount * 10a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount * Unless required by applicable law or agreed to in writing, software 11a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount * distributed under the License is distributed on an "AS IS" BASIS, 12a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount * See the License for the specific language governing permissions and 14a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount * limitations under the License. 15a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount */ 16a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mountpackage android.support.v4.app.test; 17a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount 18a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mountimport android.app.Activity; 192913b112d6089ea3e7ebe4a807394dd99f3ebc0fAdam Powellimport android.content.Context; 20a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mountimport android.os.Build.VERSION; 21a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mountimport android.os.Build.VERSION_CODES; 22a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mountimport android.os.Bundle; 23a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mountimport android.support.v4.app.Fragment; 24a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mountimport android.support.v4.app.FragmentActivity; 252913b112d6089ea3e7ebe4a807394dd99f3ebc0fAdam Powellimport android.support.v4.app.FragmentManager; 26a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mountimport android.support.v4.test.R; 27a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mountimport android.transition.Transition; 28a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mountimport android.transition.Transition.TransitionListener; 29a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mountimport android.transition.TransitionInflater; 30a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mountimport android.view.LayoutInflater; 31a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mountimport android.view.View; 32a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mountimport android.view.ViewGroup; 33a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount 34a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount/** 352913b112d6089ea3e7ebe4a807394dd99f3ebc0fAdam Powell * A simple activity used for Fragment Transitions and lifecycle event ordering 36a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount */ 37a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mountpublic class FragmentTestActivity extends FragmentActivity { 38a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount @Override 39a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount public void onCreate(Bundle icicle) { 40a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount super.onCreate(icicle); 41a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount setContentView(R.layout.activity_content); 42a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount } 43a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount 44a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount public static class TestFragment extends Fragment { 45a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount public static final int ENTER = 0; 46a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount public static final int RETURN = 1; 47a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount public static final int EXIT = 2; 48a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount public static final int REENTER = 3; 49a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount public static final int SHARED_ELEMENT_ENTER = 4; 50a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount public static final int SHARED_ELEMENT_RETURN = 5; 51a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount private static final int TRANSITION_COUNT = 6; 52a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount 53a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount private static final String LAYOUT_ID = "layoutId"; 54a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount private static final String TRANSITION_KEY = "transition_"; 55a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount private int mLayoutId = R.layout.fragment_start; 56a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount private final int[] mTransitionIds = new int[] { 57a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount android.R.transition.explode, 58a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount android.R.transition.explode, 59a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount android.R.transition.fade, 60a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount android.R.transition.fade, 61a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount android.R.transition.move, 62a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount android.R.transition.move, 63a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount }; 64a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount private final TransitionCalledListener[] mListeners = 65a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount new TransitionCalledListener[TRANSITION_COUNT]; 66a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount private OnTransitionListener mOnTransitionListener; 67a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount 68a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount public TestFragment() { 69a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount for (int i = 0; i < TRANSITION_COUNT; i++) { 70a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount mListeners[i] = new TransitionCalledListener(); 71a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount } 72a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount } 73a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount 74a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount public static TestFragment create(int layoutId) { 75a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount TestFragment testFragment = new TestFragment(); 76a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount testFragment.mLayoutId = layoutId; 77a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount return testFragment; 78a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount } 79a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount 80a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount public void clearTransitions() { 81a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount for (int i = 0; i < TRANSITION_COUNT; i++) { 82a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount mTransitionIds[i] = 0; 83a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount } 84a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount } 85a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount 86a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount public void clearNotifications() { 87a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount for (int i = 0; i < TRANSITION_COUNT; i++) { 88a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount mListeners[i].transitionStarted = false; 89a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount mListeners[i].transitionEnded = false; 90a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount } 91a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount } 92a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount 93a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount @Override 94a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount public void onCreate(Bundle savedInstanceState) { 95a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount super.onCreate(savedInstanceState); 96a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount if (savedInstanceState != null) { 97a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount mLayoutId = savedInstanceState.getInt(LAYOUT_ID, mLayoutId); 98a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount for (int i = 0; i < TRANSITION_COUNT; i++) { 99a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount String key = TRANSITION_KEY + i; 100a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount mTransitionIds[i] = savedInstanceState.getInt(key, mTransitionIds[i]); 101a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount } 102a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount } 103a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount } 104a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount 105a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount @Override 106a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount public void onSaveInstanceState(Bundle outState) { 107a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount super.onSaveInstanceState(outState); 108a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount outState.putInt(LAYOUT_ID, mLayoutId); 109a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount for (int i = 0; i < TRANSITION_COUNT; i++) { 110a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount String key = TRANSITION_KEY + i; 111a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount outState.putInt(key, mTransitionIds[i]); 112a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount } 113a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount } 114a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount 115a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount @Override 116a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount public View onCreateView(LayoutInflater inflater, ViewGroup container, 117a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount Bundle savedInstanceState) { 118a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount return inflater.inflate(mLayoutId, container, false); 119a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount } 120a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount 121a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount @SuppressWarnings("deprecation") 122a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount @Override 123a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount public void onAttach(Activity activity) { 124a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount super.onAttach(activity); 125a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount if (VERSION.SDK_INT > VERSION_CODES.KITKAT) { 126a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount setEnterTransition(loadTransition(ENTER)); 127a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount setReenterTransition(loadTransition(REENTER)); 128a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount setExitTransition(loadTransition(EXIT)); 129a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount setReturnTransition(loadTransition(RETURN)); 130a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount setSharedElementEnterTransition(loadTransition(SHARED_ELEMENT_ENTER)); 131a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount setSharedElementReturnTransition(loadTransition(SHARED_ELEMENT_RETURN)); 132a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount } 133a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount } 134a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount 135a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount public void setOnTransitionListener(OnTransitionListener listener) { 136a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount mOnTransitionListener = listener; 137a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount } 138a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount 139a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount public boolean wasStartCalled(int transitionKey) { 140a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount return mListeners[transitionKey].transitionStarted; 141a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount } 142a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount 143a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount public boolean wasEndCalled(int transitionKey) { 144a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount return mListeners[transitionKey].transitionEnded; 145a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount } 146a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount 147a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount private Transition loadTransition(int key) { 148a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount final int id = mTransitionIds[key]; 149a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount if (id == 0) { 150a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount return null; 151a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount } 152a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount Transition transition = TransitionInflater.from(getActivity()).inflateTransition(id); 153a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount transition.addListener(mListeners[key]); 154a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount return transition; 155a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount } 156a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount 157a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount private void notifyTransition() { 158a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount if (mOnTransitionListener != null) { 159a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount mOnTransitionListener.onTransition(this); 160a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount } 161a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount } 162a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount 163a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount private class TransitionCalledListener implements TransitionListener { 164a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount public boolean transitionStarted; 165a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount public boolean transitionEnded; 166a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount 167a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount public TransitionCalledListener() { 168a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount } 169a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount 170a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount @Override 171a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount public void onTransitionStart(Transition transition) { 172a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount transitionStarted = true; 173a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount notifyTransition(); 174a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount } 175a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount 176a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount @Override 177a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount public void onTransitionEnd(Transition transition) { 178a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount transitionEnded = true; 179a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount notifyTransition(); 180a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount } 181a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount 182a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount @Override 183a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount public void onTransitionCancel(Transition transition) { 184a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount } 185a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount 186a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount @Override 187a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount public void onTransitionPause(Transition transition) { 188a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount } 189a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount 190a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount @Override 191a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount public void onTransitionResume(Transition transition) { 192a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount } 193a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount } 194a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount } 195a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount 196a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount public interface OnTransitionListener { 197a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount void onTransition(TestFragment fragment); 198a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount } 199a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount 2002913b112d6089ea3e7ebe4a807394dd99f3ebc0fAdam Powell public static class ParentFragment extends Fragment { 2012913b112d6089ea3e7ebe4a807394dd99f3ebc0fAdam Powell public boolean wasAttachedInTime; 2022913b112d6089ea3e7ebe4a807394dd99f3ebc0fAdam Powell @Override 2032913b112d6089ea3e7ebe4a807394dd99f3ebc0fAdam Powell public void onCreate(Bundle savedInstanceState) { 2042913b112d6089ea3e7ebe4a807394dd99f3ebc0fAdam Powell super.onCreate(savedInstanceState); 2052913b112d6089ea3e7ebe4a807394dd99f3ebc0fAdam Powell ChildFragment f = new ChildFragment(); 2062913b112d6089ea3e7ebe4a807394dd99f3ebc0fAdam Powell FragmentManager fm = getChildFragmentManager(); 2072913b112d6089ea3e7ebe4a807394dd99f3ebc0fAdam Powell fm.beginTransaction().add(f, "foo").commit(); 2082913b112d6089ea3e7ebe4a807394dd99f3ebc0fAdam Powell fm.executePendingTransactions(); 2092913b112d6089ea3e7ebe4a807394dd99f3ebc0fAdam Powell wasAttachedInTime = f.attached; 2102913b112d6089ea3e7ebe4a807394dd99f3ebc0fAdam Powell } 2112913b112d6089ea3e7ebe4a807394dd99f3ebc0fAdam Powell } 2122913b112d6089ea3e7ebe4a807394dd99f3ebc0fAdam Powell 2132913b112d6089ea3e7ebe4a807394dd99f3ebc0fAdam Powell public static class ChildFragment extends Fragment { 2142913b112d6089ea3e7ebe4a807394dd99f3ebc0fAdam Powell public boolean attached; 2152913b112d6089ea3e7ebe4a807394dd99f3ebc0fAdam Powell @Override 2162913b112d6089ea3e7ebe4a807394dd99f3ebc0fAdam Powell public void onAttach(Context activity) { 2172913b112d6089ea3e7ebe4a807394dd99f3ebc0fAdam Powell super.onAttach(activity); 2182913b112d6089ea3e7ebe4a807394dd99f3ebc0fAdam Powell attached = true; 2192913b112d6089ea3e7ebe4a807394dd99f3ebc0fAdam Powell } 2202913b112d6089ea3e7ebe4a807394dd99f3ebc0fAdam Powell } 221a1f95ec10cc7e88dcc1c57c92ac5d0c37c2d9553George Mount} 222