Example usage for android.content.res Resources getColor

List of usage examples for android.content.res Resources getColor

Introduction

In this page you can find the example usage for android.content.res Resources getColor.

Prototype

@ColorInt
@Deprecated
public int getColor(@ColorRes int id) throws NotFoundException 

Source Link

Document

Returns a color integer associated with a particular resource ID.

Usage

From source file:de.avpptr.umweltzone.map.MapFragment.java

private void drawPolygonOverlay() {
    Activity activity = getActivity();//from ww  w  .  jav  a2 s.  c  o m
    String cityName = mPreferencesHelper.restoreLastKnownLocationAsString();
    if (cityName == null || cityName.length() < 1) {
        return;
    }
    @SuppressWarnings("unchecked")
    List<Circuit> circuits = ContentProvider.getCircuits(activity, cityName);
    Resources resources = getResources();
    int fillColor = resources.getColor(R.color.shape_fill_color);
    int strokeColor = resources.getColor(R.color.shape_stroke_color);
    int strokeWidth = resources.getInteger(R.integer.shape_stroke_width);
    mMapDrawer.drawPolygons(circuits, fillColor, strokeColor, strokeWidth);
}

From source file:de.vanita5.twittnuker.util.ThemeUtils.java

public static int getThemeColor(Context context, int themeResourceId) {
    final Context appContext = context.getApplicationContext();
    final Resources res = appContext.getResources();
    final TypedArray a = appContext.obtainStyledAttributes(null,
            new int[] { android.R.attr.colorActivatedHighlight }, 0, themeResourceId);
    try {//from w w w .j av  a 2s.  c om
        return a.getColor(0, res.getColor(R.color.material_light_blue));
    } finally {
        a.recycle();
    }
}

From source file:com.github.segoh.viewpagerindicator.ViewPagerIndicator.java

public ViewPagerIndicator(final Context context, final AttributeSet attrs, final int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    if (isInEditMode()) {
        return;//from w  ww  . j  av a 2s.  c  o  m
    }
    final Resources res = getResources();
    final int defaultCurrentPageColor = res.getColor(R.color.vpi__current_page);
    final int defaultPageColor = res.getColor(R.color.vpi__page);
    final float defaultRadius = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4,
            res.getDisplayMetrics());
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ViewPagerIndicator, defStyleAttr, 0);
    if (a != null) {
        mPaintPage.setStyle(Paint.Style.FILL);
        mPaintPage.setColor(a.getColor(R.styleable.ViewPagerIndicator_pageColor, defaultPageColor));
        mPaintCurrentPage.setStyle(Paint.Style.FILL);
        mPaintCurrentPage
                .setColor(a.getColor(R.styleable.ViewPagerIndicator_currentPageColor, defaultCurrentPageColor));
        mRadius = a.getDimension(R.styleable.ViewPagerIndicator_radius, defaultRadius);
        Drawable background = a.getDrawable(R.styleable.ViewPagerIndicator_android_background);
        setBackgroundDrawable(background);
        a.recycle();
    }
}

From source file:de.vanita5.twittnuker.util.ThemeUtils.java

public static int getThemeColor(final Context context) {
    final Resources res = getResources(context);
    final Context wrapped = getThemedContext(context, res);
    final TypedArray a = wrapped.obtainStyledAttributes(new int[] { android.R.attr.colorActivatedHighlight });
    try {/*from www  .j a  va  2s  .  c o m*/
        return a.getColor(0, res.getColor(R.color.material_light_blue));
    } finally {
        a.recycle();
    }
}

From source file:com.android.mail.browse.SubjectAndFolderView.java

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

    final Resources res = getResources();
    mNoFolderChipName = res.getString(R.string.add_label);
    mNoFolderBgColor = res.getColor(R.color.conv_header_add_label_background);
    mNoFolderFgColor = res.getColor(R.color.conv_header_add_label_text);
    mImportanceMarkerDrawable = res.getDrawable(R.drawable.ic_email_caret_none_important_unread);
    mImportanceMarkerDrawable.setBounds(0, 0, mImportanceMarkerDrawable.getIntrinsicWidth(),
            mImportanceMarkerDrawable.getIntrinsicHeight());
    mChipVerticalOffset = res.getDimensionPixelOffset(R.dimen.folder_cv_vertical_offset);

    mVisibleFolders = false;/*  w  w w  .ja  v  a  2  s  . c o m*/
    mFolderDisplayer = new ConversationFolderDisplayer(getContext());
}

From source file:codingpractice.renard314.com.products.ProductGridAdapter.java

public ProductGridAdapter(LayoutInflater layoutInflater, Collection<Product> products) {
    mProducts.addAll(products);//from   w w w .  ja  va2s .c o  m
    final Resources resources = layoutInflater.getContext().getResources();
    mDefaultBackgroundColor = resources.getColor(R.color.colorAccent);
    mDefaultTextColor = resources.getColor(R.color.primary_text_default_material_dark);
    this.mLayoutInflater = layoutInflater;
}

From source file:com.dimelo.sampleapp.google.IconSlidingTabLayout.java

private void updateIcon(ImageView iconImageView, int position) {
    if (mViewPager == null) {
        return;/* w  w w .j a  v  a2  s .  c  o  m*/
    }
    int icon_id;
    ViewPagerIconAndTextAdapter adapter = (ViewPagerIconAndTextAdapter) mViewPager.getAdapter();
    if (position == mViewPager.getCurrentItem()) {
        icon_id = adapter.getSelectedPageIconId(position);
    } else {
        icon_id = adapter.getPageIconId(position);
    }
    Resources resources = getContext().getResources();
    Drawable icon = DrawableCompat.wrap(resources.getDrawable(icon_id));
    DrawableCompat.setTint(icon, resources.getColor(R.color.accent));
    iconImageView.setImageDrawable(icon);
}

From source file:com.android.mail.ui.FolderDisplayer.java

protected void initializeDrawableResources() {
    // Set default values used across all folder chips
    final Resources res = mContext.getResources();
    mFolderDrawableResources.defaultFgColor = res.getColor(R.color.default_folder_foreground_color);
    mFolderDrawableResources.defaultBgColor = res.getColor(R.color.default_folder_background_color);
    mFolderDrawableResources.folderRoundedCornerRadius = res
            .getDimensionPixelOffset(R.dimen.folder_rounded_corner_radius);
    mFolderDrawableResources.folderInBetweenPadding = res.getDimensionPixelOffset(R.dimen.folder_start_padding);
}

From source file:com.polatic.pantaudki.home.IncomeFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View v = inflater.inflate(R.layout.home_fragment_income, container, false);
    final Resources resources = getResources();
    ArrayList<Bar> aBars = new ArrayList<Bar>();

    Bar bar = new Bar();
    bar.setColor(resources.getColor(R.color.green_light));
    bar.setSelectedColor(resources.getColor(R.color.transparent_orange));
    bar.setName("Pajak Daerah");
    bar.setValue(32500000);//from ww  w.j av a2 s.  c om
    bar.setValueString("32,500 Milyar");
    aBars.add(bar);

    bar = new Bar();
    bar.setColor(resources.getColor(R.color.purple));
    bar.setName("Retribusi");
    bar.setValue(1746418);
    bar.setValueString("1,746 Milyar");
    aBars.add(bar);

    bar = new Bar();
    bar.setColor(resources.getColor(R.color.red));
    bar.setName("Pengelolaan");
    bar.setValue(447550);
    bar.setValueString("447 Milyar");
    aBars.add(bar);

    bar = new Bar();
    bar.setColor(resources.getColor(R.color.main_red));
    bar.setName("Lain-Lain");
    bar.setValue(4850246);
    bar.setValueString("4,850 Milyar");
    aBars.add(bar);

    BarGraph barGraph = (BarGraph) v.findViewById(R.id.first_bargraph);
    barGraph.setBars(aBars);

    barGraph.setOnBarClickedListener(new OnBarClickedListener() {

        @Override
        public void onClick(int index) {
            Toast.makeText(getActivity(), "Bar " + index + " clicked", Toast.LENGTH_SHORT).show();
        }
    });

    aBars = new ArrayList<Bar>();

    bar = new Bar();
    bar.setColor(resources.getColor(R.color.main_blue));
    bar.setSelectedColor(resources.getColor(R.color.transparent_orange));
    bar.setName("Dana Hasil");
    bar.setValue(17684);
    bar.setValueString("17,684 Milyar");
    aBars.add(bar);

    bar = new Bar();
    bar.setColor(resources.getColor(R.color.main_red));
    bar.setName("Dana Alokasi Umum");
    bar.setValue(86);
    bar.setValueString("86 Milyar");
    aBars.add(bar);

    barGraph = (BarGraph) v.findViewById(R.id.second_bargraph);
    barGraph.setBars(aBars);

    aBars = new ArrayList<Bar>();

    bar = new Bar();
    bar.setColor(resources.getColor(R.color.main_blue_light));
    bar.setSelectedColor(resources.getColor(R.color.transparent_orange));
    bar.setName("Pendapatan Hibah");
    bar.setValue(5000);
    bar.setValueString("5,000 Milyar");
    aBars.add(bar);

    bar = new Bar();
    bar.setColor(resources.getColor(R.color.red_light));
    bar.setName("Penyesuaian dan Otonomi");
    bar.setValue(2386);
    bar.setValueString("2,386 Milyar");
    aBars.add(bar);

    barGraph = (BarGraph) v.findViewById(R.id.third_bargraph);
    barGraph.setBars(aBars);

    return v;
}

From source file:com.ben.gank.fragment.WebFragment.java

protected void initView() {
    mToolbar.setSubtitle(mTitle);/*  w w  w.ja  v a 2 s.  c o m*/
    mToolbar.setTitle("");
    AppCompatActivity activity = (AppCompatActivity) getActivity();
    activity.setSupportActionBar(mToolbar);
    activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    Resources resources = getResources();
    mSwipeRefreshLayout.setColorSchemeColors(resources.getColor(R.color.blue_dark),
            resources.getColor(R.color.red_dark), resources.getColor(R.color.yellow_dark),
            resources.getColor(R.color.green_dark)

    );
    mSwipeRefreshLayout.setOnRefreshListener(this);
}