Example usage for android.content.res TypedArray getString

List of usage examples for android.content.res TypedArray getString

Introduction

In this page you can find the example usage for android.content.res TypedArray getString.

Prototype

@Nullable
public String getString(@StyleableRes int index) 

Source Link

Document

Retrieves the string value for the attribute at index.

Usage

From source file:es.voghdev.pdfviewpager.library.PDFViewPager.java

protected void init(AttributeSet attrs) {
    if (isInEditMode()) {
        setBackgroundResource(R.drawable.flaticon_pdf_dummy);
        return;//from w ww.  j  ava2 s  . c o m
    }

    if (attrs != null) {
        TypedArray a;

        a = context.obtainStyledAttributes(attrs, R.styleable.PDFViewPager);
        String assetFileName = a.getString(R.styleable.PDFViewPager_assetFileName);

        if (assetFileName != null && assetFileName.length() > 0) {
            initAdapter(context, assetFileName);
        }
    }
}

From source file:com.netpace.expressit.android.ui.TypefaceEditText.java

public TypefaceEditText(Context context, AttributeSet attrs) {
    super(context, attrs);

    // Get our custom attributes
    TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.TypefaceTextView, 0, 0);

    try {/*from w  w w .j a v a 2 s  .co m*/
        String typefaceName = a.getString(R.styleable.TypefaceTextView_typeface);

        if (!isInEditMode() && !TextUtils.isEmpty(typefaceName)) {
            Typeface typeface = sTypefaceCache.get(typefaceName);

            if (typeface == null) {
                typeface = Typeface.createFromAsset(context.getAssets(),
                        String.format("fonts/%s_0.otf", typefaceName));

                // Cache the Typeface object
                sTypefaceCache.put(typefaceName, typeface);
            }
            setTypeface(typeface);

            // Note: This flag is required for proper typeface rendering
            setPaintFlags(getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG);
        }
    } finally {
        a.recycle();
    }
}

From source file:es.voghdev.pdfviewpager.library.RemotePDFVerticalViewPager.java

private void init(AttributeSet attrs) {
    if (attrs != null) {
        TypedArray a;

        a = context.obtainStyledAttributes(attrs, R.styleable.PDFViewPager);
        String pdfUrl = a.getString(R.styleable.PDFViewPager_pdfUrl);

        if (pdfUrl != null && pdfUrl.length() > 0) {
            init(new DownloadFileUrlConnectionImpl(context, new Handler(), this), pdfUrl);
        }// www.j  a va 2 s .co  m

        a.recycle();
    }
}

From source file:org.getlantern.firetweet.preference.ValueDependencyCheckBoxPreference.java

public ValueDependencyCheckBoxPreference(final Context context, final AttributeSet attrs, final int defStyle) {
    super(context, attrs, defStyle);
    final Resources res = context.getResources();
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ValueDependencyPreference, defStyle,
            0);/*from  ww w  .  j  a v a 2 s  . co m*/
    mDependencyKey = a.getString(R.styleable.ValueDependencyPreference_dependencyKey);
    final int dependencyValueRes = a.getResourceId(R.styleable.ValueDependencyPreference_dependencyValues, 0);
    mDependencyValues = dependencyValueRes > 0 ? res.getStringArray(dependencyValueRes) : null;
    mDependencyValueDefault = a.getString(R.styleable.ValueDependencyPreference_dependencyValueDefault);
    a.recycle();
}

From source file:org.getlantern.firetweet.preference.ValueDependencyDialogPreference.java

public ValueDependencyDialogPreference(final Context context, final AttributeSet attrs, final int defStyle) {
    super(context, attrs, defStyle);
    final Resources res = context.getResources();
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ValueDependencyPreference, defStyle,
            0);//from w  w  w. j  a va 2s  .  co m
    mDependencyKey = a.getString(R.styleable.ValueDependencyPreference_dependencyKey);
    final int dependencyValueRes = a.getResourceId(R.styleable.ValueDependencyPreference_dependencyValues, 0);
    mDependencyValues = dependencyValueRes > 0 ? res.getStringArray(dependencyValueRes) : null;
    mDependencyValueDefault = a.getString(R.styleable.ValueDependencyPreference_dependencyValueDefault);
    a.recycle();
}

From source file:org.getlantern.firetweet.preference.ValueDependencySeekBarDialogPreference.java

public ValueDependencySeekBarDialogPreference(final Context context, final AttributeSet attrs,
        final int defStyle) {
    super(context, attrs, defStyle);
    final Resources res = context.getResources();
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ValueDependencyPreference, defStyle,
            0);/*from  w w w. j a v  a  2s.co  m*/
    mDependencyKey = a.getString(R.styleable.ValueDependencyPreference_dependencyKey);
    final int dependencyValueRes = a.getResourceId(R.styleable.ValueDependencyPreference_dependencyValues, 0);
    mDependencyValues = dependencyValueRes > 0 ? res.getStringArray(dependencyValueRes) : null;
    mDependencyValueDefault = a.getString(R.styleable.ValueDependencyPreference_dependencyValueDefault);
    a.recycle();
}

From source file:se.frikod.payday.TypefaceTextView.java

public TypefaceTextView(Context context, AttributeSet attrs) {
    super(context, attrs);

    // Get our custom attributes
    TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.TypefaceTextView, 0, 0);

    try {//from  www.  j av a2 s .  co  m
        String typefaceName = a.getString(R.styleable.TypefaceTextView_typeface);

        if (!isInEditMode() && !TextUtils.isEmpty(typefaceName)) {
            Typeface typeface = sTypefaceCache.get(typefaceName);

            if (typeface == null) {
                typeface = Typeface.createFromAsset(context.getAssets(), String.format("%s", typefaceName));

                // Cache the Typeface object
                sTypefaceCache.put(typefaceName, typeface);
            }
            setTypeface(typeface);

            // Note: This flag is required for proper typeface rendering
            setPaintFlags(getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG);
        }
    } finally {
        a.recycle();
    }
}

From source file:com.ipa.Tools.TypefaceTextView.java

public TypefaceTextView(Context context, AttributeSet attrs) {
    super(context, attrs);
    // Get our custom attributes
    TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.TypefaceTextView, 0, 0);

    try {//from w w w  .  j a v  a  2  s. c o  m
        String typefaceName = a.getString(R.styleable.TypefaceTextView_typeface);

        if (!isInEditMode() && !TextUtils.isEmpty(typefaceName)) {
            Typeface typeface = sTypefaceCache.get(typefaceName);

            if (typeface == null) {
                typeface = Typeface.createFromAsset(context.getAssets(),
                        String.format("fonts/%s-Family.otf", typefaceName));

                // Cache the Typeface object
                sTypefaceCache.put(typefaceName, typeface);
            }
            setTypeface(typeface);

            // Note: This flag is required for proper typeface rendering
            setPaintFlags(getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG);
        }
    } finally {
        a.recycle();
    }
}

From source file:com.netpace.expressit.android.ui.TypefaceTextView.java

public TypefaceTextView(Context context, AttributeSet attrs) {
    super(context, attrs);

    // Get our custom attributes
    TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.TypefaceTextView, 0, 0);

    try {//w ww  .j  a va2s .com
        String typefaceName = a.getString(R.styleable.TypefaceTextView_typeface);

        if (!isInEditMode() && !TextUtils.isEmpty(typefaceName)) {
            Typeface typeface = sTypefaceCache.get(typefaceName);

            if (typeface == null) {
                typeface = Typeface.createFromAsset(context.getAssets(),
                        String.format("fonts/%s_0.otf", typefaceName));

                // Cache the Typeface object
                sTypefaceCache.put(typefaceName, typeface);
            }
            setTypeface(typeface);

            // Note: This flag is required for proper typeface rendering
            setPaintFlags(getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG);
        }
    } finally {
        a.recycle();
    }
}

From source file:com.mjaworski.myQuotes.Utils.TypefaceTextView.java

public TypefaceTextView(Context context, AttributeSet attrs) {
    super(context, attrs);

    // Get our custom attributes
    TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.TypefaceTextView, 0, 0);

    try {//  w  ww.  j a v  a 2 s .  c o  m
        String typefaceName = a.getString(R.styleable.TypefaceTextView_typeface);

        if (!isInEditMode() && !TextUtils.isEmpty(typefaceName)) {
            Typeface typeface = sTypefaceCache.get(typefaceName);

            if (typeface == null) {
                typeface = Typeface.createFromAsset(context.getAssets(),
                        String.format("fonts/%s", typefaceName));

                // Cache the Typeface object
                sTypefaceCache.put(typefaceName, typeface);
            }
            setTypeface(typeface);
        }
    } finally {
        a.recycle();
    }
}