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:com.example.percentlayout.view.PercentLayoutHelper.java

/**
 * Constructs a PercentLayoutInfo from attributes associated with a View. Call this method from
 * {@code LayoutParams(Context c, AttributeSet attrs)} constructor.
 *//* w  w w .  j  a v  a2s. co  m*/
public static PercentLayoutInfo getPercentLayoutInfo(Context context, AttributeSet attrs) {
    PercentLayoutInfo info = null;
    TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.PercentLayout_Layout);

    int index = R.styleable.PercentLayout_Layout_layout_widthPercent;
    String sizeStr = array.getString(index);
    PercentLayoutInfo.PercentVal percentVal = getPercentVal(sizeStr, true);
    if (percentVal != null) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent width: " + percentVal.percent);
        }
        info = checkForInfoExists(info);
        info.widthPercent = percentVal;
    }
    sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_heightPercent);
    percentVal = getPercentVal(sizeStr, false);

    if (sizeStr != null) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent height: " + percentVal.percent);
        }
        info = checkForInfoExists(info);
        info.heightPercent = percentVal;
    }

    // value = array.getFraction(R.styleable.PercentLayout_Layout_layout_marginPercent, 1, 1, -1f);
    sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginPercent);
    // just for judge
    percentVal = getPercentVal(sizeStr, false);

    if (percentVal != null) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent margin: " + percentVal.percent);
        }
        info = checkForInfoExists(info);
        info.leftMarginPercent = getPercentVal(sizeStr, true);
        info.topMarginPercent = getPercentVal(sizeStr, false);
        info.rightMarginPercent = getPercentVal(sizeStr, true);
        info.bottomMarginPercent = getPercentVal(sizeStr, false);
    }
    //value = array.getFraction(R.styleable.PercentLayout_Layout_layout_marginLeftPercent, 1, 1,
    //      -1f);
    sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginLeftPercent);
    percentVal = getPercentVal(sizeStr, true);
    if (percentVal != null) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent left margin: " + percentVal.percent);
        }
        info = checkForInfoExists(info);
        info.leftMarginPercent = percentVal;
    }

    //  value = array.getFraction(R.styleable.PercentLayout_Layout_layout_marginTopPercent, 1, 1,
    //        -1f);
    sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginTopPercent);
    percentVal = getPercentVal(sizeStr, false);
    if (percentVal != null) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent top margin: " + percentVal.percent);
        }
        info = checkForInfoExists(info);
        info.topMarginPercent = percentVal;
    }
    // value = array.getFraction(R.styleable.PercentLayout_Layout_layout_marginRightPercent, 1, 1,
    //       -1f);
    sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginRightPercent);
    percentVal = getPercentVal(sizeStr, true);
    if (percentVal != null) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent right margin: " + percentVal.percent);
        }
        info = checkForInfoExists(info);
        info.rightMarginPercent = percentVal;
    }
    //value = array.getFraction(R.styleable.PercentLayout_Layout_layout_marginBottomPercent, 1, 1,
    //  -1f);
    sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginBottomPercent);
    percentVal = getPercentVal(sizeStr, false);
    if (percentVal != null) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent bottom margin: " + percentVal.percent);
        }
        info = checkForInfoExists(info);
        info.bottomMarginPercent = percentVal;
    }
    // value = array.getFraction(R.styleable.PercentLayout_Layout_layout_marginStartPercent, 1, 1,
    //       -1f);
    sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginStartPercent);
    percentVal = getPercentVal(sizeStr, true);
    if (percentVal != null) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent start margin: " + percentVal.percent);
        }
        info = checkForInfoExists(info);
        info.startMarginPercent = percentVal;
    }
    //value = array.getFraction(R.styleable.PercentLayout_Layout_layout_marginEndPercent, 1, 1,
    //      -1f);
    sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginEndPercent);
    percentVal = getPercentVal(sizeStr, true);
    if (percentVal != null) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent end margin: " + percentVal.percent);
        }
        info = checkForInfoExists(info);
        info.endMarginPercent = percentVal;
    }

    //textSizePercent
    sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_textSizePercent);
    percentVal = getPercentVal(sizeStr, false);
    if (percentVal != null) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent text size: " + percentVal.percent);
        }
        info = checkForInfoExists(info);
        info.textSizePercent = percentVal;
    }

    //maxWidth
    percentVal = getPercentVal(array, R.styleable.PercentLayout_Layout_layout_maxWidthPercent, true);
    if (percentVal != null) {
        checkForInfoExists(info);
        info.maxWidthPercent = percentVal;
    }
    //maxHeight
    percentVal = getPercentVal(array, R.styleable.PercentLayout_Layout_layout_maxHeightPercent, false);
    if (percentVal != null) {
        checkForInfoExists(info);
        info.maxHeightPercent = percentVal;
    }
    //minWidth
    percentVal = getPercentVal(array, R.styleable.PercentLayout_Layout_layout_minWidthPercent, true);
    if (percentVal != null) {
        checkForInfoExists(info);
        info.minWidthPercent = percentVal;
    }
    //minHeight
    percentVal = getPercentVal(array, R.styleable.PercentLayout_Layout_layout_minHeightPercent, false);
    Log.d(TAG, "minHeight = " + percentVal);
    if (percentVal != null) {
        checkForInfoExists(info);
        info.minHeightPercent = percentVal;
    }

    array.recycle();
    if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log.d(TAG, "constructed: " + info);
    }
    return info;
}

From source file:KSView.PercentLayoutHelper.java

/**
 * Constructs a PercentLayoutInfo from attributes associated with a View. Call this method from
 * {@code LayoutParams(Context c, AttributeSet attrs)} constructor.
 *//* ww  w.  jav  a2  s.  com*/
public static PercentLayoutInfo getPercentLayoutInfo(Context context, AttributeSet attrs) {
    PercentLayoutInfo info = null;
    TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.PercentLayout_Layout);

    int index = R.styleable.PercentLayout_Layout_layout_widthPercent;
    String sizeStr = array.getString(index);
    PercentLayoutInfo.PercentVal percentVal = getPercentVal(sizeStr, true);
    if (percentVal != null) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent width: " + percentVal.percent);
        }
        info = checkForInfoExists(info);
        info.widthPercent = percentVal;
    }
    sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_heightPercent);
    percentVal = getPercentVal(sizeStr, false);

    if (sizeStr != null) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent height: " + percentVal.percent);
        }
        info = checkForInfoExists(info);
        info.heightPercent = percentVal;
    }

    // value = array.getFraction(R.styleable.PercentLayout_Layout_layout_marginPercent, 1, 1, -1f);
    sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginPercent);
    // just for judge
    percentVal = getPercentVal(sizeStr, false);

    if (percentVal != null) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent margin: " + percentVal.percent);
        }
        info = checkForInfoExists(info);
        info.leftMarginPercent = getPercentVal(sizeStr, true);
        info.topMarginPercent = getPercentVal(sizeStr, false);
        info.rightMarginPercent = getPercentVal(sizeStr, true);
        info.bottomMarginPercent = getPercentVal(sizeStr, false);
    }
    //value = array.getFraction(R.styleable.PercentLayout_Layout_layout_marginLeftPercent, 1, 1,
    //      -1f);
    sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginLeftPercent);
    percentVal = getPercentVal(sizeStr, true);
    if (percentVal != null) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent left margin: " + percentVal.percent);
        }
        info = checkForInfoExists(info);
        info.leftMarginPercent = percentVal;
    }

    //  value = array.getFraction(R.styleable.PercentLayout_Layout_layout_marginTopPercent, 1, 1,
    //        -1f);
    sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginTopPercent);
    percentVal = getPercentVal(sizeStr, false);
    if (percentVal != null) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent top margin: " + percentVal.percent);
        }
        info = checkForInfoExists(info);
        info.topMarginPercent = percentVal;
    }
    // value = array.getFraction(R.styleable.PercentLayout_Layout_layout_marginRightPercent, 1, 1,
    //       -1f);
    sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginRightPercent);
    percentVal = getPercentVal(sizeStr, true);
    if (percentVal != null) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent right margin: " + percentVal.percent);
        }
        info = checkForInfoExists(info);
        info.rightMarginPercent = percentVal;
    }
    //value = array.getFraction(R.styleable.PercentLayout_Layout_layout_marginBottomPercent, 1, 1,
    //  -1f);
    sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginBottomPercent);
    percentVal = getPercentVal(sizeStr, false);
    if (percentVal != null) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent bottom margin: " + percentVal.percent);
        }
        info = checkForInfoExists(info);
        info.bottomMarginPercent = percentVal;
    }
    // value = array.getFraction(R.styleable.PercentLayout_Layout_layout_marginStartPercent, 1, 1,
    //       -1f);
    sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginStartPercent);
    percentVal = getPercentVal(sizeStr, true);
    if (percentVal != null) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent start margin: " + percentVal.percent);
        }
        info = checkForInfoExists(info);
        info.startMarginPercent = percentVal;
    }
    //value = array.getFraction(R.styleable.PercentLayout_Layout_layout_marginEndPercent, 1, 1,
    //      -1f);
    sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginEndPercent);
    percentVal = getPercentVal(sizeStr, true);
    if (percentVal != null) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent end margin: " + percentVal.percent);
        }
        info = checkForInfoExists(info);
        info.endMarginPercent = percentVal;
    }

    //textSizePercent
    sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_textSizePercent);
    percentVal = getPercentVal(sizeStr, false);
    if (percentVal != null) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent text size: " + percentVal.percent);
        }
        info = checkForInfoExists(info);
        info.textSizePercent = percentVal;
    }

    //maxWidth
    percentVal = getPercentVal(array, R.styleable.PercentLayout_Layout_layout_maxWidthPercent, true);
    if (percentVal != null) {
        checkForInfoExists(info);
        info.maxWidthPercent = percentVal;
    }
    //maxHeight
    percentVal = getPercentVal(array, R.styleable.PercentLayout_Layout_layout_maxHeightPercent, false);
    if (percentVal != null) {
        checkForInfoExists(info);
        info.maxHeightPercent = percentVal;
    }
    //minWidth
    percentVal = getPercentVal(array, R.styleable.PercentLayout_Layout_layout_minWidthPercent, true);
    if (percentVal != null) {
        checkForInfoExists(info);
        info.minWidthPercent = percentVal;
    }
    //minHeight
    percentVal = getPercentVal(array, R.styleable.PercentLayout_Layout_layout_minHeightPercent, false);
    LogUtil.d(TAG, "minHeight = " + percentVal);
    if (percentVal != null) {
        checkForInfoExists(info);
        info.minHeightPercent = percentVal;
    }

    array.recycle();
    if (Log.isLoggable(TAG, Log.DEBUG)) {
        LogUtil.d(TAG, "constructed: " + info);
    }
    return info;
}

From source file:com.gosuncn.core.percentlayout.PercentLayoutHelper.java

/**
 * Constructs a PercentLayoutInfo from attributes associated with a View.
 * Call this method from {@code LayoutParams(Context c, AttributeSet attrs)}
 * constructor.//w  ww . j ava 2 s.com
 */
public static PercentLayoutInfo getPercentLayoutInfo(Context context, AttributeSet attrs) {
    PercentLayoutInfo info = null;
    TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.PercentLayout_Layout);

    // float value =
    // array.getFraction(R.styleable.PercentLayout_Layout_layout_widthPercent,
    // 1, 1,
    // -1f);
    String sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_widthPercent);
    PercentLayoutInfo.PercentVal percentVal = getPercentVal(sizeStr, true);
    if (percentVal != null) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent width: " + percentVal.percent);
        }
        info = info != null ? info : new PercentLayoutInfo();
        info.widthPercent = percentVal;
    }
    // value =
    // array.getFraction(R.styleable.PercentLayout_Layout_layout_heightPercent,
    // 1, 1, -1f);
    sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_heightPercent);
    percentVal = getPercentVal(sizeStr, false);

    if (sizeStr != null) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent height: " + percentVal.percent);
        }
        info = info != null ? info : new PercentLayoutInfo();
        info.heightPercent = percentVal;
    }

    // value =
    // array.getFraction(R.styleable.PercentLayout_Layout_layout_marginPercent,
    // 1, 1, -1f);
    sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginPercent);
    // just for judge
    percentVal = getPercentVal(sizeStr, false);

    if (percentVal != null) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent margin: " + percentVal.percent);
        }
        info = info != null ? info : new PercentLayoutInfo();
        info.leftMarginPercent = getPercentVal(sizeStr, true);
        info.topMarginPercent = getPercentVal(sizeStr, false);
        info.rightMarginPercent = getPercentVal(sizeStr, true);
        info.bottomMarginPercent = getPercentVal(sizeStr, false);
    }
    // value =
    // array.getFraction(R.styleable.PercentLayout_Layout_layout_marginLeftPercent,
    // 1, 1,
    // -1f);
    sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginLeftPercent);
    percentVal = getPercentVal(sizeStr, true);
    if (percentVal != null) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent left margin: " + percentVal.percent);
        }
        info = info != null ? info : new PercentLayoutInfo();
        info.leftMarginPercent = percentVal;
    }

    // value =
    // array.getFraction(R.styleable.PercentLayout_Layout_layout_marginTopPercent,
    // 1, 1,
    // -1f);
    sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginTopPercent);
    percentVal = getPercentVal(sizeStr, false);
    if (percentVal != null) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent top margin: " + percentVal.percent);
        }
        info = info != null ? info : new PercentLayoutInfo();
        info.topMarginPercent = percentVal;
    }
    // value =
    // array.getFraction(R.styleable.PercentLayout_Layout_layout_marginRightPercent,
    // 1, 1,
    // -1f);
    sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginRightPercent);
    percentVal = getPercentVal(sizeStr, true);
    if (percentVal != null) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent right margin: " + percentVal.percent);
        }
        info = info != null ? info : new PercentLayoutInfo();
        info.rightMarginPercent = percentVal;
    }
    // value =
    // array.getFraction(R.styleable.PercentLayout_Layout_layout_marginBottomPercent,
    // 1, 1,
    // -1f);
    sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginBottomPercent);
    percentVal = getPercentVal(sizeStr, false);
    if (percentVal != null) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent bottom margin: " + percentVal.percent);
        }
        info = info != null ? info : new PercentLayoutInfo();
        info.bottomMarginPercent = percentVal;
    }
    // value =
    // array.getFraction(R.styleable.PercentLayout_Layout_layout_marginStartPercent,
    // 1, 1,
    // -1f);
    sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginStartPercent);
    percentVal = getPercentVal(sizeStr, true);
    if (percentVal != null) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent start margin: " + percentVal.percent);
        }
        info = info != null ? info : new PercentLayoutInfo();
        info.startMarginPercent = percentVal;
    }
    // value =
    // array.getFraction(R.styleable.PercentLayout_Layout_layout_marginEndPercent,
    // 1, 1,
    // -1f);
    sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginEndPercent);
    percentVal = getPercentVal(sizeStr, true);
    if (percentVal != null) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent end margin: " + percentVal.percent);
        }
        info = info != null ? info : new PercentLayoutInfo();
        info.endMarginPercent = percentVal;
    }

    // textSizePercent
    sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_textSizePercent);
    percentVal = getPercentVal(sizeStr, false);
    if (percentVal != null) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent text size: " + percentVal.percent);
        }
        info = info != null ? info : new PercentLayoutInfo();
        info.textSizePercent = percentVal;
    }
    array.recycle();
    if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log.d(TAG, "constructed: " + info);
    }
    return info;
}

From source file:com.ty.highway.frameworklibrary.support.percent.PercentLayoutHelper.java

/**
 * Constructs a PercentLayoutInfo from attributes associated with a View.
 * Call this method from {@code LayoutParams(Context c, AttributeSet attrs)}
 * constructor.//from   w w w .  j a  va2 s .co  m
 */
public static PercentLayoutInfo getPercentLayoutInfo(Context context, AttributeSet attrs) {
    PercentLayoutInfo info = null;
    TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.PercentLayout_Layout);

    int index = R.styleable.PercentLayout_Layout_layout_widthPercent;
    String sizeStr = array.getString(index);
    PercentLayoutInfo.PercentVal percentVal = getPercentVal(sizeStr, true);
    if (percentVal != null) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent width: " + percentVal.percent);
        }
        info = checkForInfoExists(info);
        info.widthPercent = percentVal;
    }
    sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_heightPercent);
    percentVal = getPercentVal(sizeStr, false);

    if (sizeStr != null) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent height: " + percentVal.percent);
        }
        info = checkForInfoExists(info);
        info.heightPercent = percentVal;
    }

    // value =
    // array.getFraction(R.styleable.PercentLayout_Layout_layout_marginPercent,
    // 1, 1, -1f);
    sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginPercent);
    // just for judge
    percentVal = getPercentVal(sizeStr, false);

    if (percentVal != null) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent margin: " + percentVal.percent);
        }
        info = checkForInfoExists(info);
        info.leftMarginPercent = getPercentVal(sizeStr, true);
        info.topMarginPercent = getPercentVal(sizeStr, false);
        info.rightMarginPercent = getPercentVal(sizeStr, true);
        info.bottomMarginPercent = getPercentVal(sizeStr, false);
    }
    // value =
    // array.getFraction(R.styleable.PercentLayout_Layout_layout_marginLeftPercent,
    // 1, 1,
    // -1f);
    sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginLeftPercent);
    percentVal = getPercentVal(sizeStr, true);
    if (percentVal != null) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent left margin: " + percentVal.percent);
        }
        info = checkForInfoExists(info);
        info.leftMarginPercent = percentVal;
    }

    // value =
    // array.getFraction(R.styleable.PercentLayout_Layout_layout_marginTopPercent,
    // 1, 1,
    // -1f);
    sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginTopPercent);
    percentVal = getPercentVal(sizeStr, false);
    if (percentVal != null) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent top margin: " + percentVal.percent);
        }
        info = checkForInfoExists(info);
        info.topMarginPercent = percentVal;
    }
    // value =
    // array.getFraction(R.styleable.PercentLayout_Layout_layout_marginRightPercent,
    // 1, 1,
    // -1f);
    sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginRightPercent);
    percentVal = getPercentVal(sizeStr, true);
    if (percentVal != null) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent right margin: " + percentVal.percent);
        }
        info = checkForInfoExists(info);
        info.rightMarginPercent = percentVal;
    }
    // value =
    // array.getFraction(R.styleable.PercentLayout_Layout_layout_marginBottomPercent,
    // 1, 1,
    // -1f);
    sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginBottomPercent);
    percentVal = getPercentVal(sizeStr, false);
    if (percentVal != null) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent bottom margin: " + percentVal.percent);
        }
        info = checkForInfoExists(info);
        info.bottomMarginPercent = percentVal;
    }
    // value =
    // array.getFraction(R.styleable.PercentLayout_Layout_layout_marginStartPercent,
    // 1, 1,
    // -1f);
    sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginStartPercent);
    percentVal = getPercentVal(sizeStr, true);
    if (percentVal != null) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent start margin: " + percentVal.percent);
        }
        info = checkForInfoExists(info);
        info.startMarginPercent = percentVal;
    }
    // value =
    // array.getFraction(R.styleable.PercentLayout_Layout_layout_marginEndPercent,
    // 1, 1,
    // -1f);
    sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_marginEndPercent);
    percentVal = getPercentVal(sizeStr, true);
    if (percentVal != null) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent end margin: " + percentVal.percent);
        }
        info = checkForInfoExists(info);
        info.endMarginPercent = percentVal;
    }

    // textSizePercent
    sizeStr = array.getString(R.styleable.PercentLayout_Layout_layout_textSizePercent);
    percentVal = getPercentVal(sizeStr, false);
    if (percentVal != null) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent text size: " + percentVal.percent);
        }
        info = checkForInfoExists(info);
        info.textSizePercent = percentVal;
    }

    // maxWidth
    percentVal = getPercentVal(array, R.styleable.PercentLayout_Layout_layout_maxWidthPercent, true);
    if (percentVal != null) {
        checkForInfoExists(info);
        info.maxWidthPercent = percentVal;
    }
    // maxHeight
    percentVal = getPercentVal(array, R.styleable.PercentLayout_Layout_layout_maxHeightPercent, false);
    if (percentVal != null) {
        checkForInfoExists(info);
        info.maxHeightPercent = percentVal;
    }
    // minWidth
    percentVal = getPercentVal(array, R.styleable.PercentLayout_Layout_layout_minWidthPercent, true);
    if (percentVal != null) {
        checkForInfoExists(info);
        info.minWidthPercent = percentVal;
    }
    // minHeight
    percentVal = getPercentVal(array, R.styleable.PercentLayout_Layout_layout_minHeightPercent, false);
    Log.d(TAG, "minHeight = " + percentVal);
    if (percentVal != null) {
        checkForInfoExists(info);
        info.minHeightPercent = percentVal;
    }

    array.recycle();
    if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log.d(TAG, "constructed: " + info);
    }
    return info;
}

From source file:com.github.notizklotz.derbunddownloader.settings.TimePickerPreference.java

@Override
protected Object onGetDefaultValue(TypedArray a, int index) {
    return a.getString(index);
}

From source file:com.github.barteksc.pdfviewpager.RemotePDFViewPager.java

private void init(AttributeSet attrs) {
    if (attrs != null) {
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PDFViewPager);
        String pdfUrl = a.getString(R.styleable.PDFViewPager_pdfUrl);

        if (pdfUrl != null && pdfUrl.length() > 0) {
            init(pdfUrl);/*from  w  w w.j  a v a 2 s.c  om*/
        }
        a.recycle();
    }
}

From source file:net.ezbim.docassist.pdfandroid.view.PDFViewPager.java

protected void init(AttributeSet attrs) {
    if (isInEditMode()) {
        setBackgroundResource(R.drawable.flaticon_pdf_dummy);
        return;//from   ww  w .  ja v  a2 s. com
    }

    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.franctan.pdfviewpager.library.view.PDFViewPager.java

protected void init(AttributeSet attrs) {
    if (isInEditMode()) {
        setBackgroundResource(R.drawable.flaticon_pdf_dummy);
        return;/*  www  .  j a va  2 s .  co 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:es.voghdev.pdfviewpager.library.RemotePDFViewPager.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(pdfUrl);//ww  w .  j av  a 2  s. c o  m
        }
    }
}

From source file:com.crcrch.chromatictuner.GraphFragment.java

@Override
public void onInflate(Context context, AttributeSet attrs, Bundle savedInstanceState) {
    super.onInflate(context, attrs, savedInstanceState);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.GraphFragment);
    graphDescription = a.getString(R.styleable.GraphFragment_graphDescription);
    a.recycle();/*  ww w .j  a  va  2  s  .co  m*/
}