1282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski/*
2282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * Copyright (C) 2011 The Android Open Source Project
3282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski *
4282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * Licensed under the Apache License, Version 2.0 (the "License");
5282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * you may not use this file except in compliance with the License.
6282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * You may obtain a copy of the License at
7282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski *
8282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski *      http://www.apache.org/licenses/LICENSE-2.0
9282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski *
10282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * Unless required by applicable law or agreed to in writing, software
11282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * distributed under the License is distributed on an "AS IS" BASIS,
12282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * See the License for the specific language governing permissions and
14282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * limitations under the License.
15282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski */
16282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
17282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinskipackage android.view;
18282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
19282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinskiimport com.android.tools.layoutlib.annotations.LayoutlibDelegate;
20282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
21282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinskiimport org.xmlpull.v1.XmlPullParser;
22282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinskiimport org.xmlpull.v1.XmlPullParserException;
23282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
246194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viveretteimport android.content.Context;
25282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinskiimport android.content.res.TypedArray;
26282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinskiimport android.content.res.XmlResourceParser;
27282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinskiimport android.util.AttributeSet;
286194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viveretteimport android.util.TypedValue;
29282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinskiimport android.util.Xml;
30282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
31282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinskiimport java.io.IOException;
32282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
33282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski/**
34282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * Delegate used to provide new implementation of a select few methods of {@link LayoutInflater}
35282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski *
36282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * Through the layoutlib_create tool, the original  methods of LayoutInflater have been replaced
37282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * by calls to methods of the same name in this delegate class.
38282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski *
39282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski */
40282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinskipublic class LayoutInflater_Delegate {
41282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski    private static final String TAG_MERGE = "merge";
42282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
436194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette    private static final String ATTR_LAYOUT = "layout";
446194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette
456194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette    private static final int[] ATTRS_THEME = new int[] {
466194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette            com.android.internal.R.attr.theme };
476194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette
48282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski    public static boolean sIsInInclude = false;
49282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
50282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski    /**
51282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski     * Recursive method used to descend down the xml hierarchy and instantiate
52282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski     * views, instantiate their children, and then call onFinishInflate().
53282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski     *
54282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski     * This implementation just records the merge status before calling the default implementation.
55282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski     */
56282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski    @LayoutlibDelegate
57ebcef6b896b3b1693862aad9c5000c450ba598a5Alan Viverette    /* package */ static void rInflate(LayoutInflater thisInflater, XmlPullParser parser,
586194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette            View parent, Context context, AttributeSet attrs, boolean finishInflate)
59ebcef6b896b3b1693862aad9c5000c450ba598a5Alan Viverette            throws XmlPullParserException, IOException {
60282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
61282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski        if (finishInflate == false) {
62282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski            // this is a merge rInflate!
63282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski            if (thisInflater instanceof BridgeInflater) {
64282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                ((BridgeInflater) thisInflater).setIsInMerge(true);
65282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski            }
66282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski        }
67282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
68282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski        // ---- START DEFAULT IMPLEMENTATION.
69282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
706194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette        thisInflater.rInflate_Original(parser, parent, context, attrs, finishInflate);
71282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
72282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski        // ---- END DEFAULT IMPLEMENTATION.
73282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
74282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski        if (finishInflate == false) {
75282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski            // this is a merge rInflate!
76282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski            if (thisInflater instanceof BridgeInflater) {
77282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                ((BridgeInflater) thisInflater).setIsInMerge(false);
78282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski            }
79282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski        }
80282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski    }
81282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
82282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski    @LayoutlibDelegate
836194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette    public static void parseInclude(LayoutInflater thisInflater, XmlPullParser parser,
846194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette            Context context, View parent, AttributeSet attrs)
856194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette            throws XmlPullParserException, IOException {
86282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski        int type;
87282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
88282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski        if (parent instanceof ViewGroup) {
896194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette            // Apply a theme wrapper, if requested. This is sort of a weird
906194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette            // edge case, since developers think the <include> overwrites
916194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette            // values in the AttributeSet of the included View. So, if the
926194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette            // included View has a theme attribute, we'll need to ignore it.
936194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette            final TypedArray ta = context.obtainStyledAttributes(attrs, ATTRS_THEME);
946194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette            final int themeResId = ta.getResourceId(0, 0);
956194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette            final boolean hasThemeOverride = themeResId != 0;
966194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette            if (hasThemeOverride) {
976194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette                context = new ContextThemeWrapper(context, themeResId);
986194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette            }
996194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette            ta.recycle();
1006194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette
1016194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette            // If the layout is pointing to a theme attribute, we have to
1026194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette            // massage the value to get a resource identifier out of it.
1036194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette            int layout = attrs.getAttributeResourceValue(null, ATTR_LAYOUT, 0);
104282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski            if (layout == 0) {
1056194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette                final String value = attrs.getAttributeValue(null, ATTR_LAYOUT);
1066194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette                if (value == null || value.length() <= 0) {
1076194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette                    throw new InflateException("You must specify a layout in the"
1086194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette                            + " include tag: <include layout=\"@layout/layoutID\" />");
1096194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette                }
1106194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette
1116194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette                // Attempt to resolve the "?attr/name" string to an identifier.
1126194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette                layout = context.getResources().getIdentifier(value.substring(1), null, null);
1136194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette            }
1146194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette
1156194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette            // The layout might be referencing a theme attribute.
1166194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette            // ---- START CHANGES
1176194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette            if (layout != 0) {
1186194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette                final TypedValue tempValue = new TypedValue();
1196194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette                if (context.getTheme().resolveAttribute(layout, tempValue, true)) {
1206194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette                    layout = tempValue.resourceId;
1216194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette                }
1226194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette            }
1236194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette            // ---- END CHANGES
1246194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette
1256194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette            if (layout == 0) {
1266194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette                final String value = attrs.getAttributeValue(null, ATTR_LAYOUT);
127282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                if (value == null) {
128282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                    throw new InflateException("You must specifiy a layout in the"
129282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                            + " include tag: <include layout=\"@layout/layoutID\" />");
130282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                } else {
131282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                    throw new InflateException("You must specifiy a valid layout "
132282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                            + "reference. The layout ID " + value + " is not valid.");
133282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                }
134282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski            } else {
135282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                final XmlResourceParser childParser =
136282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                    thisInflater.getContext().getResources().getLayout(layout);
137282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
138282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                try {
139282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                    final AttributeSet childAttrs = Xml.asAttributeSet(childParser);
140282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
141282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                    while ((type = childParser.next()) != XmlPullParser.START_TAG &&
142282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                            type != XmlPullParser.END_DOCUMENT) {
143282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                        // Empty.
144282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                    }
145282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
146282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                    if (type != XmlPullParser.START_TAG) {
147282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                        throw new InflateException(childParser.getPositionDescription() +
148282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                                ": No start tag found!");
149282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                    }
150282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
151282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                    final String childName = childParser.getName();
152282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
153282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                    if (TAG_MERGE.equals(childName)) {
154282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                        // Inflate all children.
1556194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette                        thisInflater.rInflate(childParser, parent, context, childAttrs, false);
156282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                    } else {
157ebcef6b896b3b1693862aad9c5000c450ba598a5Alan Viverette                        final View view = thisInflater.createViewFromTag(parent, childName,
1586194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette                                context, childAttrs, hasThemeOverride);
159282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                        final ViewGroup group = (ViewGroup) parent;
160282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
1616194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette                        final TypedArray a = context.obtainStyledAttributes(
1626194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette                                attrs, com.android.internal.R.styleable.Include);
1636194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette                        final int id = a.getResourceId(
1646194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette                                com.android.internal.R.styleable.Include_id, View.NO_ID);
1656194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette                        final int visibility = a.getInt(
1666194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette                                com.android.internal.R.styleable.Include_visibility, -1);
1676194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette                        a.recycle();
1686194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette
169282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                        // We try to load the layout params set in the <include /> tag. If
170282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                        // they don't exist, we will rely on the layout params set in the
171282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                        // included XML file.
172282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                        // During a layoutparams generation, a runtime exception is thrown
173282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                        // if either layout_width or layout_height is missing. We catch
174282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                        // this exception and set localParams accordingly: true means we
175282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                        // successfully loaded layout params from the <include /> tag,
176282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                        // false means we need to rely on the included layout params.
177282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                        ViewGroup.LayoutParams params = null;
1785181f279c8740b9786be37a3a9459114e3f06dfdAlan Viverette                        try {
1795181f279c8740b9786be37a3a9459114e3f06dfdAlan Viverette                            // ---- START CHANGES
1805181f279c8740b9786be37a3a9459114e3f06dfdAlan Viverette                            sIsInInclude = true;
1815181f279c8740b9786be37a3a9459114e3f06dfdAlan Viverette                            // ---- END CHANGES
1825181f279c8740b9786be37a3a9459114e3f06dfdAlan Viverette
1835181f279c8740b9786be37a3a9459114e3f06dfdAlan Viverette                            params = group.generateLayoutParams(attrs);
18421b564573327b1ed2f7e06146b8a01c47ede3089Deepanshu Gupta                        } catch (RuntimeException ignored) {
18521b564573327b1ed2f7e06146b8a01c47ede3089Deepanshu Gupta                            // Ignore, just fail over to child attrs.
1865181f279c8740b9786be37a3a9459114e3f06dfdAlan Viverette                        } finally {
1875181f279c8740b9786be37a3a9459114e3f06dfdAlan Viverette                            // ---- START CHANGES
1885181f279c8740b9786be37a3a9459114e3f06dfdAlan Viverette                            sIsInInclude = false;
1895181f279c8740b9786be37a3a9459114e3f06dfdAlan Viverette                            // ---- END CHANGES
190282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                        }
1916194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette                        if (params == null) {
1926194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette                            params = group.generateLayoutParams(childAttrs);
1936194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette                        }
1946194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette                        view.setLayoutParams(params);
195282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
196282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                        // Inflate all children.
1976194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette                        thisInflater.rInflateChildren(childParser, view, childAttrs, true);
198282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
199282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                        if (id != View.NO_ID) {
200282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                            view.setId(id);
201282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                        }
202282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
203282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                        switch (visibility) {
204282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                            case 0:
205282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                                view.setVisibility(View.VISIBLE);
206282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                                break;
207282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                            case 1:
208282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                                view.setVisibility(View.INVISIBLE);
209282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                                break;
210282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                            case 2:
211282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                                view.setVisibility(View.GONE);
212282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                                break;
213282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                        }
214282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
215282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                        group.addView(view);
216282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                    }
217282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                } finally {
218282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                    childParser.close();
219282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski                }
220282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski            }
221282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski        } else {
222282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski            throw new InflateException("<include /> can only be used inside of a ViewGroup");
223282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski        }
224282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski
2256194d728cf9d43a3a40f8a0e96283d92887c5bcdAlan Viverette        LayoutInflater.consumeChildElements(parser);
226282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski    }
227282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski}
228