android.support.annotation.AttrRes的实例源码

项目:searchablespinner    文件:SearchableSpinner.java   
public SearchableSpinner(@NonNull Context context,@Nullable AttributeSet attrs,@AttrRes int defStyleAttr,@StyleRes int defStyleRes) {
    super(context,attrs,defStyleAttr,defStyleRes);
    mContext = context;
    getAttributeSet(attrs,defStyleRes);

    final LayoutInflater factory = LayoutInflater.from(context);
    factory.inflate(R.layout.view_searchable_spinner,this,true);

    mSpinnerListContainer = (LinearLayout) factory.inflate(R.layout.view_list,false);
    mSpinnerListView = (ListView) mSpinnerListContainer.findViewById(R.id.LstVw_SpinnerListView);
    if (mListItemDivider != null) {
        mSpinnerListView.setDivider(mListItemDivider);
        mSpinnerListView.setDividerHeight(mListDividerSize);
    }
    mEmptyTextView = (TextView) mSpinnerListContainer.findViewById(R.id.TxtVw_EmptyText);
    mSpinnerListView.setEmptyView(mEmptyTextView);
}
项目:q-mail    文件:SecurityInfoDialog.java   
private void setCryptoMessageSingleLine(@AttrRes int colorAttr,@StringRes int topTextRes,@DrawableRes int statusIconRes,@DrawableRes Integer statusDotsRes) {
    @ColorInt int color = ThemeUtils.getStyledColor(getActivity(),colorAttr);

    authenticationIcon_1.setImageResource(statusIconRes);
    authenticationIcon_1.setColorFilter(color);
    authenticationText.setText(topTextRes);

    if (statusDotsRes != null) {
        authenticationIcon_3.setImageResource(statusDotsRes);
        authenticationIcon_3.setColorFilter(color);
        authenticationIcon_3.setVisibility(View.VISIBLE);
    } else {
        authenticationIcon_3.setVisibility(View.GONE);
    }

    trustText.setVisibility(View.GONE);
    trustIconFrame.setVisibility(View.GONE);
}
项目:searchablespinner    文件:SearchableSpinner.java   
private void getAttributeSet(@Nullable AttributeSet attrs,@StyleRes int defStyleRes) {
    if (attrs != null) {
        try {
            TypedArray attributes = mContext.getTheme().obtainStyledAttributes(attrs,R.styleable.SearchableSpinner,defStyleRes);
            mRevealViewBackgroundColor = attributes.getColor(R.styleable.SearchableSpinner_RevealViewBackgroundColor,Color.WHITE);
            mStartEditTintColor = attributes.getColor(R.styleable.SearchableSpinner_StartSearchTintColor,Color.GRAY);
            mEditViewBackgroundColor = attributes.getColor(R.styleable.SearchableSpinner_SearchViewBackgroundColor,Color.WHITE);
            mEditViewTextColor = attributes.getColor(R.styleable.SearchableSpinner_SearchViewTextColor,Color.BLACK);
            mDoneEditTintColor = attributes.getColor(R.styleable.SearchableSpinner_DoneSearchTintColor,Color.GRAY);
            mBordersSize = attributes.getDimensionPixelSize(R.styleable.SearchableSpinner_BordersSize,4);
            mExpandSize = attributes.getDimensionPixelSize(R.styleable.SearchableSpinner_SpinnerExpandHeight,0);
            mShowBorders = attributes.getBoolean(R.styleable.SearchableSpinner_ShowBorders,false);
            mBoarderColor = attributes.getColor(R.styleable.SearchableSpinner_BoarderColor,Color.GRAY);
            mAnimDuration = attributes.getColor(R.styleable.SearchableSpinner_AnimDuration,DefaultAnimationDuration);
            mKeepLastSearch = attributes.getBoolean(R.styleable.SearchableSpinner_KeepLastSearch,false);
            mRevealEmptyText = attributes.getString(R.styleable.SearchableSpinner_RevealEmptyText);
            mSearchHintText = attributes.getString(R.styleable.SearchableSpinner_SearchHintText);
            mNoItemsFoundText = attributes.getString(R.styleable.SearchableSpinner_NoItemsFoundText);
            mListItemDivider = attributes.getDrawable(R.styleable.SearchableSpinner_ItemsDivider);
            mListDividerSize = attributes.getDimensionPixelSize(R.styleable.SearchableSpinner_DividerHeight,0);
        } catch (UnsupportedOperationException e) {
            Log.e("SearchableSpinner","getAttributeSet --> " + e.getLocalizedMessage());
        }
    }
}
项目:IslamicLibraryAndroid    文件:Util.java   
public static ColorStateList resolveColorStateList(Context context,@AttrRes int attr) {
    TEMP_ARRAY[0] = attr;
    TintTypedArray ta = TintTypedArray.obtainStyledAttributes(context,null,TEMP_ARRAY);
    try {
        return ta.getColorStateList(0);
    } finally {
        ta.recycle();
    }
}
项目:IslamicLibraryAndroid    文件:Util.java   
public static int resolveResourceId(Context context,@AttrRes int attr,int fallback) {
    TEMP_ARRAY[0] = attr;
    TypedArray ta = context.obtainStyledAttributes(TEMP_ARRAY);
    try {
        return ta.getResourceId(0,fallback);
    } finally {
        ta.recycle();
    }
}
项目:StyleableToast    文件:Utils.java   
public static boolean getStyleValuesBoolean(Context context,@AttrRes int attrId,int style) {
    TypedArray a = null;

    if (style > 0) {
        int[] AttrSet = {attrId};
        a = context.obtainStyledAttributes(style,AttrSet);
        a.recycle();
    }
    return a.getBoolean(0,false);
}
项目:q-mail    文件:SecurityInfoDialog.java   
private void setTransportSecurityMessageSingleLine(@AttrRes int colorAttr,@DrawableRes int statusIconRes) {
    @ColorInt int color = ThemeUtils.getStyledColor(getActivity(),colorAttr);

    transportSecurityIcon_1.setImageResource(statusIconRes);
    transportSecurityIcon_1.setColorFilter(color);
    transportSecurityText.setText(topTextRes);
}
项目:ChromeLikeTabSwitcher    文件:ThemeHelper.java   
/**
 * Returns the drawable,which corresponds to a specific theme attribute,regarding the
 * theme,which is used when using a specific layout.
 *
 * @param layout
 *         The layout as a value of the enum {@link Layout}. The layout may not be null
 * @param resourceId
 *         The resource id of the theme attribute,the drawable should be obtained from,as an
 *         {@link Integer} value. The resource id must correspond to a valid theme attribute
 * @return The color state list,which has been obtained,as an instance of the class {@link
 * ColorStateList}
 */
public Drawable getDrawable(@NonNull final Layout layout,@AttrRes final int resourceId) {
    try {
        return ThemeUtil.getDrawable(context,resourceId);
    } catch (NotFoundException e1) {
        int themeResourceId = getThemeResourceId(layout);

        try {
            return ThemeUtil.getDrawable(context,themeResourceId,resourceId);
        } catch (NotFoundException e) {
            themeResourceId = obtainThemeFromThemeAttributes(layout,themeResourceId);
            return ThemeUtil.getDrawable(context,resourceId);
        }
    }
}
项目:q-mail    文件:SecurityInfoDialog.java   
private void setDKIMMessageSingleLine(@AttrRes int colorAttr,colorAttr);

    dkimIcon_1.setImageResource(statusIconRes);
    dkimIcon_1.setColorFilter(color);
    dkimText.setText(topTextRes);
}
项目:q-mail    文件:AlternateRecipientAdapter.java   
private void setCryptoStatusView(RecipientTokenHolder holder,@DrawableRes int cryptoStatusRes,@AttrRes int cryptoStatusColorAttr) {
    Resources resources = context.getResources();

    Drawable drawable = resources.getDrawable(cryptoStatusRes);
    // noinspection ConstantConditions,we know the resource exists!
    drawable.mutate();

    int cryptoStatusColor = ThemeUtils.getStyledColor(context,cryptoStatusColorAttr);
    drawable.setColorFilter(cryptoStatusColor,Mode.SRC_ATOP);

    holder.itemCryptoStatusIcon.setImageDrawable(drawable);
    holder.itemCryptoStatus.setVisibility(View.VISIBLE);
}
项目:Mire    文件:Preferences.java   
@ColorInt
   public static int getAttributeColor(Context context,int fallback) 
{
       TypedArray a = context.getTheme().obtainStyledAttributes(new int[] {attr});
       try 
    {
           return a.getColor(0,fallback);
       }
    finally 
    {
           a.recycle();
       }
   }
项目:MaterialStepperView    文件:ViewUtils.java   
/**
 * Get color attribute from current theme
 *
 * @param context Themed context
 * @param attr The resource id of color attribute
 * @return Result
 */
@ColorInt
static int getColorFromAttr(Context context,@AttrRes int attr) {
    TypedArray array = context.getTheme().obtainStyledAttributes(new int[]{attr});
    int color = array.getColor(0,Color.TRANSPARENT);
    array.recycle();
    return color;
}
项目:GitHub    文件:DialogUtils.java   
private static Drawable resolveDrawable(Context context,@SuppressWarnings(
                                                "SameParameterValue") Drawable fallback) {
    TypedArray a = context.getTheme().obtainStyledAttributes(new int[]{attr});
    try {
        Drawable d = a.getDrawable(0);
        if (d == null && fallback != null)
            d = fallback;
        return d;
    } finally {
        a.recycle();
    }
}
项目:CookieBar2    文件:ThemeResolver.java   
static int getColor(Context context,int defaultColor) {
    TypedArray a = context.getTheme().obtainStyledAttributes(new int[]{attr});
    try {
        return a.getColor(0,defaultColor);
    } finally {
        a.recycle();
    }
}
项目:SCCameraView    文件:SCCameraView.java   
public SCCameraView(@NonNull Context context,@AttrRes int defStyleAttr) {
    super(context,defStyleAttr);
    if (isInEditMode()){
        cameraView = null;
        return;
    }

    cameraView = BaseCameraView.createCameraView(context);
    cameraView.loadAspectRatios();
    this.addView(cameraView);
}
项目:Mix    文件:ThemeUtils.java   
public static boolean getThemeAttrBoolean(Context context,@AttrRes int attr) {
    TEMP_ARRAY[0] = attr;
    TypedArray a = context.obtainStyledAttributes(null,TEMP_ARRAY);
    try {
        return a.getBoolean(0,false);
    } finally {
        a.recycle();
    }
}
项目:MzViewPager    文件:MzViewPager.java   
public MzViewPager(@NonNull Context context,defStyleAttr);
    handleTypedArray(context,attrs);

    mVpMargin = dp2px(DEFAULT_VP_MARGIN);
    mVpPadding = dp2px(DEFAULT_VP_PADDING);

    mContext = context;
    initViewPager();
}
项目:BlackList    文件:Notifications.java   
private static int getColor(Context context,@AttrRes int attrRes) {
    int styleRes = R.style.AppTheme_Dark;
    if (Settings.getBooleanValue(context,Settings.UI_THEME_DARK)) {
        styleRes = R.style.AppTheme_Light;
    }
    int colorRes = Utils.getResourceId(context,attrRes,styleRes);
    return ContextCompat.getColor(context,colorRes);
}
项目:Aequorea    文件:ACheckBox.java   
public ACheckBox(@NonNull Context context,defStyleAttr);

    View.inflate(context,R.layout.layout_custom_checkbox,this);
    init(context,attrs);
    setOnClickListener(this);
}
项目:Pocket-Plays-for-Twitch    文件:Service.java   
/**
 * Finds and returns an attribute color. If it was not found the method returns the default color
 */
public static int getColorAttribute(@AttrRes int attribute,@ColorRes int defaultColor,Context context) {
    TypedValue a = new TypedValue();
    context.getTheme().resolveAttribute(attribute,a,true);
    if (a.type >= TypedValue.TYPE_FIRST_COLOR_INT && a.type <= TypedValue.TYPE_LAST_COLOR_INT) {
        return a.data;
    } else {
        return ContextCompat.getColor(context,defaultColor);
    }
}
项目:FancyAccordionView    文件:ThemeUtils.java   
/**
 * Convenience method for retrieving a themed drawable.
 *
 * @param context the {@link Context} to resolve the theme attribute against
 * @param attr    the attribute corresponding to the drawable to resolve
 * @return the drawable of the resolved attribute
 */
public static Drawable resolveDrawable(Context context,@AttrRes int attr) {
    final TypedArray a;
    synchronized (TEMP_ATTR) {
        TEMP_ATTR[0] = attr;
        a = context.obtainStyledAttributes(TEMP_ATTR);
    }

    try {
        return a.getDrawable(0);
    } finally {
        a.recycle();
    }
}
项目:microMathematics    文件:CompatUtils.java   
/**
 * Procedure sets the background for given view as a drawable with given resource id
 */
@SuppressWarnings("deprecation")
public static void updateBackgroundAttr(Context c,View v,@DrawableRes int drawableId,@AttrRes int colorAttrId)
{
    Drawable bg = null;

    if (drawableId >= 0)
    {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        {
            bg = c.getResources().getDrawable(drawableId,c.getTheme());
        }
        else
        {
            bg = c.getResources().getDrawable(drawableId);
        }
    }

    setDrawableColorAttr(c,bg,colorAttrId);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
    {
        v.setBackground(bg);
    }
    else
    {
        v.setBackgroundDrawable(bg);
    }
}
项目:Mix    文件:ThemeUtils.java   
public static int getThemeAttrId(Context context,TEMP_ARRAY);
    try {
        return a.getResourceId(0,0);
    } finally {
        a.recycle();
    }
}
项目:Tusky    文件:ComposeActivity.java   
private void updateHideMediaToggleColor() {
    @AttrRes int attribute;
    if (statusMarkSensitive) {
        attribute = R.attr.compose_hide_media_button_selected_color;
    } else {
        attribute = R.attr.compose_hide_media_button_color;
    }
    ThemeUtils.setDrawableTint(this,hideMediaToggle.getDrawable(),attribute);
}
项目:NetworkStateView    文件:NetworkStateView.java   
public NetworkStateView(@NonNull Context context,defStyleAttr);

    TypedArray typedArray = context.obtainStyledAttributes(attrs,R.styleable.NetworkStateView,R.style.NetworkStateView_Style);

    mLoadingViewId = typedArray.getResourceId(R.styleable.NetworkStateView_loadingView,R.layout.view_loading);

    mErrorViewId = typedArray.getResourceId(R.styleable.NetworkStateView_errorView,R.layout.view_network_error);
    mErrorImageId = typedArray.getResourceId(R.styleable.NetworkStateView_nsvErrorImage,NO_ID);
    mErrorText = typedArray.getString(R.styleable.NetworkStateView_nsvErrorText);

    mNoNetworkViewId = typedArray.getResourceId(R.styleable.NetworkStateView_noNetworkView,R.layout.view_no_network);
    mNoNetworkImageId = typedArray.getResourceId(R.styleable.NetworkStateView_nsvNoNetworkImage,NO_ID);
    mNoNetworkText = typedArray.getString(R.styleable.NetworkStateView_nsvNoNetworkText);

    mEmptyViewId = typedArray.getResourceId(R.styleable.NetworkStateView_emptyView,R.layout.view_empty);
    mEmptyImageId = typedArray.getResourceId(R.styleable.NetworkStateView_nsvEmptyImage,NO_ID);
    mEmptyText = typedArray.getString(R.styleable.NetworkStateView_nsvEmptyText);

    mRefreshViewId = typedArray.getResourceId(R.styleable.NetworkStateView_nsvRefreshImage,NO_ID);

    mTextColor = typedArray.getColor(R.styleable.NetworkStateView_nsvTextColor,0x8a000000);
    mTextSize = typedArray.getDimensionPixelSize(R.styleable.NetworkStateView_nsvTextSize,UIUtils.dp2px(14));

    typedArray.recycle();

    mInflater = LayoutInflater.from(context);
    params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT);
    setBackgroundColor(UIUtils.getColor(R.color.white));
}
项目:AndelaTrackChallenge    文件:ThemeUtils.java   
public static int getThemeAttrColor(@NonNull Context context,@AttrRes int attributeColor) {
    int[] attrs = new int[]{attributeColor};
    TypedArray ta = context.obtainStyledAttributes(attrs);
    int color = ta.getColor(0,Color.TRANSPARENT);
    ta.recycle();
    return color;
}
项目:android_ui    文件:PullController.java   
/**
 * Performs configuration of this controller from the given <var>attrs</var>.
 *
 * @param context      Context used to obtain values for the given attributes.
 * @param attrs        Set of attributes with values to be used to set up this controller.
 * @param defStyleAttr An attribute which contains a reference to a default style resource,for
 *                     the view attached to this controller,within a theme of the given context.
 * @param defStyleRes  Resource id of the default style for the view attached to this controller.
 * @return {@code True} if some setting of this controller has been changed,{@code false} otherwise.
 */
@SuppressWarnings("ResourceType")
public boolean setUpFromAttrs(@NonNull Context context,AttributeSet attrs,@StyleRes int defStyleRes) {
    final TypedArray typedArray = context.obtainStyledAttributes(attrs,R.styleable.Ui_PullController,defStyleRes);
    if (typedArray != null) {
        this.ensurePullHelper();
        final int n = typedArray.getIndexCount();
        for (int i = 0; i < n; i++) {
            final int index = typedArray.getIndex(i);
            if (index == R.styleable.Ui_PullController_uiPullMode) {
                setPullMode(typedArray.getInteger(index,mPullHelper.getPullMode()));
            } else if (index == R.styleable.Ui_PullController_uiPullMinVelocity) {
                setPullMinVelocity(typedArray.getFloat(index,getPullMinVelocity()));
            } else if (index == R.styleable.Ui_PullController_uiPullDistanceFraction) {
                setPullDistanceFraction(typedArray.getFloat(index,getPullDistanceFraction()));
            } else if (index == R.styleable.Ui_PullController_uiPullDistance) {
                setPullDistance(typedArray.getDimensionPixelSize(index,(int) getPullDistance()));
            } else if (index == R.styleable.Ui_PullController_uiPullCollapseDuration) {
                setPullCollapseDuration(typedArray.getInt(index,(int) mAnimations.pullCollapseDuration));
            } else if (index == R.styleable.Ui_PullController_uiPullCollapseDelay) {
                setPullCollapseDelay(typedArray.getInt(index,(int) mAnimations.pullCollapseDelay));
            }
        }
        typedArray.recycle();
        return n > 0;
    }
    return false;
}
项目:Tusky    文件:ThemeUtils.java   
public static @DrawableRes int getDrawableId(Context context,@AttrRes int attribute,@DrawableRes int fallbackDrawableId) {
    TypedValue value = new TypedValue();
    if (context.getTheme().resolveAttribute(attribute,value,true)) {
        return value.resourceId;
    } else {
        return fallbackDrawableId;
    }
}
项目:https-github.com-hyb1996-NoRootScriptDroid    文件:ScriptListWithProgressBarView.java   
public ScriptListWithProgressBarView(@NonNull Context context,defStyleAttr);
    init();
}
项目:UsuraKnob    文件:SquareFrameLayout.java   
public SquareFrameLayout(@NonNull Context context,defStyleAttr);
}
项目:HeadlineNews    文件:NewsDetailHeader.java   
public NewsDetailHeader(@NonNull Context context,defStyleAttr);

    initViews();
}
项目:AndroidDigIn    文件:TouchDelegateViewGroup.java   
public TouchDelegateViewGroup(@NonNull Context context,defStyleAttr);
}
项目:CNode-OAuth-Login-Android    文件:CNodeOAuthLoginView.java   
public CNodeOAuthLoginView(@NonNull Context context,defStyleAttr);
    init(context);
}
项目:elevator-room    文件:PersonWidget.java   
public PersonWidget(@NonNull Context context,defStyleAttr);
    init(context);
}
项目:Rxjava2.0Demo    文件:BallPulseFooter.java   
public BallPulseFooter(@NonNull Context context,defStyleAttr);
    initView(context,defStyleAttr);
}
项目:CurtainCardView    文件:CurtainCardView.java   
public CurtainCardView(@NonNull Context context,defStyleAttr);
    init(context,attrs);
}
项目:android-radiobutton-extended    文件:CompoundFrameLayout.java   
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public CompoundFrameLayout(@NonNull Context context,defStyleRes);
}
项目:ui-atoms-android    文件:AtomView.java   
public AtomView(@NonNull Context context,defStyleAttr);
}
项目:BlackList    文件:Utils.java   
/**
 * Sets the tint color of the drawable
 **/
public static void setDrawableTint(Context context,Drawable drawable,@AttrRes int colorAttrRes) {
    int colorRes = getResourceId(context,colorAttrRes);
    int color = ContextCompat.getColor(context,colorRes);
    DrawableCompat.setTint(drawable,color);
}
项目:MusicX-music-player    文件:Config.java   
@Override
public Config statusBarColorAttr(@AttrRes int colorAttr) {
    return statusBarColor(ATEUtil.resolveColor(mContext,colorAttr));
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


com.google.gson.internal.bind.ArrayTypeAdapter的实例源码
com.google.gson.JsonSyntaxException的实例源码
com.google.gson.JsonDeserializer的实例源码
com.google.gson.internal.ConstructorConstructor的实例源码
com.google.gson.JsonPrimitive的实例源码
com.google.gson.LongSerializationPolicy的实例源码
com.google.gson.internal.GsonInternalAccess的实例源码
com.google.gson.JsonIOException的实例源码
com.google.gson.internal.StringMap的实例源码
com.google.gson.JsonObject的实例源码
com.google.gson.internal.bind.TimeTypeAdapter的实例源码
com.google.gson.FieldAttributes的实例源码
com.google.gson.internal.bind.TreeTypeAdapter的实例源码
com.google.gson.internal.LinkedHashTreeMap的实例源码
com.google.gson.TypeAdapterFactory的实例源码
com.google.gson.JsonSerializer的实例源码
com.google.gson.FieldNamingPolicy的实例源码
com.google.gson.JsonElement的实例源码
com.google.gson.internal.JsonReaderInternalAccess的实例源码
com.google.gson.TypeAdapter的实例源码