The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 The Android Open Source Project |
| 3 | * |
| 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 |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 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. |
| 15 | */ |
| 16 | |
| 17 | package android.view; |
| 18 | |
Alan Viverette | e8489cd | 2015-02-03 14:40:45 -0800 | [diff] [blame] | 19 | import com.android.internal.R; |
Alan Viverette | 0810b63 | 2014-05-01 14:42:56 -0700 | [diff] [blame] | 20 | |
Gilles Debunne | 3030193 | 2010-06-16 18:32:00 -0700 | [diff] [blame] | 21 | import org.xmlpull.v1.XmlPullParser; |
| 22 | import org.xmlpull.v1.XmlPullParserException; |
| 23 | |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 24 | import android.annotation.LayoutRes; |
Alan Viverette | e8489cd | 2015-02-03 14:40:45 -0800 | [diff] [blame] | 25 | import android.annotation.Nullable; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 26 | import android.content.Context; |
Alan Viverette | 0810b63 | 2014-05-01 14:42:56 -0700 | [diff] [blame] | 27 | import android.content.res.Resources; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 28 | import android.content.res.TypedArray; |
| 29 | import android.content.res.XmlResourceParser; |
Alan Viverette | e8489cd | 2015-02-03 14:40:45 -0800 | [diff] [blame] | 30 | import android.graphics.Canvas; |
| 31 | import android.os.Handler; |
| 32 | import android.os.Message; |
| 33 | import android.os.Trace; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 34 | import android.util.AttributeSet; |
Alan Viverette | 0810b63 | 2014-05-01 14:42:56 -0700 | [diff] [blame] | 35 | import android.util.Log; |
Alan Viverette | e8489cd | 2015-02-03 14:40:45 -0800 | [diff] [blame] | 36 | import android.util.TypedValue; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 37 | import android.util.Xml; |
Alan Viverette | e8489cd | 2015-02-03 14:40:45 -0800 | [diff] [blame] | 38 | import android.widget.FrameLayout; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 39 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 40 | import java.io.IOException; |
| 41 | import java.lang.reflect.Constructor; |
| 42 | import java.util.HashMap; |
| 43 | |
| 44 | /** |
Scott Main | 93dc642 | 2012-02-24 12:04:06 -0800 | [diff] [blame] | 45 | * Instantiates a layout XML file into its corresponding {@link android.view.View} |
| 46 | * objects. It is never used directly. Instead, use |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 47 | * {@link android.app.Activity#getLayoutInflater()} or |
| 48 | * {@link Context#getSystemService} to retrieve a standard LayoutInflater instance |
| 49 | * that is already hooked up to the current context and correctly configured |
| 50 | * for the device you are running on. For example: |
| 51 | * |
| 52 | * <pre>LayoutInflater inflater = (LayoutInflater)context.getSystemService |
Christian Mehlmauer | bd6fda1 | 2011-01-08 18:22:20 +0100 | [diff] [blame] | 53 | * (Context.LAYOUT_INFLATER_SERVICE);</pre> |
Dave Burke | 579e140 | 2012-10-18 20:41:55 -0700 | [diff] [blame] | 54 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 55 | * <p> |
| 56 | * To create a new LayoutInflater with an additional {@link Factory} for your |
| 57 | * own views, you can use {@link #cloneInContext} to clone an existing |
| 58 | * ViewFactory, and then call {@link #setFactory} on it to include your |
| 59 | * Factory. |
Dave Burke | 579e140 | 2012-10-18 20:41:55 -0700 | [diff] [blame] | 60 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 61 | * <p> |
| 62 | * For performance reasons, view inflation relies heavily on pre-processing of |
| 63 | * XML files that is done at build time. Therefore, it is not currently possible |
| 64 | * to use LayoutInflater with an XmlPullParser over a plain XML file at runtime; |
| 65 | * it only works with an XmlPullParser returned from a compiled resource |
| 66 | * (R.<em>something</em> file.) |
Dave Burke | 579e140 | 2012-10-18 20:41:55 -0700 | [diff] [blame] | 67 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 68 | * @see Context#getSystemService |
| 69 | */ |
| 70 | public abstract class LayoutInflater { |
Alan Viverette | 33e3cda | 2014-12-17 15:43:29 -0800 | [diff] [blame] | 71 | |
Alan Viverette | 0810b63 | 2014-05-01 14:42:56 -0700 | [diff] [blame] | 72 | private static final String TAG = LayoutInflater.class.getSimpleName(); |
| 73 | private static final boolean DEBUG = false; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 74 | |
| 75 | /** |
| 76 | * This field should be made private, so it is hidden from the SDK. |
| 77 | * {@hide} |
| 78 | */ |
| 79 | protected final Context mContext; |
| 80 | |
| 81 | // these are optional, set by the caller |
| 82 | private boolean mFactorySet; |
| 83 | private Factory mFactory; |
Dianne Hackborn | 625ac27 | 2010-09-17 18:29:22 -0700 | [diff] [blame] | 84 | private Factory2 mFactory2; |
Dianne Hackborn | 420829e | 2011-01-28 11:30:35 -0800 | [diff] [blame] | 85 | private Factory2 mPrivateFactory; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 86 | private Filter mFilter; |
| 87 | |
Xavier Ducrohet | 7f9f99ea | 2011-08-11 10:16:17 -0700 | [diff] [blame] | 88 | final Object[] mConstructorArgs = new Object[2]; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 89 | |
Xavier Ducrohet | 7f9f99ea | 2011-08-11 10:16:17 -0700 | [diff] [blame] | 90 | static final Class<?>[] mConstructorSignature = new Class[] { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 91 | Context.class, AttributeSet.class}; |
| 92 | |
Gilles Debunne | 3030193 | 2010-06-16 18:32:00 -0700 | [diff] [blame] | 93 | private static final HashMap<String, Constructor<? extends View>> sConstructorMap = |
| 94 | new HashMap<String, Constructor<? extends View>>(); |
Dave Burke | 579e140 | 2012-10-18 20:41:55 -0700 | [diff] [blame] | 95 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 96 | private HashMap<String, Boolean> mFilterMap; |
| 97 | |
Alan Viverette | 33e3cda | 2014-12-17 15:43:29 -0800 | [diff] [blame] | 98 | private TypedValue mTempValue; |
| 99 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 100 | private static final String TAG_MERGE = "merge"; |
| 101 | private static final String TAG_INCLUDE = "include"; |
Romain Guy | 9c1223a | 2011-05-17 14:25:49 -0700 | [diff] [blame] | 102 | private static final String TAG_1995 = "blink"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 103 | private static final String TAG_REQUEST_FOCUS = "requestFocus"; |
Alan Viverette | 451a341 | 2014-02-11 18:08:46 -0800 | [diff] [blame] | 104 | private static final String TAG_TAG = "tag"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 105 | |
Alan Viverette | 33e3cda | 2014-12-17 15:43:29 -0800 | [diff] [blame] | 106 | private static final String ATTR_LAYOUT = "layout"; |
| 107 | |
Alan Viverette | ef259e4 | 2014-01-24 17:20:12 -0800 | [diff] [blame] | 108 | private static final int[] ATTRS_THEME = new int[] { |
| 109 | com.android.internal.R.attr.theme }; |
Alan Viverette | 24927f2 | 2014-01-07 17:28:48 -0800 | [diff] [blame] | 110 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 111 | /** |
| 112 | * Hook to allow clients of the LayoutInflater to restrict the set of Views that are allowed |
| 113 | * to be inflated. |
Dave Burke | 579e140 | 2012-10-18 20:41:55 -0700 | [diff] [blame] | 114 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 115 | */ |
| 116 | public interface Filter { |
| 117 | /** |
| 118 | * Hook to allow clients of the LayoutInflater to restrict the set of Views |
| 119 | * that are allowed to be inflated. |
Dave Burke | 579e140 | 2012-10-18 20:41:55 -0700 | [diff] [blame] | 120 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 121 | * @param clazz The class object for the View that is about to be inflated |
Dave Burke | 579e140 | 2012-10-18 20:41:55 -0700 | [diff] [blame] | 122 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 123 | * @return True if this class is allowed to be inflated, or false otherwise |
| 124 | */ |
Gilles Debunne | e6ac8b9 | 2010-06-17 10:55:04 -0700 | [diff] [blame] | 125 | @SuppressWarnings("unchecked") |
| 126 | boolean onLoadClass(Class clazz); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 127 | } |
Dave Burke | 579e140 | 2012-10-18 20:41:55 -0700 | [diff] [blame] | 128 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 129 | public interface Factory { |
| 130 | /** |
| 131 | * Hook you can supply that is called when inflating from a LayoutInflater. |
| 132 | * You can use this to customize the tag names available in your XML |
| 133 | * layout files. |
Dave Burke | 579e140 | 2012-10-18 20:41:55 -0700 | [diff] [blame] | 134 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 135 | * <p> |
| 136 | * Note that it is good practice to prefix these custom names with your |
| 137 | * package (i.e., com.coolcompany.apps) to avoid conflicts with system |
| 138 | * names. |
Dave Burke | 579e140 | 2012-10-18 20:41:55 -0700 | [diff] [blame] | 139 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 140 | * @param name Tag name to be inflated. |
| 141 | * @param context The context the view is being created in. |
| 142 | * @param attrs Inflation attributes as specified in XML file. |
Dave Burke | 579e140 | 2012-10-18 20:41:55 -0700 | [diff] [blame] | 143 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 144 | * @return View Newly created view. Return null for the default |
| 145 | * behavior. |
| 146 | */ |
| 147 | public View onCreateView(String name, Context context, AttributeSet attrs); |
| 148 | } |
| 149 | |
Dianne Hackborn | 625ac27 | 2010-09-17 18:29:22 -0700 | [diff] [blame] | 150 | public interface Factory2 extends Factory { |
| 151 | /** |
| 152 | * Version of {@link #onCreateView(String, Context, AttributeSet)} |
| 153 | * that also supplies the parent that the view created view will be |
| 154 | * placed in. |
| 155 | * |
| 156 | * @param parent The parent that the created view will be placed |
| 157 | * in; <em>note that this may be null</em>. |
| 158 | * @param name Tag name to be inflated. |
| 159 | * @param context The context the view is being created in. |
| 160 | * @param attrs Inflation attributes as specified in XML file. |
| 161 | * |
| 162 | * @return View Newly created view. Return null for the default |
| 163 | * behavior. |
| 164 | */ |
| 165 | public View onCreateView(View parent, String name, Context context, AttributeSet attrs); |
| 166 | } |
| 167 | |
| 168 | private static class FactoryMerger implements Factory2 { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 169 | private final Factory mF1, mF2; |
Dianne Hackborn | 625ac27 | 2010-09-17 18:29:22 -0700 | [diff] [blame] | 170 | private final Factory2 mF12, mF22; |
Dave Burke | 579e140 | 2012-10-18 20:41:55 -0700 | [diff] [blame] | 171 | |
Dianne Hackborn | 625ac27 | 2010-09-17 18:29:22 -0700 | [diff] [blame] | 172 | FactoryMerger(Factory f1, Factory2 f12, Factory f2, Factory2 f22) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 173 | mF1 = f1; |
| 174 | mF2 = f2; |
Dianne Hackborn | 625ac27 | 2010-09-17 18:29:22 -0700 | [diff] [blame] | 175 | mF12 = f12; |
| 176 | mF22 = f22; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 177 | } |
Dave Burke | 579e140 | 2012-10-18 20:41:55 -0700 | [diff] [blame] | 178 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 179 | public View onCreateView(String name, Context context, AttributeSet attrs) { |
| 180 | View v = mF1.onCreateView(name, context, attrs); |
| 181 | if (v != null) return v; |
| 182 | return mF2.onCreateView(name, context, attrs); |
| 183 | } |
Dianne Hackborn | 625ac27 | 2010-09-17 18:29:22 -0700 | [diff] [blame] | 184 | |
| 185 | public View onCreateView(View parent, String name, Context context, AttributeSet attrs) { |
| 186 | View v = mF12 != null ? mF12.onCreateView(parent, name, context, attrs) |
| 187 | : mF1.onCreateView(name, context, attrs); |
| 188 | if (v != null) return v; |
| 189 | return mF22 != null ? mF22.onCreateView(parent, name, context, attrs) |
| 190 | : mF2.onCreateView(name, context, attrs); |
| 191 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 192 | } |
Dave Burke | 579e140 | 2012-10-18 20:41:55 -0700 | [diff] [blame] | 193 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 194 | /** |
| 195 | * Create a new LayoutInflater instance associated with a particular Context. |
| 196 | * Applications will almost always want to use |
| 197 | * {@link Context#getSystemService Context.getSystemService()} to retrieve |
| 198 | * the standard {@link Context#LAYOUT_INFLATER_SERVICE Context.INFLATER_SERVICE}. |
Dave Burke | 579e140 | 2012-10-18 20:41:55 -0700 | [diff] [blame] | 199 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 200 | * @param context The Context in which this LayoutInflater will create its |
| 201 | * Views; most importantly, this supplies the theme from which the default |
| 202 | * values for their attributes are retrieved. |
| 203 | */ |
| 204 | protected LayoutInflater(Context context) { |
| 205 | mContext = context; |
| 206 | } |
| 207 | |
| 208 | /** |
| 209 | * Create a new LayoutInflater instance that is a copy of an existing |
| 210 | * LayoutInflater, optionally with its Context changed. For use in |
| 211 | * implementing {@link #cloneInContext}. |
Dave Burke | 579e140 | 2012-10-18 20:41:55 -0700 | [diff] [blame] | 212 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 213 | * @param original The original LayoutInflater to copy. |
| 214 | * @param newContext The new Context to use. |
| 215 | */ |
| 216 | protected LayoutInflater(LayoutInflater original, Context newContext) { |
| 217 | mContext = newContext; |
| 218 | mFactory = original.mFactory; |
Dianne Hackborn | 625ac27 | 2010-09-17 18:29:22 -0700 | [diff] [blame] | 219 | mFactory2 = original.mFactory2; |
Dianne Hackborn | 420829e | 2011-01-28 11:30:35 -0800 | [diff] [blame] | 220 | mPrivateFactory = original.mPrivateFactory; |
Dan Sandler | 0c7bb33 | 2014-09-18 22:11:18 -0400 | [diff] [blame] | 221 | setFilter(original.mFilter); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 222 | } |
Dave Burke | 579e140 | 2012-10-18 20:41:55 -0700 | [diff] [blame] | 223 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 224 | /** |
| 225 | * Obtains the LayoutInflater from the given context. |
| 226 | */ |
| 227 | public static LayoutInflater from(Context context) { |
| 228 | LayoutInflater LayoutInflater = |
| 229 | (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); |
| 230 | if (LayoutInflater == null) { |
| 231 | throw new AssertionError("LayoutInflater not found."); |
| 232 | } |
| 233 | return LayoutInflater; |
| 234 | } |
| 235 | |
| 236 | /** |
| 237 | * Create a copy of the existing LayoutInflater object, with the copy |
| 238 | * pointing to a different Context than the original. This is used by |
| 239 | * {@link ContextThemeWrapper} to create a new LayoutInflater to go along |
| 240 | * with the new Context theme. |
Dave Burke | 579e140 | 2012-10-18 20:41:55 -0700 | [diff] [blame] | 241 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 242 | * @param newContext The new Context to associate with the new LayoutInflater. |
| 243 | * May be the same as the original Context if desired. |
Dave Burke | 579e140 | 2012-10-18 20:41:55 -0700 | [diff] [blame] | 244 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 245 | * @return Returns a brand spanking new LayoutInflater object associated with |
| 246 | * the given Context. |
| 247 | */ |
| 248 | public abstract LayoutInflater cloneInContext(Context newContext); |
Dave Burke | 579e140 | 2012-10-18 20:41:55 -0700 | [diff] [blame] | 249 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 250 | /** |
| 251 | * Return the context we are running in, for access to resources, class |
| 252 | * loader, etc. |
| 253 | */ |
| 254 | public Context getContext() { |
| 255 | return mContext; |
| 256 | } |
| 257 | |
| 258 | /** |
Dianne Hackborn | 625ac27 | 2010-09-17 18:29:22 -0700 | [diff] [blame] | 259 | * Return the current {@link Factory} (or null). This is called on each element |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 260 | * name. If the factory returns a View, add that to the hierarchy. If it |
| 261 | * returns null, proceed to call onCreateView(name). |
| 262 | */ |
| 263 | public final Factory getFactory() { |
| 264 | return mFactory; |
| 265 | } |
| 266 | |
| 267 | /** |
Dianne Hackborn | 625ac27 | 2010-09-17 18:29:22 -0700 | [diff] [blame] | 268 | * Return the current {@link Factory2}. Returns null if no factory is set |
| 269 | * or the set factory does not implement the {@link Factory2} interface. |
| 270 | * This is called on each element |
| 271 | * name. If the factory returns a View, add that to the hierarchy. If it |
| 272 | * returns null, proceed to call onCreateView(name). |
| 273 | */ |
| 274 | public final Factory2 getFactory2() { |
| 275 | return mFactory2; |
| 276 | } |
| 277 | |
| 278 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 279 | * Attach a custom Factory interface for creating views while using |
| 280 | * this LayoutInflater. This must not be null, and can only be set once; |
| 281 | * after setting, you can not change the factory. This is |
| 282 | * called on each element name as the xml is parsed. If the factory returns |
| 283 | * a View, that is added to the hierarchy. If it returns null, the next |
| 284 | * factory default {@link #onCreateView} method is called. |
Dave Burke | 579e140 | 2012-10-18 20:41:55 -0700 | [diff] [blame] | 285 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 286 | * <p>If you have an existing |
| 287 | * LayoutInflater and want to add your own factory to it, use |
| 288 | * {@link #cloneInContext} to clone the existing instance and then you |
| 289 | * can use this function (once) on the returned new instance. This will |
| 290 | * merge your own factory with whatever factory the original instance is |
| 291 | * using. |
| 292 | */ |
| 293 | public void setFactory(Factory factory) { |
| 294 | if (mFactorySet) { |
| 295 | throw new IllegalStateException("A factory has already been set on this LayoutInflater"); |
| 296 | } |
| 297 | if (factory == null) { |
| 298 | throw new NullPointerException("Given factory can not be null"); |
| 299 | } |
| 300 | mFactorySet = true; |
| 301 | if (mFactory == null) { |
| 302 | mFactory = factory; |
| 303 | } else { |
Dianne Hackborn | 625ac27 | 2010-09-17 18:29:22 -0700 | [diff] [blame] | 304 | mFactory = new FactoryMerger(factory, null, mFactory, mFactory2); |
| 305 | } |
| 306 | } |
| 307 | |
| 308 | /** |
| 309 | * Like {@link #setFactory}, but allows you to set a {@link Factory2} |
| 310 | * interface. |
| 311 | */ |
| 312 | public void setFactory2(Factory2 factory) { |
| 313 | if (mFactorySet) { |
| 314 | throw new IllegalStateException("A factory has already been set on this LayoutInflater"); |
| 315 | } |
| 316 | if (factory == null) { |
| 317 | throw new NullPointerException("Given factory can not be null"); |
| 318 | } |
| 319 | mFactorySet = true; |
| 320 | if (mFactory == null) { |
| 321 | mFactory = mFactory2 = factory; |
| 322 | } else { |
Adam Powell | 371a809 | 2014-06-20 12:51:12 -0700 | [diff] [blame] | 323 | mFactory = mFactory2 = new FactoryMerger(factory, factory, mFactory, mFactory2); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 324 | } |
| 325 | } |
| 326 | |
| 327 | /** |
Dianne Hackborn | 420829e | 2011-01-28 11:30:35 -0800 | [diff] [blame] | 328 | * @hide for use by framework |
| 329 | */ |
| 330 | public void setPrivateFactory(Factory2 factory) { |
Adam Powell | 371a809 | 2014-06-20 12:51:12 -0700 | [diff] [blame] | 331 | if (mPrivateFactory == null) { |
| 332 | mPrivateFactory = factory; |
| 333 | } else { |
| 334 | mPrivateFactory = new FactoryMerger(factory, factory, mPrivateFactory, mPrivateFactory); |
| 335 | } |
Dianne Hackborn | 420829e | 2011-01-28 11:30:35 -0800 | [diff] [blame] | 336 | } |
| 337 | |
| 338 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 339 | * @return The {@link Filter} currently used by this LayoutInflater to restrict the set of Views |
| 340 | * that are allowed to be inflated. |
| 341 | */ |
| 342 | public Filter getFilter() { |
| 343 | return mFilter; |
| 344 | } |
Dave Burke | 579e140 | 2012-10-18 20:41:55 -0700 | [diff] [blame] | 345 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 346 | /** |
| 347 | * Sets the {@link Filter} to by this LayoutInflater. If a view is attempted to be inflated |
| 348 | * which is not allowed by the {@link Filter}, the {@link #inflate(int, ViewGroup)} call will |
| 349 | * throw an {@link InflateException}. This filter will replace any previous filter set on this |
| 350 | * LayoutInflater. |
Dave Burke | 579e140 | 2012-10-18 20:41:55 -0700 | [diff] [blame] | 351 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 352 | * @param filter The Filter which restricts the set of Views that are allowed to be inflated. |
| 353 | * This filter will replace any previous filter set on this LayoutInflater. |
| 354 | */ |
| 355 | public void setFilter(Filter filter) { |
| 356 | mFilter = filter; |
| 357 | if (filter != null) { |
| 358 | mFilterMap = new HashMap<String, Boolean>(); |
| 359 | } |
| 360 | } |
| 361 | |
| 362 | /** |
| 363 | * Inflate a new view hierarchy from the specified xml resource. Throws |
| 364 | * {@link InflateException} if there is an error. |
Dave Burke | 579e140 | 2012-10-18 20:41:55 -0700 | [diff] [blame] | 365 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 366 | * @param resource ID for an XML layout resource to load (e.g., |
| 367 | * <code>R.layout.main_page</code>) |
| 368 | * @param root Optional view to be the parent of the generated hierarchy. |
| 369 | * @return The root View of the inflated hierarchy. If root was supplied, |
| 370 | * this is the root View; otherwise it is the root of the inflated |
| 371 | * XML file. |
| 372 | */ |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 373 | public View inflate(@LayoutRes int resource, @Nullable ViewGroup root) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 374 | return inflate(resource, root, root != null); |
| 375 | } |
| 376 | |
| 377 | /** |
| 378 | * Inflate a new view hierarchy from the specified xml node. Throws |
| 379 | * {@link InflateException} if there is an error. * |
| 380 | * <p> |
| 381 | * <em><strong>Important</strong></em> For performance |
| 382 | * reasons, view inflation relies heavily on pre-processing of XML files |
| 383 | * that is done at build time. Therefore, it is not currently possible to |
| 384 | * use LayoutInflater with an XmlPullParser over a plain XML file at runtime. |
Dave Burke | 579e140 | 2012-10-18 20:41:55 -0700 | [diff] [blame] | 385 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 386 | * @param parser XML dom node containing the description of the view |
| 387 | * hierarchy. |
| 388 | * @param root Optional view to be the parent of the generated hierarchy. |
| 389 | * @return The root View of the inflated hierarchy. If root was supplied, |
| 390 | * this is the root View; otherwise it is the root of the inflated |
| 391 | * XML file. |
| 392 | */ |
Scott Kennedy | db5fd42 | 2015-01-15 11:56:33 -0800 | [diff] [blame] | 393 | public View inflate(XmlPullParser parser, @Nullable ViewGroup root) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 394 | return inflate(parser, root, root != null); |
| 395 | } |
| 396 | |
| 397 | /** |
| 398 | * Inflate a new view hierarchy from the specified xml resource. Throws |
| 399 | * {@link InflateException} if there is an error. |
Dave Burke | 579e140 | 2012-10-18 20:41:55 -0700 | [diff] [blame] | 400 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 401 | * @param resource ID for an XML layout resource to load (e.g., |
| 402 | * <code>R.layout.main_page</code>) |
| 403 | * @param root Optional view to be the parent of the generated hierarchy (if |
| 404 | * <em>attachToRoot</em> is true), or else simply an object that |
| 405 | * provides a set of LayoutParams values for root of the returned |
| 406 | * hierarchy (if <em>attachToRoot</em> is false.) |
| 407 | * @param attachToRoot Whether the inflated hierarchy should be attached to |
| 408 | * the root parameter? If false, root is only used to create the |
| 409 | * correct subclass of LayoutParams for the root view in the XML. |
| 410 | * @return The root View of the inflated hierarchy. If root was supplied and |
| 411 | * attachToRoot is true, this is root; otherwise it is the root of |
| 412 | * the inflated XML file. |
| 413 | */ |
Tor Norbye | 7b9c912 | 2013-05-30 16:48:33 -0700 | [diff] [blame] | 414 | public View inflate(@LayoutRes int resource, @Nullable ViewGroup root, boolean attachToRoot) { |
Alan Viverette | 0810b63 | 2014-05-01 14:42:56 -0700 | [diff] [blame] | 415 | final Resources res = getContext().getResources(); |
| 416 | if (DEBUG) { |
| 417 | Log.d(TAG, "INFLATING from resource: \"" + res.getResourceName(resource) + "\" (" |
| 418 | + Integer.toHexString(resource) + ")"); |
| 419 | } |
| 420 | |
| 421 | final XmlResourceParser parser = res.getLayout(resource); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 422 | try { |
| 423 | return inflate(parser, root, attachToRoot); |
| 424 | } finally { |
| 425 | parser.close(); |
| 426 | } |
| 427 | } |
| 428 | |
| 429 | /** |
| 430 | * Inflate a new view hierarchy from the specified XML node. Throws |
| 431 | * {@link InflateException} if there is an error. |
| 432 | * <p> |
| 433 | * <em><strong>Important</strong></em> For performance |
| 434 | * reasons, view inflation relies heavily on pre-processing of XML files |
| 435 | * that is done at build time. Therefore, it is not currently possible to |
| 436 | * use LayoutInflater with an XmlPullParser over a plain XML file at runtime. |
Dave Burke | 579e140 | 2012-10-18 20:41:55 -0700 | [diff] [blame] | 437 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 438 | * @param parser XML dom node containing the description of the view |
| 439 | * hierarchy. |
| 440 | * @param root Optional view to be the parent of the generated hierarchy (if |
| 441 | * <em>attachToRoot</em> is true), or else simply an object that |
| 442 | * provides a set of LayoutParams values for root of the returned |
| 443 | * hierarchy (if <em>attachToRoot</em> is false.) |
| 444 | * @param attachToRoot Whether the inflated hierarchy should be attached to |
| 445 | * the root parameter? If false, root is only used to create the |
| 446 | * correct subclass of LayoutParams for the root view in the XML. |
| 447 | * @return The root View of the inflated hierarchy. If root was supplied and |
| 448 | * attachToRoot is true, this is root; otherwise it is the root of |
| 449 | * the inflated XML file. |
| 450 | */ |
Scott Kennedy | db5fd42 | 2015-01-15 11:56:33 -0800 | [diff] [blame] | 451 | public View inflate(XmlPullParser parser, @Nullable ViewGroup root, boolean attachToRoot) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 452 | synchronized (mConstructorArgs) { |
Romain Guy | 09f7b93 | 2013-04-10 11:42:44 -0700 | [diff] [blame] | 453 | Trace.traceBegin(Trace.TRACE_TAG_VIEW, "inflate"); |
| 454 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 455 | final AttributeSet attrs = Xml.asAttributeSet(parser); |
Dianne Hackborn | 9dae48e | 2010-08-26 10:20:01 -0700 | [diff] [blame] | 456 | Context lastContext = (Context)mConstructorArgs[0]; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 457 | mConstructorArgs[0] = mContext; |
| 458 | View result = root; |
| 459 | |
| 460 | try { |
| 461 | // Look for the root node. |
| 462 | int type; |
| 463 | while ((type = parser.next()) != XmlPullParser.START_TAG && |
| 464 | type != XmlPullParser.END_DOCUMENT) { |
| 465 | // Empty |
| 466 | } |
| 467 | |
| 468 | if (type != XmlPullParser.START_TAG) { |
| 469 | throw new InflateException(parser.getPositionDescription() |
| 470 | + ": No start tag found!"); |
| 471 | } |
| 472 | |
| 473 | final String name = parser.getName(); |
Dave Burke | 579e140 | 2012-10-18 20:41:55 -0700 | [diff] [blame] | 474 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 475 | if (DEBUG) { |
| 476 | System.out.println("**************************"); |
| 477 | System.out.println("Creating root view: " |
| 478 | + name); |
| 479 | System.out.println("**************************"); |
| 480 | } |
| 481 | |
| 482 | if (TAG_MERGE.equals(name)) { |
| 483 | if (root == null || !attachToRoot) { |
| 484 | throw new InflateException("<merge /> can be used only with a valid " |
| 485 | + "ViewGroup root and attachToRoot=true"); |
| 486 | } |
| 487 | |
Alan Viverette | 24927f2 | 2014-01-07 17:28:48 -0800 | [diff] [blame] | 488 | rInflate(parser, root, attrs, false, false); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 489 | } else { |
| 490 | // Temp is the root view that was found in the xml |
Alan Viverette | 24927f2 | 2014-01-07 17:28:48 -0800 | [diff] [blame] | 491 | final View temp = createViewFromTag(root, name, attrs, false); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 492 | |
| 493 | ViewGroup.LayoutParams params = null; |
| 494 | |
| 495 | if (root != null) { |
| 496 | if (DEBUG) { |
| 497 | System.out.println("Creating params from root: " + |
| 498 | root); |
| 499 | } |
| 500 | // Create layout params that match root, if supplied |
| 501 | params = root.generateLayoutParams(attrs); |
| 502 | if (!attachToRoot) { |
| 503 | // Set the layout params for temp if we are not |
| 504 | // attaching. (If we are, we use addView, below) |
| 505 | temp.setLayoutParams(params); |
| 506 | } |
| 507 | } |
| 508 | |
| 509 | if (DEBUG) { |
| 510 | System.out.println("-----> start inflating children"); |
| 511 | } |
| 512 | // Inflate all children under temp |
Alan Viverette | 24927f2 | 2014-01-07 17:28:48 -0800 | [diff] [blame] | 513 | rInflate(parser, temp, attrs, true, true); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 514 | if (DEBUG) { |
| 515 | System.out.println("-----> done inflating children"); |
| 516 | } |
| 517 | |
| 518 | // We are supposed to attach all the views we found (int temp) |
| 519 | // to root. Do that now. |
| 520 | if (root != null && attachToRoot) { |
| 521 | root.addView(temp, params); |
| 522 | } |
| 523 | |
| 524 | // Decide whether to return the root that was passed in or the |
| 525 | // top view found in xml. |
| 526 | if (root == null || !attachToRoot) { |
| 527 | result = temp; |
| 528 | } |
| 529 | } |
| 530 | |
| 531 | } catch (XmlPullParserException e) { |
| 532 | InflateException ex = new InflateException(e.getMessage()); |
| 533 | ex.initCause(e); |
| 534 | throw ex; |
Alan Viverette | 9379505 | 2015-03-09 15:32:50 -0700 | [diff] [blame] | 535 | } catch (Exception e) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 536 | InflateException ex = new InflateException( |
| 537 | parser.getPositionDescription() |
Alan Viverette | 9379505 | 2015-03-09 15:32:50 -0700 | [diff] [blame] | 538 | + ": " + e.getMessage()); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 539 | ex.initCause(e); |
| 540 | throw ex; |
Dianne Hackborn | 9dae48e | 2010-08-26 10:20:01 -0700 | [diff] [blame] | 541 | } finally { |
| 542 | // Don't retain static reference on context. |
| 543 | mConstructorArgs[0] = lastContext; |
| 544 | mConstructorArgs[1] = null; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 545 | } |
| 546 | |
Romain Guy | 09f7b93 | 2013-04-10 11:42:44 -0700 | [diff] [blame] | 547 | Trace.traceEnd(Trace.TRACE_TAG_VIEW); |
| 548 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 549 | return result; |
| 550 | } |
| 551 | } |
| 552 | |
| 553 | /** |
| 554 | * Low-level function for instantiating a view by name. This attempts to |
| 555 | * instantiate a view class of the given <var>name</var> found in this |
| 556 | * LayoutInflater's ClassLoader. |
Dave Burke | 579e140 | 2012-10-18 20:41:55 -0700 | [diff] [blame] | 557 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 558 | * <p> |
| 559 | * There are two things that can happen in an error case: either the |
| 560 | * exception describing the error will be thrown, or a null will be |
| 561 | * returned. You must deal with both possibilities -- the former will happen |
| 562 | * the first time createView() is called for a class of a particular name, |
| 563 | * the latter every time there-after for that class name. |
Dave Burke | 579e140 | 2012-10-18 20:41:55 -0700 | [diff] [blame] | 564 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 565 | * @param name The full name of the class to be instantiated. |
| 566 | * @param attrs The XML attributes supplied for this instance. |
Dave Burke | 579e140 | 2012-10-18 20:41:55 -0700 | [diff] [blame] | 567 | * |
Gilles Debunne | 3030193 | 2010-06-16 18:32:00 -0700 | [diff] [blame] | 568 | * @return View The newly instantiated view, or null. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 569 | */ |
| 570 | public final View createView(String name, String prefix, AttributeSet attrs) |
| 571 | throws ClassNotFoundException, InflateException { |
Gilles Debunne | 3030193 | 2010-06-16 18:32:00 -0700 | [diff] [blame] | 572 | Constructor<? extends View> constructor = sConstructorMap.get(name); |
| 573 | Class<? extends View> clazz = null; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 574 | |
| 575 | try { |
Romain Guy | 09f7b93 | 2013-04-10 11:42:44 -0700 | [diff] [blame] | 576 | Trace.traceBegin(Trace.TRACE_TAG_VIEW, name); |
| 577 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 578 | if (constructor == null) { |
| 579 | // Class not found in the cache, see if it's real, and try to add it |
Romain Guy | d03b880 | 2009-09-16 14:36:16 -0700 | [diff] [blame] | 580 | clazz = mContext.getClassLoader().loadClass( |
Gilles Debunne | 3030193 | 2010-06-16 18:32:00 -0700 | [diff] [blame] | 581 | prefix != null ? (prefix + name) : name).asSubclass(View.class); |
Dave Burke | 579e140 | 2012-10-18 20:41:55 -0700 | [diff] [blame] | 582 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 583 | if (mFilter != null && clazz != null) { |
| 584 | boolean allowed = mFilter.onLoadClass(clazz); |
| 585 | if (!allowed) { |
| 586 | failNotAllowed(name, prefix, attrs); |
| 587 | } |
| 588 | } |
| 589 | constructor = clazz.getConstructor(mConstructorSignature); |
| 590 | sConstructorMap.put(name, constructor); |
| 591 | } else { |
| 592 | // If we have a filter, apply it to cached constructor |
| 593 | if (mFilter != null) { |
| 594 | // Have we seen this name before? |
| 595 | Boolean allowedState = mFilterMap.get(name); |
| 596 | if (allowedState == null) { |
| 597 | // New class -- remember whether it is allowed |
Romain Guy | d03b880 | 2009-09-16 14:36:16 -0700 | [diff] [blame] | 598 | clazz = mContext.getClassLoader().loadClass( |
Gilles Debunne | 3030193 | 2010-06-16 18:32:00 -0700 | [diff] [blame] | 599 | prefix != null ? (prefix + name) : name).asSubclass(View.class); |
Dave Burke | 579e140 | 2012-10-18 20:41:55 -0700 | [diff] [blame] | 600 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 601 | boolean allowed = clazz != null && mFilter.onLoadClass(clazz); |
| 602 | mFilterMap.put(name, allowed); |
| 603 | if (!allowed) { |
| 604 | failNotAllowed(name, prefix, attrs); |
| 605 | } |
| 606 | } else if (allowedState.equals(Boolean.FALSE)) { |
| 607 | failNotAllowed(name, prefix, attrs); |
| 608 | } |
| 609 | } |
| 610 | } |
| 611 | |
| 612 | Object[] args = mConstructorArgs; |
| 613 | args[1] = attrs; |
Jeff Sharkey | b27b7a1 | 2012-04-02 21:07:29 -0700 | [diff] [blame] | 614 | |
Jeff Hao | e3abd2c | 2014-03-28 11:33:53 -0700 | [diff] [blame] | 615 | constructor.setAccessible(true); |
Jeff Sharkey | b27b7a1 | 2012-04-02 21:07:29 -0700 | [diff] [blame] | 616 | final View view = constructor.newInstance(args); |
| 617 | if (view instanceof ViewStub) { |
Alan Viverette | a9ddb8d | 2014-09-17 18:14:32 -0700 | [diff] [blame] | 618 | // Use the same context when inflating ViewStub later. |
Jeff Sharkey | b27b7a1 | 2012-04-02 21:07:29 -0700 | [diff] [blame] | 619 | final ViewStub viewStub = (ViewStub) view; |
Alan Viverette | a9ddb8d | 2014-09-17 18:14:32 -0700 | [diff] [blame] | 620 | viewStub.setLayoutInflater(cloneInContext((Context) args[0])); |
Jeff Sharkey | b27b7a1 | 2012-04-02 21:07:29 -0700 | [diff] [blame] | 621 | } |
| 622 | return view; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 623 | |
| 624 | } catch (NoSuchMethodException e) { |
| 625 | InflateException ie = new InflateException(attrs.getPositionDescription() |
| 626 | + ": Error inflating class " |
| 627 | + (prefix != null ? (prefix + name) : name)); |
| 628 | ie.initCause(e); |
| 629 | throw ie; |
| 630 | |
Gilles Debunne | 3030193 | 2010-06-16 18:32:00 -0700 | [diff] [blame] | 631 | } catch (ClassCastException e) { |
| 632 | // If loaded class is not a View subclass |
| 633 | InflateException ie = new InflateException(attrs.getPositionDescription() |
| 634 | + ": Class is not a View " |
| 635 | + (prefix != null ? (prefix + name) : name)); |
| 636 | ie.initCause(e); |
| 637 | throw ie; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 638 | } catch (ClassNotFoundException e) { |
| 639 | // If loadClass fails, we should propagate the exception. |
| 640 | throw e; |
| 641 | } catch (Exception e) { |
| 642 | InflateException ie = new InflateException(attrs.getPositionDescription() |
| 643 | + ": Error inflating class " |
Romain Guy | d03b880 | 2009-09-16 14:36:16 -0700 | [diff] [blame] | 644 | + (clazz == null ? "<unknown>" : clazz.getName())); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 645 | ie.initCause(e); |
| 646 | throw ie; |
Romain Guy | 09f7b93 | 2013-04-10 11:42:44 -0700 | [diff] [blame] | 647 | } finally { |
| 648 | Trace.traceEnd(Trace.TRACE_TAG_VIEW); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 649 | } |
| 650 | } |
| 651 | |
| 652 | /** |
Gilles Debunne | 3030193 | 2010-06-16 18:32:00 -0700 | [diff] [blame] | 653 | * Throw an exception because the specified class is not allowed to be inflated. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 654 | */ |
| 655 | private void failNotAllowed(String name, String prefix, AttributeSet attrs) { |
Romain Guy | 9c1223a | 2011-05-17 14:25:49 -0700 | [diff] [blame] | 656 | throw new InflateException(attrs.getPositionDescription() |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 657 | + ": Class not allowed to be inflated " |
| 658 | + (prefix != null ? (prefix + name) : name)); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 659 | } |
| 660 | |
| 661 | /** |
| 662 | * This routine is responsible for creating the correct subclass of View |
| 663 | * given the xml element name. Override it to handle custom view objects. If |
| 664 | * you override this in your subclass be sure to call through to |
| 665 | * super.onCreateView(name) for names you do not recognize. |
Dave Burke | 579e140 | 2012-10-18 20:41:55 -0700 | [diff] [blame] | 666 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 667 | * @param name The fully qualified class name of the View to be create. |
| 668 | * @param attrs An AttributeSet of attributes to apply to the View. |
Dave Burke | 579e140 | 2012-10-18 20:41:55 -0700 | [diff] [blame] | 669 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 670 | * @return View The View created. |
| 671 | */ |
| 672 | protected View onCreateView(String name, AttributeSet attrs) |
| 673 | throws ClassNotFoundException { |
| 674 | return createView(name, "android.view.", attrs); |
| 675 | } |
| 676 | |
Dianne Hackborn | 625ac27 | 2010-09-17 18:29:22 -0700 | [diff] [blame] | 677 | /** |
| 678 | * Version of {@link #onCreateView(String, AttributeSet)} that also |
Chet Haase | 430742f | 2013-04-12 11:18:36 -0700 | [diff] [blame] | 679 | * takes the future parent of the view being constructed. The default |
Dianne Hackborn | 625ac27 | 2010-09-17 18:29:22 -0700 | [diff] [blame] | 680 | * implementation simply calls {@link #onCreateView(String, AttributeSet)}. |
| 681 | * |
| 682 | * @param parent The future parent of the returned view. <em>Note that |
| 683 | * this may be null.</em> |
| 684 | * @param name The fully qualified class name of the View to be create. |
| 685 | * @param attrs An AttributeSet of attributes to apply to the View. |
| 686 | * |
| 687 | * @return View The View created. |
| 688 | */ |
| 689 | protected View onCreateView(View parent, String name, AttributeSet attrs) |
| 690 | throws ClassNotFoundException { |
| 691 | return onCreateView(name, attrs); |
| 692 | } |
| 693 | |
Alan Viverette | 24927f2 | 2014-01-07 17:28:48 -0800 | [diff] [blame] | 694 | /** |
| 695 | * Creates a view from a tag name using the supplied attribute set. |
| 696 | * <p> |
| 697 | * If {@code inheritContext} is true and the parent is non-null, the view |
| 698 | * will be inflated in parent view's context. If the view specifies a |
| 699 | * <theme> attribute, the inflation context will be wrapped with the |
| 700 | * specified theme. |
| 701 | * <p> |
| 702 | * Note: Default visibility so the BridgeInflater can override it. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 703 | */ |
Alan Viverette | 24927f2 | 2014-01-07 17:28:48 -0800 | [diff] [blame] | 704 | View createViewFromTag(View parent, String name, AttributeSet attrs, boolean inheritContext) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 705 | if (name.equals("view")) { |
| 706 | name = attrs.getAttributeValue(null, "class"); |
| 707 | } |
| 708 | |
Alan Viverette | 24927f2 | 2014-01-07 17:28:48 -0800 | [diff] [blame] | 709 | Context viewContext; |
| 710 | if (parent != null && inheritContext) { |
| 711 | viewContext = parent.getContext(); |
| 712 | } else { |
| 713 | viewContext = mContext; |
| 714 | } |
| 715 | |
| 716 | // Apply a theme wrapper, if requested. |
Alan Viverette | ef259e4 | 2014-01-24 17:20:12 -0800 | [diff] [blame] | 717 | final TypedArray ta = viewContext.obtainStyledAttributes(attrs, ATTRS_THEME); |
| 718 | final int themeResId = ta.getResourceId(0, 0); |
Alan Viverette | 24927f2 | 2014-01-07 17:28:48 -0800 | [diff] [blame] | 719 | if (themeResId != 0) { |
| 720 | viewContext = new ContextThemeWrapper(viewContext, themeResId); |
| 721 | } |
Alan Viverette | ef259e4 | 2014-01-24 17:20:12 -0800 | [diff] [blame] | 722 | ta.recycle(); |
Alan Viverette | 24927f2 | 2014-01-07 17:28:48 -0800 | [diff] [blame] | 723 | |
| 724 | if (name.equals(TAG_1995)) { |
| 725 | // Let's party like it's 1995! |
| 726 | return new BlinkLayout(viewContext, attrs); |
| 727 | } |
| 728 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 729 | if (DEBUG) System.out.println("******** Creating view: " + name); |
| 730 | |
| 731 | try { |
Dianne Hackborn | 625ac27 | 2010-09-17 18:29:22 -0700 | [diff] [blame] | 732 | View view; |
Alan Viverette | 24927f2 | 2014-01-07 17:28:48 -0800 | [diff] [blame] | 733 | if (mFactory2 != null) { |
| 734 | view = mFactory2.onCreateView(parent, name, viewContext, attrs); |
| 735 | } else if (mFactory != null) { |
| 736 | view = mFactory.onCreateView(name, viewContext, attrs); |
| 737 | } else { |
| 738 | view = null; |
| 739 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 740 | |
Dianne Hackborn | 420829e | 2011-01-28 11:30:35 -0800 | [diff] [blame] | 741 | if (view == null && mPrivateFactory != null) { |
Alan Viverette | 24927f2 | 2014-01-07 17:28:48 -0800 | [diff] [blame] | 742 | view = mPrivateFactory.onCreateView(parent, name, viewContext, attrs); |
Dianne Hackborn | 420829e | 2011-01-28 11:30:35 -0800 | [diff] [blame] | 743 | } |
Alan Viverette | 24927f2 | 2014-01-07 17:28:48 -0800 | [diff] [blame] | 744 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 745 | if (view == null) { |
Alan Viverette | 24927f2 | 2014-01-07 17:28:48 -0800 | [diff] [blame] | 746 | final Object lastContext = mConstructorArgs[0]; |
| 747 | mConstructorArgs[0] = viewContext; |
| 748 | try { |
| 749 | if (-1 == name.indexOf('.')) { |
| 750 | view = onCreateView(parent, name, attrs); |
| 751 | } else { |
| 752 | view = createView(name, null, attrs); |
| 753 | } |
| 754 | } finally { |
| 755 | mConstructorArgs[0] = lastContext; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 756 | } |
| 757 | } |
| 758 | |
| 759 | if (DEBUG) System.out.println("Created view is: " + view); |
| 760 | return view; |
| 761 | |
| 762 | } catch (InflateException e) { |
| 763 | throw e; |
| 764 | |
| 765 | } catch (ClassNotFoundException e) { |
| 766 | InflateException ie = new InflateException(attrs.getPositionDescription() |
| 767 | + ": Error inflating class " + name); |
| 768 | ie.initCause(e); |
| 769 | throw ie; |
| 770 | |
| 771 | } catch (Exception e) { |
| 772 | InflateException ie = new InflateException(attrs.getPositionDescription() |
| 773 | + ": Error inflating class " + name); |
| 774 | ie.initCause(e); |
| 775 | throw ie; |
| 776 | } |
| 777 | } |
| 778 | |
| 779 | /** |
| 780 | * Recursive method used to descend down the xml hierarchy and instantiate |
| 781 | * views, instantiate their children, and then call onFinishInflate(). |
Alan Viverette | 24927f2 | 2014-01-07 17:28:48 -0800 | [diff] [blame] | 782 | * |
| 783 | * @param inheritContext Whether the root view should be inflated in its |
| 784 | * parent's context. This should be true when called inflating |
| 785 | * child views recursively, or false otherwise. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 786 | */ |
Xavier Ducrohet | 7f9f99ea | 2011-08-11 10:16:17 -0700 | [diff] [blame] | 787 | void rInflate(XmlPullParser parser, View parent, final AttributeSet attrs, |
Alan Viverette | 24927f2 | 2014-01-07 17:28:48 -0800 | [diff] [blame] | 788 | boolean finishInflate, boolean inheritContext) throws XmlPullParserException, |
| 789 | IOException { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 790 | |
| 791 | final int depth = parser.getDepth(); |
| 792 | int type; |
| 793 | |
| 794 | while (((type = parser.next()) != XmlPullParser.END_TAG || |
| 795 | parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) { |
| 796 | |
| 797 | if (type != XmlPullParser.START_TAG) { |
| 798 | continue; |
| 799 | } |
| 800 | |
| 801 | final String name = parser.getName(); |
Dave Burke | 579e140 | 2012-10-18 20:41:55 -0700 | [diff] [blame] | 802 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 803 | if (TAG_REQUEST_FOCUS.equals(name)) { |
| 804 | parseRequestFocus(parser, parent); |
Alan Viverette | 451a341 | 2014-02-11 18:08:46 -0800 | [diff] [blame] | 805 | } else if (TAG_TAG.equals(name)) { |
| 806 | parseViewTag(parser, parent, attrs); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 807 | } else if (TAG_INCLUDE.equals(name)) { |
| 808 | if (parser.getDepth() == 0) { |
| 809 | throw new InflateException("<include /> cannot be the root element"); |
| 810 | } |
Alan Viverette | 24927f2 | 2014-01-07 17:28:48 -0800 | [diff] [blame] | 811 | parseInclude(parser, parent, attrs, inheritContext); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 812 | } else if (TAG_MERGE.equals(name)) { |
| 813 | throw new InflateException("<merge /> must be the root element"); |
| 814 | } else { |
Alan Viverette | 24927f2 | 2014-01-07 17:28:48 -0800 | [diff] [blame] | 815 | final View view = createViewFromTag(parent, name, attrs, inheritContext); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 816 | final ViewGroup viewGroup = (ViewGroup) parent; |
| 817 | final ViewGroup.LayoutParams params = viewGroup.generateLayoutParams(attrs); |
Alan Viverette | 24927f2 | 2014-01-07 17:28:48 -0800 | [diff] [blame] | 818 | rInflate(parser, view, attrs, true, true); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 819 | viewGroup.addView(view, params); |
| 820 | } |
| 821 | } |
| 822 | |
Romain Guy | 9295ada | 2010-06-15 11:33:24 -0700 | [diff] [blame] | 823 | if (finishInflate) parent.onFinishInflate(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 824 | } |
| 825 | |
Alan Viverette | 451a341 | 2014-02-11 18:08:46 -0800 | [diff] [blame] | 826 | /** |
| 827 | * Parses a <code><request-focus></code> element and requests focus on |
| 828 | * the containing View. |
| 829 | */ |
| 830 | private void parseRequestFocus(XmlPullParser parser, View view) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 831 | throws XmlPullParserException, IOException { |
| 832 | int type; |
Alan Viverette | 451a341 | 2014-02-11 18:08:46 -0800 | [diff] [blame] | 833 | view.requestFocus(); |
| 834 | final int currentDepth = parser.getDepth(); |
| 835 | while (((type = parser.next()) != XmlPullParser.END_TAG || |
| 836 | parser.getDepth() > currentDepth) && type != XmlPullParser.END_DOCUMENT) { |
| 837 | // Empty |
| 838 | } |
| 839 | } |
| 840 | |
| 841 | /** |
| 842 | * Parses a <code><tag></code> element and sets a keyed tag on the |
| 843 | * containing View. |
| 844 | */ |
| 845 | private void parseViewTag(XmlPullParser parser, View view, AttributeSet attrs) |
| 846 | throws XmlPullParserException, IOException { |
| 847 | int type; |
| 848 | |
Alan Viverette | 33e3cda | 2014-12-17 15:43:29 -0800 | [diff] [blame] | 849 | final TypedArray ta = view.getContext().obtainStyledAttributes( |
Alan Viverette | 451a341 | 2014-02-11 18:08:46 -0800 | [diff] [blame] | 850 | attrs, com.android.internal.R.styleable.ViewTag); |
| 851 | final int key = ta.getResourceId(com.android.internal.R.styleable.ViewTag_id, 0); |
| 852 | final CharSequence value = ta.getText(com.android.internal.R.styleable.ViewTag_value); |
| 853 | view.setTag(key, value); |
| 854 | ta.recycle(); |
| 855 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 856 | final int currentDepth = parser.getDepth(); |
| 857 | while (((type = parser.next()) != XmlPullParser.END_TAG || |
| 858 | parser.getDepth() > currentDepth) && type != XmlPullParser.END_DOCUMENT) { |
| 859 | // Empty |
| 860 | } |
| 861 | } |
| 862 | |
Alan Viverette | 24927f2 | 2014-01-07 17:28:48 -0800 | [diff] [blame] | 863 | private void parseInclude(XmlPullParser parser, View parent, AttributeSet attrs, |
| 864 | boolean inheritContext) throws XmlPullParserException, IOException { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 865 | int type; |
| 866 | |
| 867 | if (parent instanceof ViewGroup) { |
Alan Viverette | 33e3cda | 2014-12-17 15:43:29 -0800 | [diff] [blame] | 868 | Context context = inheritContext ? parent.getContext() : mContext; |
| 869 | |
| 870 | // Apply a theme wrapper, if requested. |
| 871 | final TypedArray ta = context.obtainStyledAttributes(attrs, ATTRS_THEME); |
| 872 | final int themeResId = ta.getResourceId(0, 0); |
| 873 | if (themeResId != 0) { |
| 874 | context = new ContextThemeWrapper(context, themeResId); |
| 875 | } |
| 876 | ta.recycle(); |
| 877 | |
| 878 | // If the layout is pointing to a theme attribute, we have to |
| 879 | // massage the value to get a resource identifier out of it. |
| 880 | int layout = attrs.getAttributeResourceValue(null, ATTR_LAYOUT, 0); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 881 | if (layout == 0) { |
Alan Viverette | 33e3cda | 2014-12-17 15:43:29 -0800 | [diff] [blame] | 882 | final String value = attrs.getAttributeValue(null, ATTR_LAYOUT); |
| 883 | if (value == null || value.length() < 1) { |
| 884 | throw new InflateException("You must specify a layout in the" |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 885 | + " include tag: <include layout=\"@layout/layoutID\" />"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 886 | } |
Alan Viverette | 33e3cda | 2014-12-17 15:43:29 -0800 | [diff] [blame] | 887 | |
| 888 | layout = context.getResources().getIdentifier(value.substring(1), null, null); |
| 889 | } |
| 890 | |
| 891 | // The layout might be referencing a theme attribute. |
| 892 | if (mTempValue == null) { |
| 893 | mTempValue = new TypedValue(); |
| 894 | } |
| 895 | if (layout != 0 && context.getTheme().resolveAttribute(layout, mTempValue, true)) { |
| 896 | layout = mTempValue.resourceId; |
| 897 | } |
| 898 | |
| 899 | if (layout == 0) { |
| 900 | final String value = attrs.getAttributeValue(null, ATTR_LAYOUT); |
| 901 | throw new InflateException("You must specify a valid layout " |
| 902 | + "reference. The layout ID " + value + " is not valid."); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 903 | } else { |
| 904 | final XmlResourceParser childParser = |
| 905 | getContext().getResources().getLayout(layout); |
| 906 | |
| 907 | try { |
| 908 | final AttributeSet childAttrs = Xml.asAttributeSet(childParser); |
| 909 | |
| 910 | while ((type = childParser.next()) != XmlPullParser.START_TAG && |
| 911 | type != XmlPullParser.END_DOCUMENT) { |
| 912 | // Empty. |
| 913 | } |
| 914 | |
| 915 | if (type != XmlPullParser.START_TAG) { |
| 916 | throw new InflateException(childParser.getPositionDescription() + |
| 917 | ": No start tag found!"); |
| 918 | } |
| 919 | |
| 920 | final String childName = childParser.getName(); |
| 921 | |
| 922 | if (TAG_MERGE.equals(childName)) { |
| 923 | // Inflate all children. |
Alan Viverette | 24927f2 | 2014-01-07 17:28:48 -0800 | [diff] [blame] | 924 | rInflate(childParser, parent, childAttrs, false, inheritContext); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 925 | } else { |
Alan Viverette | 24927f2 | 2014-01-07 17:28:48 -0800 | [diff] [blame] | 926 | final View view = createViewFromTag(parent, childName, childAttrs, |
| 927 | inheritContext); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 928 | final ViewGroup group = (ViewGroup) parent; |
| 929 | |
Alan Viverette | e8489cd | 2015-02-03 14:40:45 -0800 | [diff] [blame] | 930 | final TypedArray a = context.obtainStyledAttributes( |
| 931 | attrs, R.styleable.Include); |
| 932 | final int id = a.getResourceId(R.styleable.Include_id, View.NO_ID); |
| 933 | final int visibility = a.getInt(R.styleable.Include_visibility, -1); |
| 934 | final boolean hasWidth = a.hasValue(R.styleable.Include_layout_width); |
| 935 | final boolean hasHeight = a.hasValue(R.styleable.Include_layout_height); |
| 936 | a.recycle(); |
| 937 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 938 | // We try to load the layout params set in the <include /> tag. If |
| 939 | // they don't exist, we will rely on the layout params set in the |
| 940 | // included XML file. |
Dave Burke | 579e140 | 2012-10-18 20:41:55 -0700 | [diff] [blame] | 941 | // During a layoutparams generation, a runtime exception is thrown |
| 942 | // if either layout_width or layout_height is missing. We catch |
| 943 | // this exception and set localParams accordingly: true means we |
| 944 | // successfully loaded layout params from the <include /> tag, |
| 945 | // false means we need to rely on the included layout params. |
| 946 | ViewGroup.LayoutParams params = null; |
Alan Viverette | e8489cd | 2015-02-03 14:40:45 -0800 | [diff] [blame] | 947 | if (hasWidth && hasHeight) { |
| 948 | try { |
| 949 | params = group.generateLayoutParams(attrs); |
| 950 | } catch (RuntimeException e) { |
| 951 | // Ignore, just fail over to child attrs. |
Dave Burke | 579e140 | 2012-10-18 20:41:55 -0700 | [diff] [blame] | 952 | } |
| 953 | } |
Alan Viverette | e8489cd | 2015-02-03 14:40:45 -0800 | [diff] [blame] | 954 | if (params == null) { |
| 955 | params = group.generateLayoutParams(childAttrs); |
| 956 | } |
| 957 | view.setLayoutParams(params); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 958 | |
| 959 | // Inflate all children. |
Alan Viverette | 24927f2 | 2014-01-07 17:28:48 -0800 | [diff] [blame] | 960 | rInflate(childParser, view, childAttrs, true, true); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 961 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 962 | if (id != View.NO_ID) { |
| 963 | view.setId(id); |
| 964 | } |
| 965 | |
| 966 | switch (visibility) { |
| 967 | case 0: |
| 968 | view.setVisibility(View.VISIBLE); |
| 969 | break; |
| 970 | case 1: |
| 971 | view.setVisibility(View.INVISIBLE); |
| 972 | break; |
| 973 | case 2: |
| 974 | view.setVisibility(View.GONE); |
| 975 | break; |
| 976 | } |
| 977 | |
| 978 | group.addView(view); |
| 979 | } |
| 980 | } finally { |
| 981 | childParser.close(); |
| 982 | } |
| 983 | } |
| 984 | } else { |
| 985 | throw new InflateException("<include /> can only be used inside of a ViewGroup"); |
| 986 | } |
| 987 | |
| 988 | final int currentDepth = parser.getDepth(); |
| 989 | while (((type = parser.next()) != XmlPullParser.END_TAG || |
| 990 | parser.getDepth() > currentDepth) && type != XmlPullParser.END_DOCUMENT) { |
| 991 | // Empty |
| 992 | } |
Romain Guy | 9c1223a | 2011-05-17 14:25:49 -0700 | [diff] [blame] | 993 | } |
| 994 | |
| 995 | private static class BlinkLayout extends FrameLayout { |
| 996 | private static final int MESSAGE_BLINK = 0x42; |
| 997 | private static final int BLINK_DELAY = 500; |
| 998 | |
| 999 | private boolean mBlink; |
| 1000 | private boolean mBlinkState; |
| 1001 | private final Handler mHandler; |
| 1002 | |
| 1003 | public BlinkLayout(Context context, AttributeSet attrs) { |
| 1004 | super(context, attrs); |
| 1005 | mHandler = new Handler(new Handler.Callback() { |
| 1006 | @Override |
| 1007 | public boolean handleMessage(Message msg) { |
| 1008 | if (msg.what == MESSAGE_BLINK) { |
| 1009 | if (mBlink) { |
| 1010 | mBlinkState = !mBlinkState; |
| 1011 | makeBlink(); |
| 1012 | } |
| 1013 | invalidate(); |
| 1014 | return true; |
| 1015 | } |
| 1016 | return false; |
| 1017 | } |
| 1018 | }); |
| 1019 | } |
| 1020 | |
| 1021 | private void makeBlink() { |
| 1022 | Message message = mHandler.obtainMessage(MESSAGE_BLINK); |
| 1023 | mHandler.sendMessageDelayed(message, BLINK_DELAY); |
| 1024 | } |
| 1025 | |
| 1026 | @Override |
| 1027 | protected void onAttachedToWindow() { |
| 1028 | super.onAttachedToWindow(); |
| 1029 | |
| 1030 | mBlink = true; |
| 1031 | mBlinkState = true; |
| 1032 | |
| 1033 | makeBlink(); |
| 1034 | } |
| 1035 | |
| 1036 | @Override |
| 1037 | protected void onDetachedFromWindow() { |
| 1038 | super.onDetachedFromWindow(); |
| 1039 | |
| 1040 | mBlink = false; |
| 1041 | mBlinkState = true; |
| 1042 | |
| 1043 | mHandler.removeMessages(MESSAGE_BLINK); |
| 1044 | } |
| 1045 | |
| 1046 | @Override |
| 1047 | protected void dispatchDraw(Canvas canvas) { |
| 1048 | if (mBlinkState) { |
| 1049 | super.dispatchDraw(canvas); |
| 1050 | } |
| 1051 | } |
| 1052 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1053 | } |