Example usage for android.view InflateException InflateException

List of usage examples for android.view InflateException InflateException

Introduction

In this page you can find the example usage for android.view InflateException InflateException.

Prototype

public InflateException(String detailMessage, Throwable throwable) 

Source Link

Usage

From source file:android.support.transition.TransitionInflater.java

/**
 * Loads a {@link Transition} object from a resource
 *
 * @param resource The resource id of the transition to load
 * @return The loaded Transition object/*from w  ww  . ja  va  2s.com*/
 * @throws android.content.res.Resources.NotFoundException when the
 *                                                         transition cannot be loaded
 */
public Transition inflateTransition(int resource) {
    XmlResourceParser parser = mContext.getResources().getXml(resource);
    try {
        return createTransitionFromXml(parser, Xml.asAttributeSet(parser), null);
    } catch (XmlPullParserException e) {
        throw new InflateException(e.getMessage(), e);
    } catch (IOException e) {
        throw new InflateException(parser.getPositionDescription() + ": " + e.getMessage(), e);
    } finally {
        parser.close();
    }
}

From source file:android.support.v7.internal.view.SupportMenuInflater.java

/**
 * 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.// w  w w  . ja va  2 s. c o  m
 */
@Override
public void inflate(int menuRes, Menu menu) {
    // If we're not dealing with a SupportMenu instance, let super handle
    if (!(menu instanceof SupportMenu)) {
        super.inflate(menuRes, menu);
        return;
    }

    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();
    }
}

From source file:com.actionbarsherlock.view.MenuInflater.java

/**
 * 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.//from  www . j  a v a 2s.c om
 */
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();
    }
}

From source file:lewa.support.v7.internal.view.SupportMenuInflater.java

/**
 * 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./*  w w w  .  j a  v a 2 s .c o m*/
 */
@Override
public void inflate(int menuRes, Menu menu) {
    // If we're not dealing with a SupportMenu instance, let super handle
    if (!(menu instanceof SupportMenu)) {
        super.inflate(menuRes, menu);
        return;
    }
    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();
    }
}

From source file:com.actionbarsherlock.internal.view.menu.MenuInflaterImpl.java

/**
 * 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.//  www. ja v a  2 s.  c om
 */
public void inflate(int menuRes, android.view.Menu menu) {
    if (!(menu instanceof MenuBuilder)) {
        mNativeMenuInflater.inflate(menuRes, menu);
        return;
    }

    MenuBuilder actionBarMenu = (MenuBuilder) menu;
    XmlResourceParser parser = null;
    try {
        parser = mContext.getResources().getLayout(menuRes);
        AttributeSet attrs = Xml.asAttributeSet(parser);

        parseMenu(parser, attrs, actionBarMenu);
    } 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();
    }
}

From source file:com.justplay1.shoppist.features.search.widget.FloatingSearchView.java

public void inflateMenu(@MenuRes int menuRes) {
    if (menuRes == 0)
        return;/*from   ww w  .  ja v a 2 s  . c  o  m*/
    getActivity().getMenuInflater().inflate(menuRes, actionMenu.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();
    }
}