Java Code Examples for android.support.v4.content.res.TypedArrayUtils

The following examples show how to use android.support.v4.content.res.TypedArrayUtils. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: FontProvider   Source File: IntegerSimpleMenuPreference.java    License: MIT License 4 votes vote down vote up
@SuppressLint("RestrictedApi")
public IntegerSimpleMenuPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);

    TypedArray a = context.obtainStyledAttributes(attrs,
            R.styleable.SimpleMenuPreference, defStyleAttr, defStyleRes);

    a.recycle();

    a = context.obtainStyledAttributes(
            attrs, R.styleable.ListPreference, defStyleAttr, defStyleRes);

    mEntries = TypedArrayUtils.getTextArray(a, R.styleable.ListPreference_entries,
            R.styleable.ListPreference_android_entries);

    mEntryValues = getIntArray(a, R.styleable.ListPreference_entryValues,
            R.styleable.ListPreference_android_entryValues);

    a.recycle();

    /* Retrieve the Preference summary attribute since it's private
     * in the Preference class.
     */
    a = context.obtainStyledAttributes(attrs,
            R.styleable.Preference, defStyleAttr, defStyleRes);

    mSummary = TypedArrayUtils.getString(a, R.styleable.Preference_summary,
            R.styleable.Preference_android_summary);

    a.recycle();

    a = context.obtainStyledAttributes(
            attrs, R.styleable.SimpleMenuPreference, defStyleAttr, defStyleRes);

    int popupStyle = a.getResourceId(R.styleable.SimpleMenuPreference_popupStyle, R.style.Preference_SimpleMenuPreference_Popup);

    mPopupWindow = new SimpleMenuPopupWindow(context, attrs, R.styleable.SimpleMenuPreference_popupStyle, popupStyle);
    mPopupWindow.setOnItemClickListener(new SimpleMenuPopupWindow.OnItemClickListener() {
        @Override
        public void onClick(int i) {
            int value = getEntryValues()[i];
            if (callChangeListener(value)) {
                setValue(value);
            }
        }
    });
}
 
Example 2
Source Project: FontProvider   Source File: IntegerSimpleMenuPreference.java    License: MIT License 4 votes vote down vote up
@SuppressLint("RestrictedApi")
private static int[] getIntArray(TypedArray a, @StyleableRes int index,
                                 @StyleableRes int fallbackIndex) {
    int resourceId = TypedArrayUtils.getResourceId(a, index, fallbackIndex, 0);
    return a.getResources().getIntArray(resourceId);
}
 
Example 3
@SuppressLint("RestrictedApi")
public RadioButtonPreference(Context context, AttributeSet attrs) {
    this(context, attrs, TypedArrayUtils.getAttr(context, R.attr.checkBoxPreferenceStyle,
            android.R.attr.checkBoxPreferenceStyle));
}
 
Example 4
@SuppressLint("RestrictedApi")
public ColorPickerPreference(Context context, AttributeSet attrs) {
  this(context, attrs, TypedArrayUtils.getAttr(context, R.attr.dialogPreferenceStyle,
                                               android.R.attr.dialogPreferenceStyle));
}
 
Example 5
Source Project: Silence   Source File: RingtonePreference.java    License: GNU General Public License v3.0 4 votes vote down vote up
@SuppressLint("RestrictedApi")
public RingtonePreference(Context context, AttributeSet attrs) {
  this(context, attrs, TypedArrayUtils.getAttr(context, R.attr.dialogPreferenceStyle,
                                               android.R.attr.dialogPreferenceStyle));
}