Example usage for android.util AttributeSet getAttributeIntValue

List of usage examples for android.util AttributeSet getAttributeIntValue

Introduction

In this page you can find the example usage for android.util AttributeSet getAttributeIntValue.

Prototype

public int getAttributeIntValue(String namespace, String attribute, int defaultValue);

Source Link

Document

Return the integer value of 'attribute'.

Usage

From source file:Main.java

public static int getIntAttribute(final Context context, final AttributeSet attrs, final String namespace,
        final String name, final int defValue) {
    final int resId = attrs.getAttributeResourceValue(namespace, name, Integer.MIN_VALUE);
    if (resId != Integer.MIN_VALUE) {
        final String string = context.getResources().getString(resId);
        try {/*from  w w  w .  j a v  a  2s . c o m*/
            return Integer.parseInt(string);
        } catch (final NumberFormatException e) {
        }
    }
    return attrs.getAttributeIntValue(namespace, name, defValue);
}

From source file:com.quran.labs.androidquran.ui.preference.SeekBarPreference.java

public SeekBarPreference(Context context, AttributeSet attrs) {
    super(context, attrs);
    mContext = context;/* ww  w  . j ava  2s  . co  m*/
    mSuffix = attrs.getAttributeValue(ANDROID_NS, "text");
    mDefault = attrs.getAttributeIntValue(ANDROID_NS, "defaultValue", Constants.DEFAULT_TEXT_SIZE);
    mMax = attrs.getAttributeIntValue(ANDROID_NS, "max", 100);
    setLayoutResource(R.layout.seekbar_pref);
    mTintColor = ContextCompat.getColor(context, R.color.accent_color);
}

From source file:de.fahrgemeinschaft.util.EditTextImageButton.java

public EditTextImageButton(Context context, AttributeSet attrs) {
    super(context, attrs);
    text = (AutoCompletePicker) findViewById(R.id.text);
    text.setThreshold(1);//from  w  w  w  .j a  va2s .  co  m
    text.setId(ID--);
    text.setHint(getContext().getString(attrs.getAttributeResourceValue(droid, HINT, R.string.app_name)));
    text.setInputType((attrs.getAttributeIntValue(droid, INPUT_TYPE, InputType.TYPE_CLASS_TEXT)));
    text.addTextChangedListener(this);
    Util.fixStreifenhoernchen(text);
    text.setSelectAllOnFocus(true);
    icon.setOnClickListener(this);
}

From source file:com.yek.keyboard.keyboardextensions.KeyboardExtensionFactory.java

@Override
protected KeyboardExtension createConcreteAddOn(Context askContext, Context context, String prefId,
        int nameResId, String description, boolean isHidden, int sortIndex, AttributeSet attrs) {
    int keyboardResId = attrs.getAttributeResourceValue(null, XML_EXT_KEYBOARD_RES_ID_ATTRIBUTE,
            AddOn.INVALID_RES_ID);/*from  www.ja  va 2s .  c  o m*/
    if (keyboardResId == AddOn.INVALID_RES_ID)
        keyboardResId = attrs.getAttributeIntValue(null, XML_EXT_KEYBOARD_RES_ID_ATTRIBUTE,
                AddOn.INVALID_RES_ID);
    @KeyboardExtension.KeyboardExtensionType
    int extensionType = attrs.getAttributeResourceValue(null, XML_EXT_KEYBOARD_TYPE_ATTRIBUTE,
            AddOn.INVALID_RES_ID);
    if (extensionType != AddOn.INVALID_RES_ID) {
        extensionType = KeyboardExtension.ensureValidType(context.getResources().getInteger(extensionType));
    } else {
        extensionType = attrs.getAttributeIntValue(null, XML_EXT_KEYBOARD_TYPE_ATTRIBUTE, AddOn.INVALID_RES_ID);
    }
    Logger.d(TAG, "Parsing Extension Keyboard! prefId %s, keyboardResId %d, type %d", prefId, keyboardResId,
            extensionType);

    if (extensionType == AddOn.INVALID_RES_ID) {
        throw new RuntimeException(String.format(Locale.US,
                "Missing details for creating Extension Keyboard! prefId %s\nkeyboardResId: %d, type: %d",
                prefId, keyboardResId, extensionType));
    } else {
        return new KeyboardExtension(askContext, context, prefId, nameResId, keyboardResId, extensionType,
                description, isHidden, sortIndex);
    }
}

From source file:com.anysoftkeyboard.keyboardextensions.KeyboardExtensionFactory.java

@Override
protected KeyboardExtension createConcreteAddOn(Context askContext, Context context, String prefId,
        int nameResId, String description, boolean isHidden, int sortIndex, AttributeSet attrs) {
    int keyboardResId = attrs.getAttributeResourceValue(null, XML_EXT_KEYBOARD_RES_ID_ATTRIBUTE,
            AddOn.INVALID_RES_ID);//from www. jav  a2s . c om
    if (keyboardResId == AddOn.INVALID_RES_ID)
        keyboardResId = attrs.getAttributeIntValue(null, XML_EXT_KEYBOARD_RES_ID_ATTRIBUTE,
                AddOn.INVALID_RES_ID);
    @KeyboardExtension.KeyboardExtensionType
    int extensionType = attrs.getAttributeResourceValue(null, XML_EXT_KEYBOARD_TYPE_ATTRIBUTE,
            AddOn.INVALID_RES_ID);
    if (extensionType != AddOn.INVALID_RES_ID) {
        extensionType = KeyboardExtension.ensureValidType(context.getResources().getInteger(extensionType));
    } else {
        extensionType = attrs.getAttributeIntValue(null, XML_EXT_KEYBOARD_TYPE_ATTRIBUTE, AddOn.INVALID_RES_ID);
    }
    Logger.d(mTag, "Parsing Extension Keyboard! prefId %s, keyboardResId %d, type %d", prefId, keyboardResId,
            extensionType);

    if (extensionType == AddOn.INVALID_RES_ID) {
        throw new RuntimeException(String.format(Locale.US,
                "Missing details for creating Extension Keyboard! prefId %s\nkeyboardResId: %d, type: %d",
                prefId, keyboardResId, extensionType));
    } else {
        return new KeyboardExtension(askContext, context, prefId, nameResId, keyboardResId, extensionType,
                description, isHidden, sortIndex);
    }
}

From source file:de.madvertise.android.sdk.MadView.java

/**
 * Reads all parameters, not needed for a request to the ad server (colors,
 * refresh timeout, ...)/* w ww. j av  a2  s . c o  m*/
 * 
 * @param attrs
 *            attribute set for the view
 */
private void initParameters(AttributeSet attrs) {
    if (attrs != null) {
        String packageName = "http://schemas.android.com/apk/res/" + getContext().getPackageName();
        if (packageName != null) {
            MadUtil.logMessage(null, Log.DEBUG, "namespace = " + packageName);
        }
        testMode = attrs.getAttributeBooleanValue(packageName, "isTestMode", IS_TESTMODE_DEFAULT);
        textColor = attrs.getAttributeIntValue(packageName, "textColor", MadUtil.TEXT_COLOR_DEFAULT);
        backgroundColor = attrs.getAttributeIntValue(packageName, "backgroundColor",
                MadUtil.BACKGROUND_COLOR_DEFAULT);
        secondsToRefreshAd = attrs.getAttributeIntValue(packageName, "secondsToRefresh",
                MadUtil.SECONDS_TO_REFRESH_AD_DEFAULT);
        bannerType = attrs.getAttributeValue(packageName, "bannerType");
        if (bannerType == null)
            bannerType = MadUtil.BANNER_TYPE_DEFAULT;
        deliverOnlyText = attrs.getAttributeBooleanValue(packageName, "deliverOnlyText",
                MadUtil.DELIVER_ONLY_TEXT_DEFAULT);
        textSize = attrs.getAttributeIntValue(packageName, "textSize", MadUtil.TEXT_SIZE_DEFAULT);
    } else {
        MadUtil.logMessage(null, Log.DEBUG, "AttributeSet is null!");
    }

    if (secondsToRefreshAd != 0 && secondsToRefreshAd < 60)
        secondsToRefreshAd = MadUtil.SECONDS_TO_REFRESH_AD_DEFAULT;

    if (bannerType.equals("iab"))
        bannerHeight = MadUtil.IAB_BANNER_HEIGHT_DEFAULT;

    MadUtil.logMessage(null, Log.DEBUG, "Using following attributes values:");
    MadUtil.logMessage(null, Log.DEBUG, " testMode = " + testMode);
    MadUtil.logMessage(null, Log.DEBUG, " textColor = " + textColor);
    MadUtil.logMessage(null, Log.DEBUG, " backgroundColor = " + backgroundColor);
    MadUtil.logMessage(null, Log.DEBUG, " secondsToRefreshAd = " + secondsToRefreshAd);
    MadUtil.logMessage(null, Log.DEBUG, " bannerType = " + bannerType);
    MadUtil.logMessage(null, Log.DEBUG, " deliverOnlyText = " + deliverOnlyText);
    MadUtil.logMessage(null, Log.DEBUG, " textSize = " + textSize);
    MadUtil.logMessage(null, Log.DEBUG, " bannerHeight = " + bannerHeight);
}

From source file:cn.com.zzwfang.view.directionalviewpager.DirectionalViewPager.java

public DirectionalViewPager(Context context, AttributeSet attrs) {
    super(context, attrs);
    initViewPager();// w  w  w .  j  a v a 2  s . c o  m

    //We default to horizontal, only change if a value is explicitly specified
    int orientation = attrs.getAttributeIntValue(XML_NS, "orientation", -1);
    if (orientation != -1) {
        setOrientation(orientation);
    }
}

From source file:com.coleman.demo.view.page.DirectionalViewPager.java

public DirectionalViewPager(Context context, AttributeSet attrs) {
    super(context, attrs);
    initViewPager();/*from  w  w  w.j  ava2s .  c  o m*/

    // We default to horizontal, only change if a value is explicitly
    // specified
    int orientation = attrs.getAttributeIntValue(XML_NS, "orientation", -1);
    if (orientation != -1) {
        setOrientation(orientation);
    }
}

From source file:info.ipeanut.youngsamples.third.viewgroup.directionalViewPager.DirectionalViewPager.java

public DirectionalViewPager(Context context, AttributeSet attrs) {
    super(context, attrs);
    initViewPager();/*from   w ww  .  ja v a  2s . c  o  m*/

    /**
    //We default to horizontal, only change if a value is explicitly specified
    //android/widget/LinearLayout.java ??  ?  
    public static final int HORIZONTAL = 0;
    public static final int VERTICAL = 1;
     */
    //XML_NS??   orientation  
    int orientation = attrs.getAttributeIntValue(XML_NS, "orientation", -1);
    if (orientation != -1) {
        setOrientation(orientation);
    }
}

From source file:de.madvertise.android.sdk.MadvertiseView.java

/**
 * Reads all parameters, not needed for a request to the ad server (colors,
 * refresh timeout, ...)//from   www .ja  va2 s .c  o  m
 *
 * @param attrs attribute set for the view
 */
private void initParameters(final AttributeSet attrs) {
    mDp = getContext().getApplicationContext().getResources().getDisplayMetrics().density;

    if (attrs != null) {
        String packageName = "http://schemas.android.com/apk/res/"
                + getContext().getApplicationContext().getPackageName();
        if (packageName != null) {
            MadvertiseUtil.logMessage(null, Log.DEBUG, "namespace = " + packageName);
        }

        mTestMode = attrs.getAttributeBooleanValue(packageName, "isTestMode", IS_TESTMODE_DEFAULT);

        mTextColor = attrs.getAttributeIntValue(packageName, "textColor", MadvertiseUtil.TEXT_COLOR_DEFAULT);

        mBackgroundColor = attrs.getAttributeIntValue(packageName, "backgroundColor",
                MadvertiseUtil.BACKGROUND_COLOR_DEFAULT);

        mSecondsToRefreshAd = attrs.getAttributeIntValue(packageName, "secondsToRefresh",
                MadvertiseUtil.SECONDS_TO_REFRESH_AD_DEFAULT);

        if (attrs.getAttributeValue(packageName, "bannerType") != null) {
            mBannerType = attrs.getAttributeValue(packageName, "bannerType");
        }

        if (attrs.getAttributeValue(packageName, "animation") != null) {
            mAnimationType = attrs.getAttributeValue(packageName, "animation");
        }

        mDeliverOnlyText = attrs.getAttributeBooleanValue(packageName, "deliverOnlyText",
                MadvertiseUtil.DELIVER_ONLY_TEXT_DEFAULT);

        if (!mBannerType.equals(MadvertiseUtil.BANNER_TYPE_MMA) && mDeliverOnlyText) {
            MadvertiseUtil.logMessage(null, Log.DEBUG,
                    "Only banners in mma-format can show text. Setting deliferOnlyText to false.");
            mDeliverOnlyText = false;
        }

        mTextSize = attrs.getAttributeIntValue(packageName, "textSize", MadvertiseUtil.TEXT_SIZE_DEFAULT);

        if (mTextSize > 20) {
            MadvertiseUtil.logMessage(null, Log.DEBUG, "The text size must be set to 20 at maximum.");
            mTextSize = 20;
        } else if (mTextSize < 10) {
            MadvertiseUtil.logMessage(null, Log.DEBUG, "The text size must be set to 10 at minimum.");
            mTextSize = 10;
        }

        mIsMraid = attrs.getAttributeBooleanValue(packageName, "mraid", true);

        final String placementTypeStr = attrs.getAttributeValue(packageName, "placement_type");
        if (placementTypeStr != null && placementTypeStr.equalsIgnoreCase("inline")) {
            mPlacementType = MadvertiseUtil.PLACEMENT_TYPE_INLINE;
        } else if (placementTypeStr != null && placementTypeStr.equalsIgnoreCase("interstitial")) {
            mPlacementType = MadvertiseUtil.PLACEMENT_TYPE_INTERSTITIAL;
        }
    } else {
        MadvertiseUtil.logMessage(null, Log.DEBUG, "AttributeSet is null. Using default parameters");
    }

    if (mSecondsToRefreshAd != 0 && mSecondsToRefreshAd < 30) {
        mSecondsToRefreshAd = MadvertiseUtil.SECONDS_TO_REFRESH_AD_DEFAULT;
        MadvertiseUtil.logMessage(null, Log.DEBUG, "Refresh intervall must be higher than 60");
    }

    calculateBannerDimensions();

    MadvertiseUtil.logMessage(null, Log.DEBUG, "Using following attributes values:");
    MadvertiseUtil.logMessage(null, Log.DEBUG, " testMode = " + mTestMode);
    MadvertiseUtil.logMessage(null, Log.DEBUG, " textColor = " + mTextColor);
    MadvertiseUtil.logMessage(null, Log.DEBUG, " backgroundColor = " + mBackgroundColor);
    MadvertiseUtil.logMessage(null, Log.DEBUG, " secondsToRefreshAd = " + mSecondsToRefreshAd);
    MadvertiseUtil.logMessage(null, Log.DEBUG, " bannerType = " + mBannerType);
    MadvertiseUtil.logMessage(null, Log.DEBUG, " animationType = " + mAnimationType);
    MadvertiseUtil.logMessage(null, Log.DEBUG, " deliverOnlyText = " + mDeliverOnlyText);
    MadvertiseUtil.logMessage(null, Log.DEBUG, " textSize = " + mTextSize);
    MadvertiseUtil.logMessage(null, Log.DEBUG, " isMraid = " + mIsMraid);
    MadvertiseUtil.logMessage(null, Log.DEBUG, " placementType = " + mPlacementType);
    MadvertiseUtil.logMessage(null, Log.DEBUG, " bannerWidth = " + mBannerWidth);
    MadvertiseUtil.logMessage(null, Log.DEBUG, " bannerHeight = " + mBannerHeight);
    MadvertiseUtil.logMessage(null, Log.DEBUG, " bannerWidthDp = " + mBannerWidthDp);
    MadvertiseUtil.logMessage(null, Log.DEBUG, " bannerHeightDp = " + mBannerHeightDp);
}