Example usage for android.content.res XmlResourceParser getAttributeBooleanValue

List of usage examples for android.content.res XmlResourceParser getAttributeBooleanValue

Introduction

In this page you can find the example usage for android.content.res XmlResourceParser getAttributeBooleanValue.

Prototype

public boolean getAttributeBooleanValue(int index, boolean defaultValue);

Source Link

Document

Return the boolean value of attribute at 'index'.

Usage

From source file:com.wit.and.dialog.internal.xml.XmlWebDialog.java

/**
  *//* www.  java 2s  .  c  o  m*/
@Override
protected void onParseAttribute(XmlResourceParser xmlParser, int attr, int index,
        WebDialog.WebOptions options) {
    if (attr == R.attr.dialogJavascriptEnabled) {
        options.javascriptEnabled(xmlParser.getAttributeBooleanValue(index, true));
    } else {
        super.onParseAttribute(xmlParser, attr, index, options);
    }
}

From source file:com.wit.and.dialog.xml.XmlDialogParser.java

/**
 * <p>//w  ww .jav  a 2  s.c o m
 * Invoked to parse value of specific attribute from currently being parsed XML.
 * </p>
 *
 * @param xmlParser Xml resource parser at position of current attribute which value should be obtained.
 * @param attr      Id of attribute which value is placed at the <var>index</var> position in the <var>xmlParser</var>.
 * @param index     Index of value which should be obtained form the <var>xmlParser</var>.
 * @param options   Dialog options to set up obtained value from parser.
 */
protected void onParseAttribute(XmlResourceParser xmlParser, int attr, int index, O options) {
    if (attr == android.R.attr.title) {
        options.title(resolveString(xmlParser, index));
    } else if (attr == android.R.attr.icon) {
        options.icon(xmlParser.getAttributeResourceValue(index, 0));
    } else if (attr == android.R.attr.text) {
        options.message(resolveString(xmlParser, index));
    } else if (attr == R.attr.dialogButtonNegative) {
        options.negative(resolveString(xmlParser, index));
    } else if (attr == R.attr.dialogButtonNeutral) {
        options.neutral(resolveString(xmlParser, index));
    } else if (attr == R.attr.dialogButtonPositive) {
        options.positive(resolveString(xmlParser, index));
    } else if (attr == R.attr.dialogTheme) {
        options.dialogTheme(xmlParser.getAttributeResourceValue(index, 0));
    } else if (attr == R.attr.dialogCancelable) {
        options.cancelable(xmlParser.getAttributeBooleanValue(index, true));
    } else if (attr == R.attr.dialogDismissOnRestore) {
        options.dismissOnRestore(xmlParser.getAttributeBooleanValue(index, false));
    }
}

From source file:com.roughike.bottombar.TabParser.java

@NonNull
private BottomBarTab parseNewTab(@NonNull XmlResourceParser parser, @IntRange(from = 0) int containerPosition) {
    BottomBarTab workingTab = tabWithDefaults();
    workingTab.setIndexInContainer(containerPosition);

    final int numberOfAttributes = parser.getAttributeCount();
    for (int i = 0; i < numberOfAttributes; i++) {
        @TabAttribute/*w  w w.  j  a  va  2  s. c om*/
        String attrName = parser.getAttributeName(i);
        switch (attrName) {
        case ID:
            workingTab.setId(parser.getIdAttributeResourceValue(i));
            break;
        case ICON:
            workingTab.setIconResId(parser.getAttributeResourceValue(i, RESOURCE_NOT_FOUND));
            break;
        case TITLE:
            workingTab.setTitle(getTitleValue(parser, i));
            break;
        case INACTIVE_COLOR:
            int inactiveColor = getColorValue(parser, i);
            if (inactiveColor == COLOR_NOT_SET)
                continue;
            workingTab.setInActiveColor(inactiveColor);
            break;
        case ACTIVE_COLOR:
            int activeColor = getColorValue(parser, i);
            if (activeColor == COLOR_NOT_SET)
                continue;
            workingTab.setActiveColor(activeColor);
            break;
        case BAR_COLOR_WHEN_SELECTED:
            int barColorWhenSelected = getColorValue(parser, i);
            if (barColorWhenSelected == COLOR_NOT_SET)
                continue;
            workingTab.setBarColorWhenSelected(barColorWhenSelected);
            break;
        case BADGE_BACKGROUND_COLOR:
            int badgeBackgroundColor = getColorValue(parser, i);
            if (badgeBackgroundColor == COLOR_NOT_SET)
                continue;
            workingTab.setBadgeBackgroundColor(badgeBackgroundColor);
            break;
        case BADGE_HIDES_WHEN_ACTIVE:
            boolean badgeHidesWhenActive = parser.getAttributeBooleanValue(i, true);
            workingTab.setBadgeHidesWhenActive(badgeHidesWhenActive);
            break;
        case IS_TITLELESS:
            boolean isTitleless = parser.getAttributeBooleanValue(i, false);
            workingTab.setIsTitleless(isTitleless);
            break;
        }
    }

    return workingTab;
}