List of usage examples for android.content.res Resources getColor
@ColorInt @Deprecated public int getColor(@ColorRes int id) throws NotFoundException
From source file:de.schildbach.wallet.ui.TransactionsAdapter.java
public TransactionsAdapter(final Context context, final Wallet wallet, final int maxConnectedPeers, final @Nullable OnClickListener onClickListener) { this.context = context; inflater = LayoutInflater.from(context); this.wallet = wallet; this.maxConnectedPeers = maxConnectedPeers; this.onClickListener = onClickListener; final Resources res = context.getResources(); colorBackground = res.getColor(R.color.bg_bright); colorBackgroundSelected = res.getColor(R.color.bg_panel); colorSignificant = res.getColor(R.color.fg_significant); colorLessSignificant = res.getColor(R.color.fg_less_significant); colorInsignificant = res.getColor(R.color.fg_insignificant); colorValuePositve = res.getColor(R.color.fg_value_positive); colorValueNegative = res.getColor(R.color.fg_value_negative); colorError = res.getColor(R.color.fg_error); textCoinBase = context.getString(R.string.wallet_transactions_fragment_coinbase); textInternal = context.getString(R.string.symbol_internal) + " " + context.getString(R.string.wallet_transactions_fragment_internal); textSizeNormal = res.getDimension(R.dimen.font_size_normal); setHasStableIds(true);/* w ww . j a va 2s.co m*/ }
From source file:com.bolaa.medical.view.banner.LoopCirclePageIndicator.java
public LoopCirclePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); //Load defaults from resources final Resources res = getResources(); final int defaultPageColor = res.getColor(R.color.default_circle_indicator_page_color); final int defaultFillColor = res.getColor(R.color.default_circle_indicator_fill_color); final int defaultOrientation = res.getInteger(R.integer.default_circle_indicator_orientation); final int defaultStrokeColor = res.getColor(R.color.default_circle_indicator_stroke_color); final float defaultStrokeWidth = res.getDimension(R.dimen.default_circle_indicator_stroke_width); final float defaultRadius = res.getDimension(R.dimen.default_circle_indicator_radius); final boolean defaultCentered = res.getBoolean(R.bool.default_circle_indicator_centered); final boolean defaultSnap = res.getBoolean(R.bool.default_circle_indicator_snap); //Retrieve styles attributes TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CirclePageIndicator, defStyle, R.style.Widget_CirclePageIndicator); mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centered, defaultCentered); mOrientation = a.getInt(R.styleable.CirclePageIndicator_orientation, defaultOrientation); mPaintPageFill = new Paint(Paint.ANTI_ALIAS_FLAG); mPaintPageFill.setStyle(Style.FILL); // mPaintPageFill.setStrokeWidth(3);//? mPaintPageFill.setColor(a.getColor(R.styleable.CirclePageIndicator_pageColor, defaultPageColor)); mPaintStroke = new Paint(Paint.ANTI_ALIAS_FLAG); mPaintStroke.setStyle(Style.FILL); mPaintStroke.setStyle(Style.STROKE); mPaintStroke.setColor(a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor)); mPaintStroke/* w w w .j a v a2 s. c om*/ .setStrokeWidth(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth)); mPaintFill = new Paint(Paint.ANTI_ALIAS_FLAG); mPaintFill.setStyle(Style.FILL);// mPaintFill.setColor(a.getColor(R.styleable.CirclePageIndicator_fillColor, defaultFillColor)); mRadius = a.getDimension(R.styleable.CirclePageIndicator_radius, defaultRadius); mSnap = a.getBoolean(R.styleable.CirclePageIndicator_snap, defaultSnap); a.recycle(); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); }
From source file:com.bolaa.sleepingbar.view.banner.LoopCirclePageIndicator.java
public LoopCirclePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); //Load defaults from resources final Resources res = getResources(); final int defaultPageColor = res.getColor(R.color.default_circle_indicator_page_color); final int defaultFillColor = res.getColor(R.color.default_circle_indicator_fill_color); final int defaultOrientation = res.getInteger(R.integer.default_circle_indicator_orientation); final int defaultStrokeColor = res.getColor(R.color.default_circle_indicator_stroke_color); final float defaultStrokeWidth = res.getDimension(R.dimen.default_circle_indicator_stroke_width); final float defaultRadius = res.getDimension(R.dimen.default_circle_indicator_radius); final boolean defaultCentered = res.getBoolean(R.bool.default_circle_indicator_centered); final boolean defaultSnap = res.getBoolean(R.bool.default_circle_indicator_snap); //Retrieve styles attributes TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CirclePageIndicator, defStyle, R.style.Widget_CirclePageIndicator); mCentered = a.getBoolean(R.styleable.CirclePageIndicator_centered, defaultCentered); mOrientation = a.getInt(R.styleable.CirclePageIndicator_orientation, defaultOrientation); mPaintPageFill = new Paint(Paint.ANTI_ALIAS_FLAG); mPaintPageFill.setStyle(Style.FILL); mPaintPageFill.setStrokeWidth(3);//? mPaintPageFill.setColor(a.getColor(R.styleable.CirclePageIndicator_pageColor, defaultPageColor)); mPaintStroke = new Paint(Paint.ANTI_ALIAS_FLAG); mPaintStroke.setStyle(Style.FILL); mPaintStroke.setStyle(Style.STROKE); mPaintStroke.setColor(a.getColor(R.styleable.CirclePageIndicator_strokeColor, defaultStrokeColor)); mPaintStroke/*from ww w . j a va 2 s .c om*/ .setStrokeWidth(a.getDimension(R.styleable.CirclePageIndicator_strokeWidth, defaultStrokeWidth)); mPaintFill = new Paint(Paint.ANTI_ALIAS_FLAG); mPaintFill.setStyle(Style.FILL);// mPaintFill.setColor(a.getColor(R.styleable.CirclePageIndicator_fillColor, defaultFillColor)); mRadius = a.getDimension(R.styleable.CirclePageIndicator_radius, defaultRadius); mSnap = a.getBoolean(R.styleable.CirclePageIndicator_snap, defaultSnap); a.recycle(); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); }
From source file:eu.operando.proxy.wifi.AccessPointsDetail.java
public void setView(@NonNull Resources resources, @NonNull View view, @NonNull final WiFiDetail wiFiDetail) { TextView ssidLabel = (TextView) view.findViewById(R.id.ssid); ssidLabel.setText(wiFiDetail.getTitle()); TextView textLinkSpeed = (TextView) view.findViewById(R.id.linkSpeed); String ipAddress = wiFiDetail.getWiFiAdditional().getIPAddress(); boolean isConnected = StringUtils.isNotBlank(ipAddress); if (!isConnected) { textLinkSpeed.setVisibility(View.GONE); ssidLabel.setTextColor(resources.getColor(android.R.color.white)); } else {/*from w w w.ja v a 2s . co m*/ ssidLabel.setTextColor(resources.getColor(R.color.connected)); int linkSpeed = wiFiDetail.getWiFiAdditional().getLinkSpeed(); if (linkSpeed == WiFiConnection.LINK_SPEED_INVALID) { textLinkSpeed.setVisibility(View.GONE); } else { textLinkSpeed.setVisibility(View.VISIBLE); textLinkSpeed.setText(String.format("%d%s", linkSpeed, WifiInfo.LINK_SPEED_UNITS)); } } WiFiSignal wiFiSignal = wiFiDetail.getWiFiSignal(); Strength strength = wiFiSignal.getStrength(); ImageView imageView = (ImageView) view.findViewById(R.id.levelImage); imageView.setImageResource(strength.imageResource()); imageView.setColorFilter(resources.getColor(strength.colorResource())); Security security = wiFiDetail.getSecurity(); ImageView securityImage = (ImageView) view.findViewById(R.id.securityImage); securityImage.setImageResource(security.imageResource()); securityImage.setColorFilter(resources.getColor(R.color.icons_color)); TextView textLevel = (TextView) view.findViewById(R.id.level); textLevel.setText(String.format("%ddBm", wiFiSignal.getLevel())); textLevel.setTextColor(resources.getColor(strength.colorResource())); ((TextView) view.findViewById(R.id.channel)) .setText(String.format("%d", wiFiSignal.getWiFiChannel().getChannel())); ((TextView) view.findViewById(R.id.frequency)) .setText(String.format("%d%s", wiFiSignal.getFrequency(), WifiInfo.FREQUENCY_UNITS)); ((TextView) view.findViewById(R.id.distance)).setText(String.format("%.1fm", wiFiSignal.getDistance())); ((TextView) view.findViewById(R.id.capabilities)).setText(wiFiDetail.getCapabilities()); LayoutInflater layoutInflater = mainContext.getLayoutInflater(); final WiFiApConfig wiFiApConfig = wiFiDetail.getWiFiAdditional().getWiFiApConfig(); ImageView configuredImage = (ImageView) view.findViewById(R.id.configuredImage); if (wiFiApConfig != null) { configuredImage.setVisibility(View.VISIBLE); if (isOperandoCompatible(wiFiApConfig)) { configuredImage.setColorFilter(resources.getColor(android.R.color.holo_green_light)); view.setOnClickListener( new ConfiguredClickListener(context, wiFiDetail, wiFiApConfig, isConnected)); } else { configuredImage.setColorFilter(resources.getColor(android.R.color.holo_red_light)); view.setOnClickListener(new ForgetClickListener(context, wiFiDetail)); } } else { configuredImage.setVisibility(View.GONE); view.setOnClickListener(new ConnectClickListener(context, wiFiDetail, layoutInflater)); } }
From source file:com.android.calendar.month.SimpleDayPickerFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); mContext = activity;/*from w w w.j ava 2s. c om*/ String tz = Time.getCurrentTimezone(); ViewConfiguration viewConfig = ViewConfiguration.get(activity); mMinimumFlingVelocity = viewConfig.getScaledMinimumFlingVelocity(); // Ensure we're in the correct time zone mSelectedDay.switchTimezone(tz); mSelectedDay.normalize(true); mFirstDayOfMonth.timezone = tz; mFirstDayOfMonth.normalize(true); mFirstVisibleDay.timezone = tz; mFirstVisibleDay.normalize(true); mTempTime.timezone = tz; Resources res = activity.getResources(); mSaturdayColor = res.getColor(R.color.month_saturday); mSundayColor = res.getColor(R.color.month_sunday); mFridayColor = res.getColor(R.color.month_friday); mDayNameColor = res.getColor(R.color.month_day_names_color); // Adjust sizes for screen density if (mScale == 0) { mScale = activity.getResources().getDisplayMetrics().density; if (mScale != 1) { WEEK_MIN_VISIBLE_HEIGHT *= mScale; BOTTOM_BUFFER *= mScale; LIST_TOP_OFFSET *= mScale; } } setUpAdapter(); setListAdapter(mAdapter); }
From source file:com.bitants.wally.views.swipeclearlayout.SwipeClearLayout.java
/** * Set the color for the swipe circle.// w ww. j a va 2 s. c o m * @param colorResId Color resource. */ public void setCircleColorResourceId(int colorResId) { ensureTarget(); final Resources resources = getResources(); circleColor = resources.getColor(colorResId); ((GradientDrawable) circle.getBackground()).setColor(circleColor); }
From source file:com.taobao.luaview.view.indicator.circle.CirclePageIndicator.java
public CirclePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;/*from w w w .jav a 2 s. c om*/ //Load defaults from resources final Resources res = getResources(); final int defaultPageColor = res.getColor(R.color.lv_default_circle_indicator_page_color); final int defaultFillColor = res.getColor(R.color.lv_default_circle_indicator_fill_color); final int defaultOrientation = res.getInteger(R.integer.lv_default_circle_indicator_orientation); final int defaultStrokeColor = res.getColor(R.color.lv_default_circle_indicator_stroke_color); final float defaultStrokeWidth = res.getDimension(R.dimen.lv_default_circle_indicator_stroke_width); final float defaultRadius = res.getDimension(R.dimen.lv_default_circle_indicator_radius); final boolean defaultCentered = res.getBoolean(R.bool.lv_default_circle_indicator_centered); final boolean defaultSnap = res.getBoolean(R.bool.lv_default_circle_indicator_snap); //Retrieve styles attributes TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LVCirclePageIndicator, defStyle, 0); mCentered = a.getBoolean(R.styleable.LVCirclePageIndicator_lv_centered1, defaultCentered); mOrientation = a.getInt(R.styleable.LVCirclePageIndicator_android_orientation, defaultOrientation); mPaintPageFill.setStyle(Style.FILL); mPaintPageFill.setColor(a.getColor(R.styleable.LVCirclePageIndicator_lv_pageColor, defaultPageColor)); mPaintStroke.setStyle(Style.STROKE); mPaintStroke.setColor(a.getColor(R.styleable.LVCirclePageIndicator_lv_strokeColor, defaultStrokeColor)); mPaintStroke.setStrokeWidth( a.getDimension(R.styleable.LVCirclePageIndicator_lv_strokeWidth, defaultStrokeWidth)); mPaintFill.setStyle(Style.FILL); mPaintFill.setColor(a.getColor(R.styleable.LVCirclePageIndicator_lv_fillColor, defaultFillColor)); mRadius = a.getDimension(R.styleable.LVCirclePageIndicator_lv_radius1, defaultRadius); mSnap = a.getBoolean(R.styleable.LVCirclePageIndicator_lv_snap, defaultSnap); Drawable background = a.getDrawable(R.styleable.LVCirclePageIndicator_android_background); if (background != null) { setBackgroundDrawable(background); } a.recycle(); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); }
From source file:com.kadavelil.jossy.mapalarm.SeekArc.java
private void init(Context context, AttributeSet attrs, int defStyle) { Log.d(TAG, "Initialising SeekArc"); final Resources res = getResources(); float density = context.getResources().getDisplayMetrics().density; // Defaults, may need to link this into theme settings int arcColor = res.getColor(R.color.progress_gray); int progressColor = res.getColor(R.color.accent_700); int thumbHalfheight = 0; int thumbHalfWidth = 0; mThumb = ContextCompat.getDrawable(context, R.drawable.seek_arc_control_selector); // Convert progress width to pixels for current density mProgressWidth = (int) (mProgressWidth * density); if (attrs != null) { // Attribute initialization final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SeekArc, defStyle, 0); Drawable thumb = a.getDrawable(R.styleable.SeekArc_thumb); if (thumb != null) { mThumb = thumb;/*w ww .j av a2 s. co m*/ } thumbHalfheight = (int) mThumb.getIntrinsicHeight() / 2; thumbHalfWidth = (int) mThumb.getIntrinsicWidth() / 2; mThumb.setBounds(-thumbHalfWidth, -thumbHalfheight, thumbHalfWidth, thumbHalfheight); mMax = a.getInteger(R.styleable.SeekArc_max, mMax); mProgress = a.getInteger(R.styleable.SeekArc_progress, mProgress); mProgressWidth = (int) a.getDimension(R.styleable.SeekArc_progressWidth, mProgressWidth); mArcWidth = (int) a.getDimension(R.styleable.SeekArc_arcWidth, mArcWidth); mStartAngle = a.getInt(R.styleable.SeekArc_startAngle, mStartAngle); mSweepAngle = a.getInt(R.styleable.SeekArc_sweepAngle, mSweepAngle); mRotation = a.getInt(R.styleable.SeekArc_rotation, mRotation); mRoundedEdges = a.getBoolean(R.styleable.SeekArc_roundEdges, mRoundedEdges); mTouchInside = a.getBoolean(R.styleable.SeekArc_touchInside, mTouchInside); mClockwise = a.getBoolean(R.styleable.SeekArc_clockwise, mClockwise); arcColor = a.getColor(R.styleable.SeekArc_arcColor, arcColor); progressColor = a.getColor(R.styleable.SeekArc_progressColor, progressColor); a.recycle(); } mProgress = (mProgress > mMax) ? mMax : mProgress; mProgress = (mProgress < 0) ? 0 : mProgress; mSweepAngle = (mSweepAngle > 360) ? 360 : mSweepAngle; mSweepAngle = (mSweepAngle < 0) ? 0 : mSweepAngle; mStartAngle = (mStartAngle > 360) ? 0 : mStartAngle; mStartAngle = (mStartAngle < 0) ? 0 : mStartAngle; mArcPaint = new Paint(); mArcPaint.setColor(arcColor); mArcPaint.setAntiAlias(true); mArcPaint.setStyle(Paint.Style.STROKE); mArcPaint.setStrokeWidth(mArcWidth); //mArcPaint.setAlpha(45); mProgressPaint = new Paint(); mProgressPaint.setColor(progressColor); mProgressPaint.setAntiAlias(true); mProgressPaint.setStyle(Paint.Style.STROKE); mProgressPaint.setStrokeWidth(mProgressWidth); if (mRoundedEdges) { mArcPaint.setStrokeCap(Paint.Cap.ROUND); mProgressPaint.setStrokeCap(Paint.Cap.ROUND); } }
From source file:com.google.android.apps.iosched.ui.tablet.TracksDropdownFragment.java
public void loadTrack(Cursor cursor, boolean loadTargetFragment) { final String trackId; final int trackColor; final Resources res = getResources(); if (cursor != null) { trackColor = cursor.getInt(TracksAdapter.TracksQuery.TRACK_COLOR); trackId = cursor.getString(TracksAdapter.TracksQuery.TRACK_ID); mTitle.setText(cursor.getString(TracksAdapter.TracksQuery.TRACK_NAME)); mAbstract.setText(cursor.getString(TracksAdapter.TracksQuery.TRACK_ABSTRACT)); } else {//from www .j av a 2s. c o m trackColor = res.getColor(R.color.all_track_color); trackId = ScheduleContract.Tracks.ALL_TRACK_ID; mTitle.setText(TracksFragment.NEXT_TYPE_SESSIONS.equals(mNextType) ? R.string.all_sessions_title : R.string.all_sandbox_title); mAbstract.setText(TracksFragment.NEXT_TYPE_SESSIONS.equals(mNextType) ? R.string.all_sessions_subtitle : R.string.all_sandbox_subtitle); } boolean isDark = UIUtils.isColorDark(trackColor); mRootView.setBackgroundColor(trackColor); if (isDark) { mTitle.setTextColor(res.getColor(R.color.body_text_1_inverse)); mAbstract.setTextColor(res.getColor(R.color.body_text_2_inverse)); mRootView.findViewById(R.id.track_dropdown_arrow) .setBackgroundResource(R.drawable.track_dropdown_arrow_light); } else { mTitle.setTextColor(res.getColor(R.color.body_text_1)); mAbstract.setTextColor(res.getColor(R.color.body_text_2)); mRootView.findViewById(R.id.track_dropdown_arrow) .setBackgroundResource(R.drawable.track_dropdown_arrow_dark); } if (loadTargetFragment) { final Intent intent = new Intent(Intent.ACTION_VIEW); final Uri trackUri = ScheduleContract.Tracks.buildTrackUri(trackId); intent.putExtra(SessionDetailFragment.EXTRA_TRACK, trackUri); if (NEXT_TYPE_SESSIONS.equals(mNextType)) { if (cursor == null) { intent.setData(ScheduleContract.Sessions.CONTENT_URI); } else { intent.setData(ScheduleContract.Tracks.buildSessionsUri(trackId)); } } else if (NEXT_TYPE_VENDORS.equals(mNextType)) { if (cursor == null) { intent.setData(ScheduleContract.Vendors.CONTENT_URI); } else { intent.setData(ScheduleContract.Tracks.buildVendorsUri(trackId)); } } ((BaseActivity) getActivity()).openActivityOrFragment(intent); } }
From source file:com.heneryh.aquanotes.ui.tablet.TracksDropdownFragment.java
public void loadTrack(Cursor cursor, boolean loadTargetFragment) { final String trackId; final int trackColor; final Resources res = getResources(); if (cursor != null) { trackColor = cursor.getInt(TracksAdapter.TracksQuery.TRACK_COLOR); trackId = cursor.getString(TracksAdapter.TracksQuery.TRACK_ID); mTitle.setText(cursor.getString(TracksAdapter.TracksQuery.TRACK_NAME)); mAbstract.setText(cursor.getString(TracksAdapter.TracksQuery.TRACK_ABSTRACT)); } else {//from w w w . j a v a2s. com trackColor = res.getColor(R.color.all_track_color); trackId = AquaNotesDbContract.Tracks.ALL_TRACK_ID; mTitle.setText(TracksFragment.NEXT_TYPE_SESSIONS.equals(mNextType) ? R.string.all_sessions_title : R.string.all_sandbox_title); mAbstract.setText(TracksFragment.NEXT_TYPE_SESSIONS.equals(mNextType) ? R.string.all_sessions_subtitle : R.string.all_sandbox_subtitle); } boolean isDark = UIUtils.isColorDark(trackColor); mRootView.setBackgroundColor(trackColor); if (isDark) { mTitle.setTextColor(res.getColor(R.color.body_text_1_inverse)); mAbstract.setTextColor(res.getColor(R.color.body_text_2_inverse)); mRootView.findViewById(R.id.track_dropdown_arrow) .setBackgroundResource(R.drawable.track_dropdown_arrow_light); } else { mTitle.setTextColor(res.getColor(R.color.body_text_1)); mAbstract.setTextColor(res.getColor(R.color.body_text_2)); mRootView.findViewById(R.id.track_dropdown_arrow) .setBackgroundResource(R.drawable.track_dropdown_arrow_dark); } if (loadTargetFragment) { final Intent intent = new Intent(Intent.ACTION_VIEW); final Uri trackUri = AquaNotesDbContract.Tracks.buildTrackUri(trackId); intent.putExtra(SessionDetailFragment.EXTRA_TRACK, trackUri); if (NEXT_TYPE_SESSIONS.equals(mNextType)) { if (cursor == null) { intent.setData(AquaNotesDbContract.Sessions.CONTENT_URI); } else { intent.setData(AquaNotesDbContract.Tracks.buildSessionsUri(trackId)); } } else if (NEXT_TYPE_VENDORS.equals(mNextType)) { if (cursor == null) { intent.setData(AquaNotesDbContract.Vendors.CONTENT_URI); } else { intent.setData(AquaNotesDbContract.Tracks.buildVendorsUri(trackId)); } } ((BaseActivity) getActivity()).openActivityOrFragment(intent); } }