2 * Copyright (C) 2011 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package android.support.v2.app;
19 import android.content.Context;
20 import android.os.Parcelable;
21 import android.util.SparseArray;
22 import android.view.View;
23 import android.view.ViewGroup;
24 import android.widget.FrameLayout;
27 * Pre-Honeycomb versions of the platform don't have View.setSaveFromParentEnabled(),
28 * so instead we insert this between the view and its parent.
30 public class NoSaveStateFrameLayout extends FrameLayout {
31 static ViewGroup wrap(View child) {
32 NoSaveStateFrameLayout wrapper = new NoSaveStateFrameLayout(child.getContext());
33 ViewGroup.LayoutParams childParams = child.getLayoutParams();
34 if (childParams != null) {
35 wrapper.setLayoutParams(childParams);
37 NoSaveStateFrameLayout.LayoutParams lp = new NoSaveStateFrameLayout.LayoutParams(
38 ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT);
39 child.setLayoutParams(lp);
40 wrapper.addView(child);
44 public NoSaveStateFrameLayout(Context context) {
49 * Override to prevent freezing of any child views.
52 protected void dispatchSaveInstanceState(SparseArray<Parcelable> container) {
53 dispatchFreezeSelfOnly(container);
57 * Override to prevent thawing of any child views.
60 protected void dispatchRestoreInstanceState(SparseArray<Parcelable> container) {
61 dispatchThawSelfOnly(container);