getString()源码实例Demo

android.content.res.TypedArray#getString()源码实例Demo

下面列出了android.content.res.TypedArray#getString() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: WidgetCase   文件: LegendRingView.java
public LegendRingView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    final TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.LegendRingView);
    int ordinal = ta.getInt(R.styleable.LegendRingView_lrv_circle_center_style, CircleCenterStyle.Txt.ordinal());
    mCircleStyle = CircleCenterStyle.values()[ordinal];
    mCircleHeight = ta.getDimensionPixelSize(R.styleable.LegendRingView_lrv_circle_height, DensityUtil.dp2px(120));
    mBorderW = ta.getDimensionPixelOffset(R.styleable.LegendRingView_lrv_circle_boderW,DensityUtil.dp2px(7));
    mCirclePaddingTop = ta.getDimensionPixelSize(R.styleable.LegendRingView_lrv_circle_paddingTop,0);
    mCirclePaddingBottom = ta.getDimensionPixelSize(R.styleable.LegendRingView_lrv_circle_paddingBottom,0);
    mCenterStr = ta.getString(R.styleable.LegendRingView_lrv_circle_center_txt);
    mCenterTxtSize = ta.getDimensionPixelSize(R.styleable.LegendRingView_lrv_circle_center_txt_size,DensityUtil.sp2px(context, 12));
    mCenterTxtColor = ta.getColor(R.styleable.LegendRingView_lrv_circle_center_txt_color,Color.rgb(42, 42, 42));
    mlabelColor = ta.getColor(R.styleable.LegendRingView_lrv_legend_font_color,Color.rgb(42, 42, 42));
    mLabelSize = ta.getDimensionPixelSize(R.styleable.LegendRingView_lrv_legend_font_size,DensityUtil.sp2px(context,12));
    mColumnWidth = ta.getDimensionPixelOffset(R.styleable.LegendRingView_lrv_legend_columnW,DensityUtil.dp2px(42));
    mLegendVerMargin = ta.getDimensionPixelOffset(R.styleable.LegendRingView_lrv_legend_vertical_margin,DensityUtil.sp2px(context,8));
    mLegendLabelAndPointMargin = ta.getDimensionPixelOffset(R.styleable.LegendRingView_lrv_legend_labelAndPoint_margin,DensityUtil.dp2px(4));
    mLegendOffsetLeft = ta.getDimensionPixelOffset(R.styleable.LegendRingView_lrv_offset_left,0);
    ta.recycle();
    init(context);
}
 
源代码2 项目: CreditCardView   文件: CreditCardFragment.java
private void parseAttrs(Context context, AttributeSet attrs) {
    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.CreditCardFragment);

    if (typedArray != null) {
        this.labelCardOwner = typedArray.getString(R.styleable.CreditCardFragment_labelCardOwner);
        this.labelCardDateExp = typedArray.getString(R.styleable.CreditCardFragment_labelCardDateExp);
        this.labelNumber = typedArray.getString(R.styleable.CreditCardFragment_labelNumber);

        this.labelExpireDate = typedArray.getString(R.styleable.CreditCardFragment_labelExpireDate);
        this.labelCVV = typedArray.getString(R.styleable.CreditCardFragment_labelCVV);
        this.labelOwnerName = typedArray.getString(R.styleable.CreditCardFragment_labelOwnerName);
        this.labelButtonPay = typedArray.getString(R.styleable.CreditCardFragment_labelButtonPay);
        this.labelTotal = typedArray.getString(R.styleable.CreditCardFragment_labelTotal);
        this.payBackground = typedArray.getDrawable(R.styleable.CreditCardFragment_buttonPayBackground);
        this.btPayTextColor = typedArray.getColorStateList(R.styleable.CreditCardFragment_buttonPayTextColor);

        this.attrInstallments = typedArray.getBoolean(R.styleable.CreditCardFragment_installments, true);
        this.attrSaveCard = typedArray.getBoolean(R.styleable.CreditCardFragment_saveCard, true);
    }
}
 
源代码3 项目: rings   文件: Rings.java
private void initByAttributes(TypedArray attributes) {
    textSize = attributes.getDimension(R.styleable.Rings_rings_text_size, defaultTextSize);
    textMarginLeft = attributes.getDimension(R.styleable.Rings_rings_text_margin_left, defaultTextMarginLeft);
    innerStrokeWidth = attributes.getDimension(R.styleable.Rings_rings_inner_stroke_width, defaultInnerStrokeWidth);
    innerStrokeWidthUnfinished = attributes.getDimension(R.styleable.Rings_rings_inner_stroke_width_unfinished, defaultInnerStrokeUnfinishedWidth);
    outerStrokeWidth = attributes.getDimension(R.styleable.Rings_rings_outer_stroke_width, defaultOuterStrokeWidth);
    outerStrokeWidthUnfinished = attributes.getDimension(R.styleable.Rings_rings_outer_stroke_width_unfinished, defaultOuterStrokeUnfinishedWidth);

    ringUnfinishedColor = attributes.getColor(R.styleable.Rings_rings_unfinished_color, defaultRingUnfinishedColor);
    defaultRingFilledColor = attributes.getColor(R.styleable.Rings_rings_default_filled_color, defaultRingFilledColor);

    ringOverallColor = attributes.getColor(R.styleable.Rings_rings_overall_color, defaultRingFilledColor);
    ringInnerThirdColor = attributes.getColor(R.styleable.Rings_rings_inner_third_color, defaultRingFilledColor);
    ringInnerSecondColor = attributes.getColor(R.styleable.Rings_rings_inner_second_color, defaultRingFilledColor);
    ringInnerFirstColor = attributes.getColor(R.styleable.Rings_rings_inner_first_color, defaultRingFilledColor);

    overAllText = attributes.getString(R.styleable.Rings_rings_overall_text);
    innerFirstText = attributes.getString(R.styleable.Rings_rings_inner_first_text);
    innerSecondText = attributes.getString(R.styleable.Rings_rings_inner_second_text);
    innerThirdText = attributes.getString(R.styleable.Rings_rings_inner_third_text);

    setRingOverallProgress(attributes.getFloat(R.styleable.Rings_rings_overall_progress, defaultRingOverallProgress), false);
    setRingInnerThirdProgress(attributes.getFloat(R.styleable.Rings_rings_inner_third_progress, defaultRingInnerThirdProgress), false);
    setRingInnerSecondProgress(attributes.getFloat(R.styleable.Rings_rings_inner_second_progress, defaultRingInnerSecondProgress), false);
    setRingInnerFirstProgress(attributes.getFloat(R.styleable.Rings_rings_inner_first_progress, defaultRingInnerFirstProgress), false);
}
 
源代码4 项目: WeGit   文件: UserLabel.java
public UserLabel(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    //Init attr
    TypedArray a = context.obtainStyledAttributes(attrs,
            R.styleable.user_verical_label);
    label_name = a.getString(R.styleable.user_verical_label_name);
    label_value = a.getString(R.styleable.user_verical_label_value);
    a.recycle();

    nameRect = new Rect();
    namePaint = new Paint();
    namePaint.setTextSize(UIUtils.sp2px(this.getContext(), 15));
    namePaint.setColor(getResources().getColor(R.color.theme_color));

    valueRect = new Rect();
    valuePaint = new Paint();
    valuePaint.setTextSize(UIUtils.sp2px(this.getContext(), 25));
    valuePaint.setColor(getResources().getColor(R.color.color_accent));

}
 
源代码5 项目: android_9.0.0_r45   文件: SyncAdaptersCache.java
public SyncAdapterType parseServiceAttributes(Resources res,
        String packageName, AttributeSet attrs) {
    TypedArray sa = res.obtainAttributes(attrs,
            com.android.internal.R.styleable.SyncAdapter);
    try {
        final String authority =
                sa.getString(com.android.internal.R.styleable.SyncAdapter_contentAuthority);
        final String accountType =
                sa.getString(com.android.internal.R.styleable.SyncAdapter_accountType);
        if (TextUtils.isEmpty(authority) || TextUtils.isEmpty(accountType)) {
            return null;
        }
        final boolean userVisible =
                sa.getBoolean(com.android.internal.R.styleable.SyncAdapter_userVisible, true);
        final boolean supportsUploading =
                sa.getBoolean(com.android.internal.R.styleable.SyncAdapter_supportsUploading,
                        true);
        final boolean isAlwaysSyncable =
                sa.getBoolean(com.android.internal.R.styleable.SyncAdapter_isAlwaysSyncable,
                        false);
        final boolean allowParallelSyncs =
                sa.getBoolean(com.android.internal.R.styleable.SyncAdapter_allowParallelSyncs,
                        false);
        final String settingsActivity =
                sa.getString(com.android.internal.R.styleable
                        .SyncAdapter_settingsActivity);
        return new SyncAdapterType(authority, accountType, userVisible, supportsUploading,
                isAlwaysSyncable, allowParallelSyncs, settingsActivity, packageName);
    } finally {
        sa.recycle();
    }
}
 
源代码6 项目: VIA-AI   文件: SeekbarPreference.java
private void init(Context context, AttributeSet attrs) throws IllegalAccessException {
    mContext = context;
    b_ShowImg = null;
    mMin = 0.0f;
    mMax = 100.0f;
    mStep = 1.0f;
    mBarValue = 0;
    mUnit = "";

    // parse attrs
    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SeekbarPreference, 0, 0);
    try {
        mMin = ta.getFloat(R.styleable.SeekbarPreference_min, 0.0f);
        mMax = ta.getFloat(R.styleable.SeekbarPreference_max, 100.0f);
        mStep = ta.getFloat(R.styleable.SeekbarPreference_step, 1.0f);
        mUnit = ta.getString(R.styleable.SeekbarPreference_unit);
    } finally {
        ta.recycle();
    }

    if((mMax < mMin)) {
        throw new IllegalAccessException("Error seekbar value :min " + mMin + ",max:" + mMax + " ,step:" + mStep);
    }

    mBarToDecimal = new DecimalFormat("#.##");

}
 
源代码7 项目: ticker   文件: TickerView.java
void applyTypedArray(TypedArray arr) {
    gravity = arr.getInt(R.styleable.TickerView_android_gravity, gravity);
    shadowColor = arr.getColor(R.styleable.TickerView_android_shadowColor,
            shadowColor);
    shadowDx = arr.getFloat(R.styleable.TickerView_android_shadowDx, shadowDx);
    shadowDy = arr.getFloat(R.styleable.TickerView_android_shadowDy, shadowDy);
    shadowRadius = arr.getFloat(R.styleable.TickerView_android_shadowRadius,
            shadowRadius);
    text = arr.getString(R.styleable.TickerView_android_text);
    textColor = arr.getColor(R.styleable.TickerView_android_textColor, textColor);
    textSize = arr.getDimension(R.styleable.TickerView_android_textSize, textSize);
    textStyle = arr.getInt(R.styleable.TickerView_android_textStyle, textStyle);
}
 
源代码8 项目: AnimCubeAndroid   文件: AnimCubeDebug.java
private void initCubeInitialState(TypedArray attributes) {
    String cubeColorsString = attributes.getString(R.styleable.AnimCube_initialState);
    if (cubeColorsString == null || cubeColorsString.length() != 54) {
        setCubeInDefaultState();
    } else {
        setStringCubeModelInternal(cubeColorsString);
    }
}
 
源代码9 项目: fdroidclient   文件: SwapView.java
@TargetApi(21)
public SwapView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);
    final TypedArray a = context.obtainStyledAttributes(
            attrs, R.styleable.SwapView, 0, 0);
    toolbarColor = a.getColor(R.styleable.SwapView_toolbarColor,
            getResources().getColor(R.color.swap_blue));
    toolbarTitle = a.getString(R.styleable.SwapView_toolbarTitle);
    a.recycle();
}
 
源代码10 项目: GSYRickText   文件: RichEditText.java
private void init(Context context, AttributeSet attrs) {

        if (isInEditMode())
            return;

        if (attrs != null) {
            TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.RichEditText);
            int textLength = array.getInteger(R.styleable.RichEditText_richMaxLength, 9999);
            float iconSize = (int) array.getDimension(R.styleable.RichEditText_richIconSize, 0);
            String colorAtUser = array.getString(R.styleable.RichEditText_richEditColorAtUser);
            String colorTopic = array.getString(R.styleable.RichEditText_richEditColorTopic);
            richMaxLength = textLength;
            InputFilter[] filters = {new InputFilter.LengthFilter(richMaxLength)};
            setFilters(filters);
            if (iconSize == 0) {
                richIconSize = dip2px(context, 20);
            }
            if (!TextUtils.isEmpty(colorAtUser)) {
                this.colorAtUser = colorAtUser;
            }
            if (!TextUtils.isEmpty(colorTopic)) {
                this.colorTopic = colorTopic;
            }
            array.recycle();
        }

        resolveAtPersonEditText();
    }
 
源代码11 项目: Transitions-Everywhere   文件: PatternPathMotion.java
public PatternPathMotion(@NonNull Context context, @NonNull AttributeSet attrs) {
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PatternPathMotion);
    try {
        String pathData = a.getString(R.styleable.PatternPathMotion_patternPathData);
        if (pathData == null) {
            throw new RuntimeException("pathData must be supplied for patternPathMotion");
        }
        Path pattern = PathParser.createPathFromPathData(pathData);
        setPatternPath(pattern);
    } finally {
        a.recycle();
    }

}
 
源代码12 项目: PopMenuLayout   文件: PopMenuLayout.java
private void initAttrs(Context context, AttributeSet attrs, int defStyleAttr){
    TypedArray attributes = context.obtainStyledAttributes(attrs, R.styleable.PopMenuLayout,
            defStyleAttr, 0);
    mConfigJson = attributes.getString(R.styleable.PopMenuLayout_config_json);
    mLevel2MenuAnimStyle = attributes.getResourceId(
            R.styleable.PopMenuLayout_level2_menu_anim_style, mLevel2MenuAnimStyle);
    mLevel1MenuItemHeight = attributes.getDimension(
            R.styleable.PopMenuLayout_level1_menu_item_height,
            Util.dp2px(context, mLevel1MenuItemHeight));
    mChildMenuItemHeight = attributes.getDimension(
            R.styleable.PopMenuLayout_child_menu_item_height,
            Util.dp2px(context, mChildMenuItemHeight));
    isWithLevel1MenuWidth = attributes.getBoolean(
            R.styleable.PopMenuLayout_cmenu_w_follow_level1_menu, isWithLevel1MenuWidth);
    mMenuDividerDp = attributes.getDimension(
            R.styleable.PopMenuLayout_menu_divider_width, Util.dp2px(context, mMenuDividerDp));
    mMenuTextPaddingLeft = attributes.getDimension(
            R.styleable.PopMenuLayout_menu_left_padding,
            Util.dp2px(context, mMenuTextPaddingLeft));
    mMenuTextPaddingRight = attributes.getDimension(
                    R.styleable.PopMenuLayout_menu_right_padding,
            Util.dp2px(context, mMenuTextPaddingRight));
    mMenuTextPaddingTop = attributes.getDimension(
            R.styleable.PopMenuLayout_menu_top_padding,
            Util.dp2px(context, mMenuTextPaddingTop));
    mMenuTextPaddingBottom = attributes.getDimension(
                    R.styleable.PopMenuLayout_menu_bottom_padding,
            Util.dp2px(context, mMenuTextPaddingBottom));
    mDividerColor = attributes.getColor(R.styleable.PopMenuLayout_menu_divider_color,
            mDividerColor);
    mExpandableIcon = attributes.getResourceId(R.styleable.PopMenuLayout_menu_expandable_icon,
            mExpandableIcon);
    mMenuTextColor = attributes.getColor(R.styleable.PopMenuLayout_menu_text_color,
            mMenuTextColor);
    mHorizontalMenuBackgroundRes = attributes.getResourceId(
            R.styleable.PopMenuLayout_horizontal_menu_bg, mHorizontalMenuBackgroundRes);
    mVerticalMenuBackgroundRes = attributes.getResourceId(
            R.styleable.PopMenuLayout_vertical_menu_bg, mVerticalMenuBackgroundRes);
    mMenuTextSize = attributes.getDimension(R.styleable.PopMenuLayout_menu_text_size,
            Util.sp2px(context, mMenuTextSize));
    mMaxMenuItemCount = attributes.getInteger(R.styleable.PopMenuLayout_child_menu_max_count,
            mMaxMenuItemCount);
    mLevel1MenuLayoutBgColor = attributes.getColor(
            R.styleable.PopMenuLayout_level1_menu_layout_bg_color, mLevel1MenuLayoutBgColor);
    mChildMenuLayoutBgColor = attributes.getColor(
            R.styleable.PopMenuLayout_cmenu_layout_bg_color, mChildMenuLayoutBgColor);
    mDividerMarginLeft = attributes.getDimension(R.styleable.PopMenuLayout_divider_margin_left,
            Util.dp2px(context, mDividerMarginLeft));
    mDividerMarginRight = attributes.getDimension(
            R.styleable.PopMenuLayout_divider_margin_right,
            Util.dp2px(context, mDividerMarginRight));
    mDividerMarginTop = attributes.getDimension(R.styleable.PopMenuLayout_divider_margin_top,
            Util.dp2px(context, mDividerMarginTop));
    mDividerMarginBottom = attributes.getDimension(
            R.styleable.PopMenuLayout_divider_margin_bottom,
            Util.dp2px(context, mDividerMarginBottom));
    attributes.recycle();
}
 
源代码13 项目: Genius-Android   文件: EditText.java
private void init(AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    if (attrs == null)
        return;

    // Get the super padding top
    mTruePaddingTop = super.getPaddingTop();

    final Context context = getContext();
    final Resources resources = getResources();

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

    String fontFile = a.getString(R.styleable.EditText_gFont);
    int lineSize = a.getDimensionPixelSize(R.styleable.EditText_gLineSize, resources.getDimensionPixelSize(R.dimen.g_editText_lineSize));
    ColorStateList lineColor = a.getColorStateList(R.styleable.EditText_gLineColor);

    // Set HintProperty
    int titleModel = a.getInt(R.styleable.EditText_gHintTitle, 1);
    int titleTextSize = a.getDimensionPixelSize(R.styleable.EditText_gHintTitleTextSize, resources.getDimensionPixelSize(R.dimen.g_editText_hintTitleTextSize));
    int titlePaddingTop = a.getDimensionPixelSize(R.styleable.EditText_gHintTitlePaddingTop, 0);
    int titlePaddingBottom = a.getDimensionPixelSize(R.styleable.EditText_gHintTitlePaddingBottom, 0);
    int titlePaddingLeft = a.getDimensionPixelSize(R.styleable.EditText_gHintTitlePaddingLeft, 0);
    int titlePaddingRight = a.getDimensionPixelSize(R.styleable.EditText_gHintTitlePaddingRight, 0);

    a.recycle();

    // Init color
    if (lineColor == null) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            lineColor = resources.getColorStateList(R.color.g_default_edit_view_line, null);
        } else {
            //noinspection deprecation
            lineColor = resources.getColorStateList(R.color.g_default_edit_view_line);
        }
    }

    if (!Ui.isHaveAttribute(attrs, "textColorHint") || getHintTextColors() == null) {
        ColorStateList hintColor;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            hintColor = resources.getColorStateList(R.color.g_default_edit_view_hint, null);
        } else {
            //noinspection deprecation
            hintColor = resources.getColorStateList(R.color.g_default_edit_view_hint);
        }
        setHintTextColor(hintColor);
    }

    // Set same values
    setLineSize(lineSize);
    setLineColor(lineColor);

    setHintTitleTextSize(titleTextSize);
    setHintTitleModel(titleModel);

    // check for IDE preview render
    if (!this.isInEditMode()) {
        // Set Font
        if (fontFile != null && fontFile.length() > 0) {
            Typeface typeface = Ui.getFont(context, fontFile);
            if (typeface != null) setTypeface(typeface);
        }
    }

    // Init background and title
    if (!Ui.isHaveAttribute(attrs, "background")) {
        initBackground();
    }

    initHintTitleText();

    // SetHintPadding
    setHintTitlePadding(titlePaddingLeft, titlePaddingTop, titlePaddingRight, titlePaddingBottom);
}
 
源代码14 项目: UsefulViews   文件: LabelledSpinner.java
/**
 * Sets up views and widget attributes
 *
 * @param context Context passed from constructor
 * @param attrs AttributeSet passed from constructor
 */
private void initializeLayout(Context context, AttributeSet attrs) {
    prepareLayout(context);

    mLabel = (TextView) getChildAt(0);
    mSpinner = (Spinner) getChildAt(1);
    mDivider = getChildAt(2);
    mErrorLabel = (TextView) getChildAt(3);

    final TypedArray a = context.obtainStyledAttributes(
            attrs, R.styleable.LabelledSpinner, 0, 0);

    String labelText = a.getString(R.styleable.LabelledSpinner_labelText);
    mWidgetColor = a.getColor(R.styleable.LabelledSpinner_widgetColor,
            ContextCompat.getColor(context, R.color.widget_labelled_spinner_default));

    mLabel.setText(labelText);
    mLabel.setPadding(0, dpToPixels(16), 0, 0);
    mSpinner.setPadding(0, dpToPixels(8), 0, dpToPixels(8));
    mSpinner.setOnItemSelectedListener(this);

    MarginLayoutParams dividerParams = (MarginLayoutParams) mDivider.getLayoutParams();
    dividerParams.rightMargin = dpToPixels(4);
    dividerParams.bottomMargin = dpToPixels(8);
    mDivider.setLayoutParams(dividerParams);

    mLabel.setTextColor(mWidgetColor);
    mDivider.setBackgroundColor(mWidgetColor);

    alignLabelWithSpinnerItem(4);

    final CharSequence[] entries = a.getTextArray(R.styleable.LabelledSpinner_spinnerEntries);
    if (entries != null) {
        setItemsArray(entries);
    }

    mDefaultErrorEnabled =
            a.getBoolean(R.styleable.LabelledSpinner_defaultErrorEnabled, false);
    mDefaultErrorText = getResources().getString(R.string.widget_labelled_spinner_errorText);

    a.recycle();
}
 
源代码15 项目: SmartRefreshHorizontal   文件: SmartViewPager.java
LayoutParams(Context context, AttributeSet attrs) {
    super(context, attrs);
    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SmartViewPager_Layout);
    title = ta.getString(R.styleable.SmartViewPager_Layout_layout_svpTitle);
    ta.recycle();
}
 
源代码16 项目: lottie-android   文件: LottieAnimationView.java
private void init(@Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
  TypedArray ta = getContext().obtainStyledAttributes(attrs, R.styleable.LottieAnimationView, defStyleAttr, 0);
  if (!isInEditMode()) {
    cacheComposition = ta.getBoolean(R.styleable.LottieAnimationView_lottie_cacheComposition, true);
    boolean hasRawRes = ta.hasValue(R.styleable.LottieAnimationView_lottie_rawRes);
    boolean hasFileName = ta.hasValue(R.styleable.LottieAnimationView_lottie_fileName);
    boolean hasUrl = ta.hasValue(R.styleable.LottieAnimationView_lottie_url);
    if (hasRawRes && hasFileName) {
      throw new IllegalArgumentException("lottie_rawRes and lottie_fileName cannot be used at " +
          "the same time. Please use only one at once.");
    } else if (hasRawRes) {
      int rawResId = ta.getResourceId(R.styleable.LottieAnimationView_lottie_rawRes, 0);
      if (rawResId != 0) {
        setAnimation(rawResId);
      }
    } else if (hasFileName) {
      String fileName = ta.getString(R.styleable.LottieAnimationView_lottie_fileName);
      if (fileName != null) {
        setAnimation(fileName);
      }
    } else if (hasUrl) {
      String url = ta.getString(R.styleable.LottieAnimationView_lottie_url);
      if (url != null) {
        setAnimationFromUrl(url);
      }
    }

    setFallbackResource(ta.getResourceId(R.styleable.LottieAnimationView_lottie_fallbackRes, 0));
  }
  if (ta.getBoolean(R.styleable.LottieAnimationView_lottie_autoPlay, false)) {
    wasAnimatingWhenDetached = true;
    autoPlay = true;
  }

  if (ta.getBoolean(R.styleable.LottieAnimationView_lottie_loop, false)) {
    lottieDrawable.setRepeatCount(LottieDrawable.INFINITE);
  }

  if (ta.hasValue(R.styleable.LottieAnimationView_lottie_repeatMode)) {
    setRepeatMode(ta.getInt(R.styleable.LottieAnimationView_lottie_repeatMode,
        LottieDrawable.RESTART));
  }

  if (ta.hasValue(R.styleable.LottieAnimationView_lottie_repeatCount)) {
    setRepeatCount(ta.getInt(R.styleable.LottieAnimationView_lottie_repeatCount,
        LottieDrawable.INFINITE));
  }

  if (ta.hasValue(R.styleable.LottieAnimationView_lottie_speed)) {
    setSpeed(ta.getFloat(R.styleable.LottieAnimationView_lottie_speed, 1f));
  }

  setImageAssetsFolder(ta.getString(R.styleable.LottieAnimationView_lottie_imageAssetsFolder));
  setProgress(ta.getFloat(R.styleable.LottieAnimationView_lottie_progress, 0));
  enableMergePathsForKitKatAndAbove(ta.getBoolean(
      R.styleable.LottieAnimationView_lottie_enableMergePathsForKitKatAndAbove, false));
  if (ta.hasValue(R.styleable.LottieAnimationView_lottie_colorFilter)) {
    SimpleColorFilter filter = new SimpleColorFilter(
        ta.getColor(R.styleable.LottieAnimationView_lottie_colorFilter, Color.TRANSPARENT));
    KeyPath keyPath = new KeyPath("**");
    LottieValueCallback<ColorFilter> callback = new LottieValueCallback<ColorFilter>(filter);
    addValueCallback(keyPath, LottieProperty.COLOR_FILTER, callback);
  }
  if (ta.hasValue(R.styleable.LottieAnimationView_lottie_scale)) {
    lottieDrawable.setScale(ta.getFloat(R.styleable.LottieAnimationView_lottie_scale, 1f));
  }

  if (ta.hasValue(R.styleable.LottieAnimationView_lottie_renderMode)) {
    int renderModeOrdinal = ta.getInt(R.styleable.LottieAnimationView_lottie_renderMode, RenderMode.AUTOMATIC.ordinal());
    if (renderModeOrdinal >= RenderMode.values().length) {
      renderModeOrdinal = RenderMode.AUTOMATIC.ordinal();
    }
    setRenderMode(RenderMode.values()[renderModeOrdinal]);
  }

  if (getScaleType() != null) {
    lottieDrawable.setScaleType(getScaleType());
  }
  ta.recycle();

  lottieDrawable.setSystemAnimationsAreEnabled(Utils.getAnimationScale(getContext()) != 0f);

  enableOrDisableHardwareLayer();
  isInitialized = true;
}
 
源代码17 项目: audio-analyzer-for-android   文件: SelectorText.java
private static String getValue(TypedArray a, int index, String dflt) {
  String result = a.getString(index);
  return result == null ? dflt : result;
}
 
源代码18 项目: android_9.0.0_r45   文件: SpellCheckerInfo.java
/**
 * Constructor.
 * @hide
 */
public SpellCheckerInfo(Context context, ResolveInfo service)
        throws XmlPullParserException, IOException {
    mService = service;
    ServiceInfo si = service.serviceInfo;
    mId = new ComponentName(si.packageName, si.name).flattenToShortString();

    final PackageManager pm = context.getPackageManager();
    int label = 0;
    String settingsActivityComponent = null;

    XmlResourceParser parser = null;
    try {
        parser = si.loadXmlMetaData(pm, SpellCheckerSession.SERVICE_META_DATA);
        if (parser == null) {
            throw new XmlPullParserException("No "
                    + SpellCheckerSession.SERVICE_META_DATA + " meta-data");
        }

        final Resources res = pm.getResourcesForApplication(si.applicationInfo);
        final AttributeSet attrs = Xml.asAttributeSet(parser);
        int type;
        while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
                && type != XmlPullParser.START_TAG) {
        }

        final String nodeName = parser.getName();
        if (!"spell-checker".equals(nodeName)) {
            throw new XmlPullParserException(
                    "Meta-data does not start with spell-checker tag");
        }

        TypedArray sa = res.obtainAttributes(attrs,
                com.android.internal.R.styleable.SpellChecker);
        label = sa.getResourceId(com.android.internal.R.styleable.SpellChecker_label, 0);
        settingsActivityComponent = sa.getString(
                com.android.internal.R.styleable.SpellChecker_settingsActivity);
        sa.recycle();

        final int depth = parser.getDepth();
        // Parse all subtypes
        while (((type = parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth)
                && type != XmlPullParser.END_DOCUMENT) {
            if (type == XmlPullParser.START_TAG) {
                final String subtypeNodeName = parser.getName();
                if (!"subtype".equals(subtypeNodeName)) {
                    throw new XmlPullParserException(
                            "Meta-data in spell-checker does not start with subtype tag");
                }
                final TypedArray a = res.obtainAttributes(
                        attrs, com.android.internal.R.styleable.SpellChecker_Subtype);
                SpellCheckerSubtype subtype = new SpellCheckerSubtype(
                        a.getResourceId(com.android.internal.R.styleable
                                .SpellChecker_Subtype_label, 0),
                        a.getString(com.android.internal.R.styleable
                                .SpellChecker_Subtype_subtypeLocale),
                        a.getString(com.android.internal.R.styleable
                                .SpellChecker_Subtype_languageTag),
                        a.getString(com.android.internal.R.styleable
                                .SpellChecker_Subtype_subtypeExtraValue),
                        a.getInt(com.android.internal.R.styleable
                                .SpellChecker_Subtype_subtypeId, 0));
                mSubtypes.add(subtype);
            }
        }
    } catch (Exception e) {
        Slog.e(TAG, "Caught exception: " + e);
        throw new XmlPullParserException(
                "Unable to create context for: " + si.packageName);
    } finally {
        if (parser != null) parser.close();
    }
    mLabel = label;
    mSettingsActivityName = settingsActivityComponent;
}
 
源代码19 项目: NoboButton   文件: NoboButton.java
/**
 * Initialize Attributes arrays
 *
 * @param attrs : Attributes array
 */
private void initAttributes(TypedArray attrs) {

	radius = attrs.getDimension(R.styleable.NoboButton_nb_radius, radius);

	borderColor = attrs.getColor(R.styleable.NoboButton_nb_borderColor, borderColor);
	borderWidth = (int) attrs.getDimension(R.styleable.NoboButton_nb_borderWidth, borderWidth);


	backgroundColor = attrs.getColor(R.styleable.NoboButton_nb_backgroundColor, backgroundColor);
	disableColor = attrs.getColor(R.styleable.NoboButton_nb_disableColor, disableColor);

	focusColor = attrs.getColor(R.styleable.NoboButton_nb_focusColor, focusColor);

	text = attrs.getString(R.styleable.NoboButton_nb_text);
	textColor = attrs.getColor(R.styleable.NoboButton_nb_textColor, textColor);
	disabledTextColor = attrs.getColor(R.styleable.NoboButton_nb_disabledTextColor, disabledTextColor);
	textSize = attrs.getDimensionPixelSize(R.styleable.NoboButton_nb_textSize, textSize);

	textStyle = attrs.getInt(R.styleable.NoboButton_nb_textStyle, textStyle);

	/*Log.e("TAG", "Dimension "+attrs.getDimension(R.styleable.NoboButton_textSize, textSize));
	Log.e("TAG", "DimensionPixelSize "+attrs.getDimensionPixelSize(R.styleable.NoboButton_textSize, textSize));*/

	textAllCaps = attrs.getBoolean(R.styleable.NoboButton_nb_textAllCaps, textAllCaps);


	fontIcon = attrs.getString(R.styleable.NoboButton_nb_fontIcon);
	iconSize = attrs.getDimensionPixelSize(R.styleable.NoboButton_nb_iconSize, iconSize);
	iconColor = attrs.getColor(R.styleable.NoboButton_nb_iconColor, iconColor);
	iconPosition = attrs.getInt(R.styleable.NoboButton_nb_iconPosition, iconPosition);

	drawableResource = attrs.getResourceId(R.styleable.NoboButton_nb_drawableResource, drawableResource);
	iconPadding = attrs.getDimensionPixelSize(R.styleable.NoboButton_nb_iconPadding, iconPadding);

	lGravity = attrs.getInt(R.styleable.NoboButton_nb_gravity, lGravity);
	isEnabled = attrs.getBoolean(R.styleable.NoboButton_nb_enabled, isEnabled);

	/*padding = (int) attrs.getDimension(R.styleable.NoboButton_padding,padding);
	paddingLeft = (int) attrs.getDimension(R.styleable.NoboButton_paddingLeft,paddingLeft);
	paddingTop = (int) attrs.getDimension(R.styleable.NoboButton_paddingTop,paddingTop);
	paddingRight = (int) attrs.getDimension(R.styleable.NoboButton_paddingRight,paddingRight);
	paddingBottom = (int) attrs.getDimension(R.styleable.NoboButton_paddingBottom,paddingBottom);*/
}
 
CalendarViewLegacyDelegate(CalendarView delegator, Context context, AttributeSet attrs,
        int defStyleAttr, int defStyleRes) {
    super(delegator, context);

    final TypedArray a = context.obtainStyledAttributes(attrs,
            R.styleable.CalendarView, defStyleAttr, defStyleRes);
    mShowWeekNumber = a.getBoolean(R.styleable.CalendarView_showWeekNumber,
            DEFAULT_SHOW_WEEK_NUMBER);
    mFirstDayOfWeek = a.getInt(R.styleable.CalendarView_firstDayOfWeek,
            LocaleData.get(Locale.getDefault()).firstDayOfWeek);
    final String minDate = a.getString(R.styleable.CalendarView_minDate);
    if (!CalendarView.parseDate(minDate, mMinDate)) {
        CalendarView.parseDate(DEFAULT_MIN_DATE, mMinDate);
    }
    final String maxDate = a.getString(R.styleable.CalendarView_maxDate);
    if (!CalendarView.parseDate(maxDate, mMaxDate)) {
        CalendarView.parseDate(DEFAULT_MAX_DATE, mMaxDate);
    }
    if (mMaxDate.before(mMinDate)) {
        throw new IllegalArgumentException("Max date cannot be before min date.");
    }
    mShownWeekCount = a.getInt(R.styleable.CalendarView_shownWeekCount,
            DEFAULT_SHOWN_WEEK_COUNT);
    mSelectedWeekBackgroundColor = a.getColor(
            R.styleable.CalendarView_selectedWeekBackgroundColor, 0);
    mFocusedMonthDateColor = a.getColor(
            R.styleable.CalendarView_focusedMonthDateColor, 0);
    mUnfocusedMonthDateColor = a.getColor(
            R.styleable.CalendarView_unfocusedMonthDateColor, 0);
    mWeekSeparatorLineColor = a.getColor(
            R.styleable.CalendarView_weekSeparatorLineColor, 0);
    mWeekNumberColor = a.getColor(R.styleable.CalendarView_weekNumberColor, 0);
    mSelectedDateVerticalBar = a.getDrawable(
            R.styleable.CalendarView_selectedDateVerticalBar);

    mDateTextAppearanceResId = a.getResourceId(
            R.styleable.CalendarView_dateTextAppearance, R.style.TextAppearance_Small);
    updateDateTextSize();

    mWeekDayTextAppearanceResId = a.getResourceId(
            R.styleable.CalendarView_weekDayTextAppearance,
            DEFAULT_WEEK_DAY_TEXT_APPEARANCE_RES_ID);
    a.recycle();

    DisplayMetrics displayMetrics = mDelegator.getResources().getDisplayMetrics();
    mWeekMinVisibleHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
            UNSCALED_WEEK_MIN_VISIBLE_HEIGHT, displayMetrics);
    mListScrollTopOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
            UNSCALED_LIST_SCROLL_TOP_OFFSET, displayMetrics);
    mBottomBuffer = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
            UNSCALED_BOTTOM_BUFFER, displayMetrics);
    mSelectedDateVerticalBarWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
            UNSCALED_SELECTED_DATE_VERTICAL_BAR_WIDTH, displayMetrics);
    mWeekSeparatorLineWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
            UNSCALED_WEEK_SEPARATOR_LINE_WIDTH, displayMetrics);

    LayoutInflater layoutInflater = (LayoutInflater) mContext
            .getSystemService(Service.LAYOUT_INFLATER_SERVICE);
    View content = layoutInflater.inflate(R.layout.calendar_view, null, false);
    mDelegator.addView(content);

    mListView = mDelegator.findViewById(R.id.list);
    mDayNamesHeader = content.findViewById(R.id.day_names);
    mMonthName = content.findViewById(R.id.month_name);

    setUpHeader();
    setUpListView();
    setUpAdapter();

    // go to today or whichever is close to today min or max date
    mTempDate.setTimeInMillis(System.currentTimeMillis());
    if (mTempDate.before(mMinDate)) {
        goTo(mMinDate, false, true, true);
    } else if (mMaxDate.before(mTempDate)) {
        goTo(mMaxDate, false, true, true);
    } else {
        goTo(mTempDate, false, true, true);
    }

    mDelegator.invalidate();
}