@NonNull private static int[] parseMatchOrder(String matchOrderString) { StringTokenizer st = new StringTokenizer(matchOrderString, ","); int matches[] = new int[st.countTokens()]; int index = 0; while (st.hasMoreTokens()) { String token = st.nextToken().trim(); if (MATCH_ID_STR.equalsIgnoreCase(token)) { matches[index] = Transition.MATCH_ID; } else if (MATCH_INSTANCE_STR.equalsIgnoreCase(token)) { matches[index] = Transition.MATCH_INSTANCE; } else if (MATCH_NAME_STR.equalsIgnoreCase(token)) { matches[index] = Transition.MATCH_NAME; } else if (MATCH_VIEW_NAME_STR.equalsIgnoreCase(token)) { matches[index] = Transition.MATCH_NAME; } else if (MATCH_ITEM_ID_STR.equalsIgnoreCase(token)) { matches[index] = Transition.MATCH_ITEM_ID; } else if (token.isEmpty()) { int[] smallerMatches = new int[matches.length - 1]; System.arraycopy(matches, 0, smallerMatches, 0, index); matches = smallerMatches; index--; } else { throw new InflateException("Unknown match type in matchOrder: '" + token + "'"); } index++; } return matches; }
throw new InflateException(tag + " tag must have a 'class' attribute"); throw new InflateException("Could not instantiate " + expectedType + " class " + className, e); } catch (ClassNotFoundException e) { throw new InflateException("Could not instantiate " + expectedType + " class " + className, e); } catch (InvocationTargetException e) { throw new InflateException("Could not instantiate " + expectedType + " class " + className, e); } catch (NoSuchMethodException e) { throw new InflateException("Could not instantiate " + expectedType + " class " + className, e); } catch (IllegalAccessException e) { throw new InflateException("Could not instantiate " + expectedType + " class " + className, e);
protected void initInflate(Context context) { try { View.inflate(context, getLayoutId(), this); } catch (InflateException e) { if (e.toString().contains("GSYImageCover")) { Debuger.printfError("********************\n" + "***** 注意 *****" + "********************\n" + "*该版本需要清除布局文件中的GSYImageCover\n" + "**** Attention ***\n" + "*Please remove GSYImageCover from Layout in this Version\n" + "********************\n"); e.printStackTrace(); throw new InflateException("该版本需要清除布局文件中的GSYImageCover,please remove GSYImageCover from your layout"); } else { e.printStackTrace(); } } }
private void afterInflate(int menuRes, Menu menu){ IconData root = new IconData(0, 0, 0); XmlResourceParser parser = null; try { parser = mContext.getResources().getLayout(menuRes); AttributeSet attrs = Xml.asAttributeSet(parser); parseMenu(parser, attrs, root); } catch (XmlPullParserException e) { throw new InflateException("Error inflating menu XML", e); } catch (IOException e) { throw new InflateException("Error inflating menu XML", e); } finally { if (parser != null) parser.close(); // populate the menu with the parsed icons populateIcons(menu, root, mDefaultColor); } }
/** * Loads a {@link TransitionManager} object from a resource * * @param resource The resource id of the transition manager to load * @return The loaded TransitionManager object * @throws android.content.res.Resources.NotFoundException when the * transition manager cannot be loaded */ @Nullable public TransitionManager inflateTransitionManager(int resource, @NonNull ViewGroup sceneRoot) { XmlResourceParser parser = mContext.getResources().getXml(resource); try { return createTransitionManagerFromXml(parser, Xml.asAttributeSet(parser), sceneRoot); } catch (XmlPullParserException e) { InflateException ex = new InflateException(e.getMessage()); ex.initCause(e); throw ex; } catch (IOException e) { InflateException ex = new InflateException( parser.getPositionDescription() + ": " + e.getMessage()); ex.initCause(e); throw ex; } finally { parser.close(); } }
/** * Loads a {@link Transition} object from a resource * * @param resource The resource id of the transition to load * @return The loaded Transition object * @throws android.content.res.Resources.NotFoundException when the * transition cannot be loaded */ @Nullable public Transition inflateTransition(int resource) { XmlResourceParser parser = mContext.getResources().getXml(resource); try { return createTransitionFromXml(parser, Xml.asAttributeSet(parser), null); } catch (XmlPullParserException e) { InflateException ex = new InflateException(e.getMessage()); ex.initCause(e); throw ex; } catch (IOException e) { InflateException ex = new InflateException( parser.getPositionDescription() + ": " + e.getMessage()); ex.initCause(e); throw ex; } finally { parser.close(); } }
transition = null; } else if (parent != null) { throw new InflateException("Could not add transition to another transition.");
public InflatedOnMenuItemClickListener(Context context, String methodName) { mContext = context; Class<?> c = context.getClass(); try { mMethod = c.getMethod(methodName, PARAM_TYPES); } catch (Exception e) { InflateException ex = new InflateException( "Couldn't resolve menu item onClick handler " + methodName + " in class " + c.getName()); ex.initCause(e); throw ex; }
public InflatedOnMenuItemClickListener(Context context, String methodName) { mContext = context; Class<?> c = context.getClass(); try { mMethod = c.getMethod(methodName, PARAM_TYPES); } catch (Exception e) { InflateException ex = new InflateException( "Couldn't resolve menu item onClick handler " + methodName + " in class " + c.getName()); ex.initCause(e); throw ex; }
@Override protected View onInflateTemplate(LayoutInflater inflater, int template) { if (template == 0) { template = R.layout.suw_glif_template; } try { return super.onInflateTemplate(inflater, template); } catch (RuntimeException e) { // Versions before M throws RuntimeException for unsuccessful attribute resolution // Versions M+ will throw an InflateException (which extends from RuntimeException) throw new InflateException("Unable to inflate layout. Are you using " + "@style/SuwThemeGlif (or its descendant) as your theme?", e); } }
public InflatedOnMenuItemClickListener(Object realOwner, String methodName) { mRealOwner = realOwner; Class<?> c = realOwner.getClass(); try { mMethod = c.getMethod(methodName, PARAM_TYPES); } catch (Exception e) { InflateException ex = new InflateException( "Couldn't resolve menu item onClick handler " + methodName + " in class " + c.getName()); ex.initCause(e); throw ex; } }
public InflatedOnMenuItemClickListener(Context context, String methodName) { mContext = context; Class<?> c = context.getClass(); try { mMethod = c.getMethod(methodName, PARAM_TYPES); } catch (Exception e) { InflateException ex = new InflateException( "Couldn't resolve menu item onClick handler " + methodName + " in class " + c.getName()); ex.initCause(e); throw ex; } }
@Override protected View onInflateTemplate(LayoutInflater inflater, int template) { if (template == 0) { template = R.layout.suw_template; } try { return super.onInflateTemplate(inflater, template); } catch (RuntimeException e) { // Versions before M throws RuntimeException for unsuccessful attribute resolution // Versions M+ will throw an InflateException (which extends from RuntimeException) throw new InflateException("Unable to inflate layout. Are you using " + "@style/SuwThemeMaterial (or its descendant) as your theme?", e); } }
throw new InflateException(errorMessage); } else { return instance;
/** * Inflate a menu hierarchy from the specified XML resource. Throws * {@link InflateException} if there is an error. * * @param menuRes Resource ID for an XML layout resource to load (e.g., * <code>R.menu.main_activity</code>) * @param menu The Menu to inflate into. The items and submenus will be * added to this Menu. */ public void inflate(int menuRes, Menu menu) { XmlResourceParser parser = null; try { parser = mContext.getResources().getLayout(menuRes); AttributeSet attrs = Xml.asAttributeSet(parser); parseMenu(parser, attrs, menu); } catch (XmlPullParserException e) { throw new InflateException("Error inflating menu XML", e); } catch (IOException e) { throw new InflateException("Error inflating menu XML", e); } finally { if (parser != null) parser.close(); } }
/** * Inflate a menu hierarchy from the specified XML resource. Throws * {@link InflateException} if there is an error. * * @param menuRes Resource ID for an XML layout resource to load (e.g., * <code>R.menu.main_activity</code>) * @param menu The Menu to inflate into. The items and submenus will be * added to this Menu. */ public void inflate(int menuRes, Menu menu) { XmlResourceParser parser = null; try { parser = mContext.getResources().getLayout(menuRes); AttributeSet attrs = Xml.asAttributeSet(parser); parseMenu(parser, attrs, menu); } catch (XmlPullParserException e) { throw new InflateException("Error inflating menu XML", e); } catch (IOException e) { throw new InflateException("Error inflating menu XML", e); } finally { if (parser != null) parser.close(); } }
@NonNull private Preference createItemFromTag(@NonNull String name, @NonNull AttributeSet attrs) { try { final Preference item; if (-1 == name.indexOf('.')) { item = createItem(name, getDefaultPackages(), attrs); } else { item = createItem(name, null, attrs); } return item; } catch (InflateException e) { throw e; } catch (ClassNotFoundException e) { final InflateException ie = new InflateException(attrs .getPositionDescription() + ": Error inflating class (not found)" + name); ie.initCause(e); throw ie; } catch (Exception e) { final InflateException ie = new InflateException(attrs .getPositionDescription() + ": Error inflating class " + name); ie.initCause(e); throw ie; } }
private T createItemFromTag(XmlPullParser parser, String name, AttributeSet attrs) { if (DEBUG) Log.v(TAG, "******** Creating item: " + name); try { T item = (mFactory == null) ? null : mFactory.onCreateItem(name, mContext, attrs); if (item == null) { if (-1 == name.indexOf('.')) { item = onCreateItem(name, attrs); } else { item = createItem(name, null, attrs); } } if (DEBUG) Log.v(TAG, "Created item is: " + item); return item; } catch (InflateException e) { throw e; } catch (Exception e) { InflateException ie = new InflateException(attrs .getPositionDescription() + ": Error inflating class " + name); ie.initCause(e); throw ie; } }
final Path path = PathData.toPath(pathData); if (path.isEmpty()) { throw new InflateException("The path cannot be empty"); throw new InflateException("pathInterpolator requires the controlX1 attribute"); } else if (!TypedArrayUtils.hasAttribute(parser, "controlY1")) { throw new InflateException("pathInterpolator requires the controlY1 attribute"); throw new InflateException( "pathInterpolator requires both controlX2 and controlY2 for cubic bezier curves");
public void inflateMenu(@MenuRes int menuRes) { if (menuRes == 0) return; getActivity().getMenuInflater() .inflate(menuRes, mActionMenu.getMenu()); XmlResourceParser parser = null; try { //noinspection ResourceType parser = getResources().getLayout(menuRes); AttributeSet attrs = Xml.asAttributeSet(parser); parseMenu(parser, attrs); } catch (XmlPullParserException | IOException e) { // should not happens throw new InflateException("Error parsing menu XML", e); } finally { if (parser != null) parser.close(); } }