List of usage examples for android.content.res Resources getColor
@ColorInt @Deprecated public int getColor(@ColorRes int id) throws NotFoundException
From source file:com.google.android.apps.forscience.whistlepunk.RunReviewOverlay.java
private void init() { Resources res = getResources(); mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mPaint.setStyle(Paint.Style.FILL); mDotPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mDotPaint.setStyle(Paint.Style.FILL); mDotBackgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mDotBackgroundPaint.setColor(res.getColor(R.color.chart_margins_color)); mDotBackgroundPaint.setStyle(Paint.Style.FILL); Typeface valueTypeface = Typeface.create("sans-serif-medium", Typeface.NORMAL); Typeface timeTimeface = Typeface.create("sans-serif", Typeface.NORMAL); mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mTextPaint.setTypeface(valueTypeface); mTextPaint.setTextSize(res.getDimension(R.dimen.run_review_overlay_label_text_size)); mTextPaint.setColor(res.getColor(R.color.text_color_white)); mTimePaint = new Paint(Paint.ANTI_ALIAS_FLAG); mTimePaint.setTypeface(timeTimeface); mTimePaint.setTextSize(res.getDimension(R.dimen.run_review_overlay_label_text_size)); mTimePaint.setColor(res.getColor(R.color.text_color_white)); mCenterLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG); mCenterLinePaint.setStrokeWidth(res.getDimensionPixelSize(R.dimen.chart_grid_line_width)); mCenterLinePaint.setStyle(Paint.Style.STROKE); mCenterLinePaint.setColor(res.getColor(R.color.text_color_white)); mLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG); mLinePaint.setStrokeWidth(res.getDimensionPixelSize(R.dimen.recording_overlay_bar_width)); int dashSize = res.getDimensionPixelSize(R.dimen.run_review_overlay_dash_size); mLinePaint.setPathEffect(new DashPathEffect(new float[] { dashSize, dashSize }, dashSize)); mLinePaint.setColor(res.getColor(R.color.note_overlay_line_color)); mLinePaint.setStyle(Paint.Style.STROKE); mPath = new Path(); // TODO: Need to make sure this is at least as detailed as the SensorAppearance number // format!//from w w w.j av a 2 s . c o m mTextFormat = res.getString(R.string.run_review_chart_label_format); mTimeFormat = ElapsedTimeAxisFormatter.getInstance(getContext()); mCropBackgroundPaint = new Paint(); mCropBackgroundPaint.setStyle(Paint.Style.FILL); mCropBackgroundPaint.setColor(res.getColor(R.color.text_color_black)); mCropBackgroundPaint.setAlpha(40); mCropVerticalLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG); mCropVerticalLinePaint.setStyle(Paint.Style.STROKE); mCropVerticalLinePaint.setStrokeWidth(res.getDimensionPixelSize(R.dimen.chart_grid_line_width)); }
From source file:com.callba.phone.widget.refreshlayout.RefreshLayout.java
/** * Set the four colors used in the progress animation from color resources. * The first color will also be the color of the bar that grows in response * to a user swipe gesture./*from w w w . ja v a2 s.co m*/ */ public void setFooterColorSchemeResources(int colorRes1, int colorRes2, int colorRes3, int colorRes4) { final Resources res = getResources(); setFooterColorSchemeColors(res.getColor(colorRes1), res.getColor(colorRes2), res.getColor(colorRes3), res.getColor(colorRes4)); }
From source file:com.doomonafireball.betterpickers.radialtimepicker.RadialTimePickerDialog.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (getShowsDialog()) { getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE); }//from ww w . j av a 2 s. co m View view = inflater.inflate(R.layout.radial_time_picker_dialog, null); KeyboardListener keyboardListener = new KeyboardListener(); view.findViewById(R.id.time_picker_dialog).setOnKeyListener(keyboardListener); Resources res = getResources(); mHourPickerDescription = res.getString(R.string.hour_picker_description); mSelectHours = res.getString(R.string.select_hours); mMinutePickerDescription = res.getString(R.string.minute_picker_description); mSelectMinutes = res.getString(R.string.select_minutes); mSelectedColor = res.getColor(mThemeDark ? R.color.red : R.color.blue); mUnselectedColor = res.getColor(mThemeDark ? R.color.white : R.color.numbers_text_color); mHourView = (TextView) view.findViewById(R.id.hours); mHourView.setOnKeyListener(keyboardListener); mHourSpaceView = (TextView) view.findViewById(R.id.hour_space); mMinuteSpaceView = (TextView) view.findViewById(R.id.minutes_space); mMinuteView = (TextView) view.findViewById(R.id.minutes); mMinuteView.setOnKeyListener(keyboardListener); mAmPmTextView = (TextView) view.findViewById(R.id.ampm_label); mAmPmTextView.setOnKeyListener(keyboardListener); String[] amPmTexts = new DateFormatSymbols().getAmPmStrings(); mAmText = amPmTexts[0]; mPmText = amPmTexts[1]; mHapticFeedbackController = new HapticFeedbackController(getActivity()); mTimePicker = (RadialPickerLayout) view.findViewById(R.id.time_picker); mTimePicker.setOnValueSelectedListener(this); mTimePicker.setOnKeyListener(keyboardListener); mTimePicker.initialize(getActivity(), mHapticFeedbackController, mInitialHourOfDay, mInitialMinute, mIs24HourMode); int currentItemShowing = HOUR_INDEX; if (savedInstanceState != null && savedInstanceState.containsKey(KEY_CURRENT_ITEM_SHOWING)) { currentItemShowing = savedInstanceState.getInt(KEY_CURRENT_ITEM_SHOWING); } setCurrentItemShowing(currentItemShowing, false, true, true); mTimePicker.invalidate(); mHourView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { setCurrentItemShowing(HOUR_INDEX, true, false, true); tryVibrate(); } }); mMinuteView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { setCurrentItemShowing(MINUTE_INDEX, true, false, true); tryVibrate(); } }); mDoneButton = (TextView) view.findViewById(R.id.done_button); if (mDoneText != null) { mDoneButton.setText(mDoneText); } mDoneButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mInKbMode && isTypedTimeFullyLegal()) { finishKbMode(false); } else { tryVibrate(); } if (mCallback != null) { mCallback.onTimeSet(RadialTimePickerDialog.this, mTimePicker.getHours(), mTimePicker.getMinutes()); } dismiss(); } }); mDoneButton.setOnKeyListener(keyboardListener); // Enable or disable the AM/PM view. mAmPmHitspace = view.findViewById(R.id.ampm_hitspace); if (mIs24HourMode) { mAmPmTextView.setVisibility(View.GONE); RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); paramsSeparator.addRule(RelativeLayout.CENTER_IN_PARENT); TextView separatorView = (TextView) view.findViewById(R.id.separator); separatorView.setLayoutParams(paramsSeparator); } else { mAmPmTextView.setVisibility(View.VISIBLE); updateAmPmDisplay(mInitialHourOfDay < 12 ? AM : PM); mAmPmHitspace.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { tryVibrate(); int amOrPm = mTimePicker.getIsCurrentlyAmOrPm(); if (amOrPm == AM) { amOrPm = PM; } else if (amOrPm == PM) { amOrPm = AM; } updateAmPmDisplay(amOrPm); mTimePicker.setAmOrPm(amOrPm); } }); } mAllowAutoAdvance = true; setHour(mInitialHourOfDay, true); setMinute(mInitialMinute); // Set up for keyboard mode. mDoublePlaceholderText = res.getString(R.string.time_placeholder); mDeletedKeyFormat = res.getString(R.string.deleted_key); mPlaceholderText = mDoublePlaceholderText.charAt(0); mAmKeyCode = mPmKeyCode = -1; generateLegalTimesTree(); if (mInKbMode) { mTypedTimes = savedInstanceState.getIntegerArrayList(KEY_TYPED_TIMES); tryStartingKbMode(-1); mHourView.invalidate(); } else if (mTypedTimes == null) { mTypedTimes = new ArrayList<Integer>(); } // Set the theme at the end so that the initialize()s above don't counteract the theme. mTimePicker.setTheme(getActivity().getApplicationContext(), mThemeDark); // Prepare some colors to use. int white = res.getColor(R.color.white); int circleBackground = res.getColor(R.color.circle_background); int line = res.getColor(R.color.line_background); int timeDisplay = res.getColor(R.color.numbers_text_color); ColorStateList doneTextColor = res.getColorStateList(R.color.done_text_color); int doneBackground = R.drawable.done_background_color; int darkGray = res.getColor(R.color.dark_gray); int lightGray = res.getColor(R.color.light_gray); int darkLine = res.getColor(R.color.line_dark); ColorStateList darkDoneTextColor = res.getColorStateList(R.color.done_text_color_dark); int darkDoneBackground = R.drawable.done_background_color_dark; // Set the colors for each view based on the theme. view.findViewById(R.id.time_display_background).setBackgroundColor(mThemeDark ? darkGray : white); view.findViewById(R.id.time_display).setBackgroundColor(mThemeDark ? darkGray : white); ((TextView) view.findViewById(R.id.separator)).setTextColor(mThemeDark ? white : timeDisplay); ((TextView) view.findViewById(R.id.ampm_label)).setTextColor(mThemeDark ? white : timeDisplay); view.findViewById(R.id.line).setBackgroundColor(mThemeDark ? darkLine : line); mDoneButton.setTextColor(mThemeDark ? darkDoneTextColor : doneTextColor); mTimePicker.setBackgroundColor(mThemeDark ? lightGray : circleBackground); mDoneButton.setBackgroundResource(mThemeDark ? darkDoneBackground : doneBackground); return view; }
From source file:com.tandong.sa.vpic.UnderlinePageIndicator.java
public UnderlinePageIndicator(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); if (isInEditMode()) return;/*from w ww .j av a 2 s. c o m*/ final Resources res = getResources(); // Load defaults from resources final boolean defaultFades = res.getBoolean(getResources() .getIdentifier("default_underline_indicator_fades", "bool", context.getPackageName())); // final boolean defaultFades = res // .getBoolean(R.bool.default_underline_indicator_fades); final int defaultFadeDelay = res.getInteger(getResources() .getIdentifier("default_underline_indicator_fade_delay", "integer", context.getPackageName())); // final int defaultFadeDelay = res // .getInteger(R.integer.default_underline_indicator_fade_delay); final int defaultFadeLength = res.getInteger(getResources() .getIdentifier("default_underline_indicator_fade_length", "integer", context.getPackageName())); // final int defaultFadeLength = res // .getInteger(R.integer.default_underline_indicator_fade_length); final int defaultSelectedColor = res.getColor(getResources() .getIdentifier("default_underline_indicator_selected_color", "color", context.getPackageName())); // final int defaultSelectedColor = res // .getColor(R.color.default_underline_indicator_selected_color); // Retrieve styles attributes TypedArray a = context.obtainStyledAttributes(attrs, new int[] { getResources().getIdentifier("UnderlinePageIndicator", "styleable", context.getPackageName()) }, defStyle, 0); // TypedArray a = context.obtainStyledAttributes(attrs, // R.styleable.UnderlinePageIndicator, defStyle, 0); setFades(a.getBoolean( getResources().getIdentifier("UnderlinePageIndicator_fades", "styleable", context.getPackageName()), defaultFades)); // setFades(a.getBoolean(R.styleable.UnderlinePageIndicator_fades, // defaultFades)); setSelectedColor(a.getColor(getResources().getIdentifier("UnderlinePageIndicator_selectedColor", "styleable", context.getPackageName()), defaultSelectedColor)); // setSelectedColor(a.getColor( // R.styleable.UnderlinePageIndicator_selectedColor, // defaultSelectedColor)); setFadeDelay(a.getInteger(getResources().getIdentifier("UnderlinePageIndicator_fadeDelay", "styleable", context.getPackageName()), defaultFadeDelay)); // setFadeDelay(a.getInteger(R.styleable.UnderlinePageIndicator_fadeDelay, // defaultFadeDelay)); setFadeLength(a.getInteger(getResources().getIdentifier("UnderlinePageIndicator_fadeLength", "styleable", context.getPackageName()), defaultFadeLength)); // setFadeLength(a.getInteger( // R.styleable.UnderlinePageIndicator_fadeLength, // defaultFadeLength)); Drawable background = a.getDrawable(getResources() .getIdentifier("UnderlinePageIndicator_android_background", "styleable", context.getPackageName())); // Drawable background = a // .getDrawable(R.styleable.UnderlinePageIndicator_android_background); if (background != null) { setBackgroundDrawable(background); } a.recycle(); final ViewConfiguration configuration = ViewConfiguration.get(context); mTouchSlop = ViewConfigurationCompat.getScaledPagingTouchSlop(configuration); }
From source file:com.htc.dotdesign.ToolBoxService.java
private void updateToolBarFunIconColor() { Resources res = getResources(); Drawable bgPalette = mBtnPalette.getBackground(); Drawable bgEraser = mBtnEraser.getBackground(); Drawable bgVirtualDot = mBtnVirtualDot.getBackground(); Drawable bgMenu = mBtnMenu.getBackground(); if (mCurrPaintFun == FunType.Fun_Palette) { bgPalette.setColorFilter(res.getColor(R.color.common_category_color), Mode.SRC_ATOP); bgEraser.clearColorFilter();/*from ww w.j ava 2s . c o m*/ } else { bgPalette.clearColorFilter(); bgEraser.setColorFilter(res.getColor(R.color.common_category_color), Mode.SRC_ATOP); } if (mIsVirtualDotOpen) { bgVirtualDot.setColorFilter(res.getColor(R.color.common_category_color), Mode.SRC_ATOP); } else { bgVirtualDot.clearColorFilter(); } if (mCurrExtend == mMenu) { bgMenu.setColorFilter(res.getColor(R.color.common_category_color), Mode.SRC_ATOP); } else { bgMenu.clearColorFilter(); } }
From source file:com.example.pickerclickcar.time.TimePickerDialog.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE); View view = inflater.inflate(R.layout.time_picker_dialog, null); KeyboardListener keyboardListener = new KeyboardListener(); view.findViewById(R.id.time_picker_dialog).setOnKeyListener(keyboardListener); Resources res = getResources(); mHourPickerDescription = res.getString(R.string.hour_picker_description); mSelectHours = res.getString(R.string.select_hours); mMinutePickerDescription = res.getString(R.string.minute_picker_description); mSelectMinutes = res.getString(R.string.select_minutes); mSelectedColor = res.getColor(mThemeDark ? R.color.red : R.color.white); mUnselectedColor = res.getColor(mThemeDark ? android.R.color.white : R.color.blue_focused); mHourView = (TextView) view.findViewById(R.id.hours); mHourView.setOnKeyListener(keyboardListener); mHourSpaceView = (TextView) view.findViewById(R.id.hour_space); mMinuteSpaceView = (TextView) view.findViewById(R.id.minutes_space); mMinuteView = (TextView) view.findViewById(R.id.minutes); mMinuteView.setOnKeyListener(keyboardListener); mAmPmTextView = (TextView) view.findViewById(R.id.ampm_label); mAmPmTextView.setOnKeyListener(keyboardListener); String[] amPmTexts = new DateFormatSymbols().getAmPmStrings(); mAmText = amPmTexts[0];/* ww w . j ava 2s .c o m*/ mPmText = amPmTexts[1]; mHapticFeedbackController = new HapticFeedbackController(getActivity()); mTimePicker = (RadialPickerLayout) view.findViewById(R.id.time_picker); mTimePicker.setOnValueSelectedListener(this); mTimePicker.setOnKeyListener(keyboardListener); mTimePicker.initialize(getActivity(), mHapticFeedbackController, mInitialHourOfDay, mInitialMinute, mIs24HourMode, mMinHour, mMaxHour, mMinMinute, mMaxMinute); int currentItemShowing = HOUR_INDEX; if (savedInstanceState != null && savedInstanceState.containsKey(KEY_CURRENT_ITEM_SHOWING)) { currentItemShowing = savedInstanceState.getInt(KEY_CURRENT_ITEM_SHOWING); } setCurrentItemShowing(currentItemShowing, false, true, true); mTimePicker.invalidate(); mHourView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { setCurrentItemShowing(HOUR_INDEX, true, false, true); tryVibrate(); } }); mMinuteView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { setCurrentItemShowing(MINUTE_INDEX, true, false, true); tryVibrate(); } }); mDoneButton = (TextView) view.findViewById(R.id.done_button); mDoneButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mInKbMode && isTypedTimeFullyLegal()) { finishKbMode(false); } else { tryVibrate(); } if (mCallback != null) { mCallback.onTimeSet(mTimePicker, mTimePicker.getHours(), mTimePicker.getMinutes()); } dismiss(); } }); mCancelButton = (Button) view.findViewById(R.id.cancel_button); mCancelButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dismiss(); } }); mDoneButton.setOnKeyListener(keyboardListener); // Enable or disable the AM/PM view. mAmPmHitspace = view.findViewById(R.id.ampm_hitspace); if (mIs24HourMode) { mAmPmTextView.setVisibility(View.GONE); RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); paramsSeparator.addRule(RelativeLayout.CENTER_IN_PARENT); TextView separatorView = (TextView) view.findViewById(R.id.separator); separatorView.setLayoutParams(paramsSeparator); } else { mAmPmTextView.setVisibility(View.VISIBLE); updateAmPmDisplay(mInitialHourOfDay < 12 ? AM : PM); mAmPmHitspace.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { tryVibrate(); int amOrPm = mTimePicker.getIsCurrentlyAmOrPm(); if (amOrPm == AM) { amOrPm = PM; } else if (amOrPm == PM) { amOrPm = AM; } updateAmPmDisplay(amOrPm); mTimePicker.setAmOrPm(amOrPm); } }); } mAllowAutoAdvance = true; setHour(mInitialHourOfDay, true); setMinute(mInitialMinute); // Set up for keyboard mode. mDoublePlaceholderText = res.getString(R.string.time_placeholder); mDeletedKeyFormat = res.getString(R.string.deleted_key); mPlaceholderText = mDoublePlaceholderText.charAt(0); mAmKeyCode = mPmKeyCode = -1; generateLegalTimesTree(); if (mInKbMode) { mTypedTimes = savedInstanceState.getIntegerArrayList(KEY_TYPED_TIMES); tryStartingKbMode(-1); mHourView.invalidate(); } else if (mTypedTimes == null) { mTypedTimes = new ArrayList<Integer>(); } // Set the theme at the end so that the initialize()s above don't counteract the theme. mTimePicker.setTheme(getActivity().getApplicationContext(), mThemeDark); // Prepare some colors to use. int white = res.getColor(R.color.mainblue); int sep = res.getColor(R.color.blue_focused); int circleBackground = res.getColor(R.color.white); int line = res.getColor(R.color.mainblue); int timeDisplay = res.getColor(R.color.numbers_text_color); ColorStateList doneTextColor = res.getColorStateList(R.color.done_text_color); int doneBackground = R.drawable.done_background_color; int darkGray = res.getColor(R.color.dark_gray); int lightGray = res.getColor(R.color.circle_background); int darkLine = res.getColor(R.color.mainblue); ColorStateList darkDoneTextColor = res.getColorStateList(R.color.mainblue); int darkDoneBackground = R.drawable.done_background_color_dark; // Set the colors for each view based on the theme. view.findViewById(R.id.time_display_background).setBackgroundColor(white); view.findViewById(R.id.time_display).setBackgroundColor(mThemeDark ? darkGray : white); ((TextView) view.findViewById(R.id.separator)).setTextColor(sep); ((TextView) view.findViewById(R.id.ampm_label)).setTextColor(mThemeDark ? white : timeDisplay); view.findViewById(R.id.line).setBackgroundColor(line); mDoneButton.setTextColor(white); mTimePicker.setBackgroundColor(mThemeDark ? lightGray : circleBackground); mDoneButton.setBackgroundColor(circleBackground); mCancelButton.setBackgroundColor(circleBackground); return view; }
From source file:com.katamaditya.apps.weather4u.weathersync.Weather4USyncAdapter.java
public void notifyWeather() { Context context = getContext(); //checking the last update and notify if it' the first of the day SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); String displayNotificationsKey = context.getString(R.string.pref_enable_notifications_key); boolean displayNotifications = prefs.getBoolean(displayNotificationsKey, Boolean.parseBoolean(context.getString(R.string.pref_enable_notifications_default))); if (displayNotifications) { String lastNotificationKey = context.getString(R.string.pref_last_notification); long lastSync = prefs.getLong(lastNotificationKey, 0); if (System.currentTimeMillis() - lastSync >= getNotificationTimeGap()) { // Last sync was more than 1 day ago, let's send a notification with the weather. String locationQuery = WeatherUtil.getPreferredLocation(context); Uri weatherUri = WeatherContract.WeatherEntry.buildWeatherLocationWithDate(locationQuery, System.currentTimeMillis()); // we'll query our contentProvider, as always Cursor cursor = context.getContentResolver().query(weatherUri, NOTIFY_WEATHER_PROJECTION, null, null, null);// www .ja v a2s .c o m if (cursor.moveToFirst()) { int weatherId = cursor.getInt(INDEX_WEATHER_ID); double high = cursor.getDouble(INDEX_MAX_TEMP); double low = cursor.getDouble(INDEX_MIN_TEMP); String desc = cursor.getString(INDEX_SHORT_DESC); int iconId = WeatherUtil.getIconResourceForWeatherCondition(weatherId); Resources resources = context.getResources(); Bitmap largeIcon = BitmapFactory.decodeResource(resources, WeatherUtil.getArtResourceForWeatherCondition(weatherId)); String title = getTitle(); // Define the text of the forecast. String contentText = String.format(context.getString(R.string.format_notification), desc, WeatherUtil.formatTemperature(context, high), WeatherUtil.formatTemperature(context, low)); // NotificationCompatBuilder is a very convenient way to build backward-compatible // notifications. Just throw in some data. NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(getContext()) .setColor(resources.getColor(R.color.weather4u_light_blue)).setSmallIcon(iconId) .setLargeIcon(largeIcon).setContentTitle(title).setContentText(contentText); mBuilder.setAutoCancel(true); // Make something interesting happen when the user clicks on the notification. // In this case, opening the app is sufficient. Intent resultIntent = new Intent(context, MainActivity.class); // The stack builder object will contain an artificial back stack for the // started Activity. // This ensures that navigating backward from the Activity leads out of // your application to the Home screen. TaskStackBuilder stackBuilder = TaskStackBuilder.create(context); stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setContentIntent(resultPendingIntent); NotificationManager mNotificationManager = (NotificationManager) getContext() .getSystemService(Context.NOTIFICATION_SERVICE); // WEATHER_NOTIFICATION_ID allows you to update the notification later on. mNotificationManager.notify(WEATHER_NOTIFICATION_ID, mBuilder.build()); //refreshing last sync SharedPreferences.Editor editor = prefs.edit(); editor.putLong(lastNotificationKey, System.currentTimeMillis()); editor.commit(); } cursor.close(); } } }
From source file:com.android.mylauncher3.allapps.AllAppsGridAdapter.java
public AllAppsGridAdapter(Launcher launcher, AlphabeticalAppsList apps, View.OnTouchListener touchListener, View.OnClickListener iconClickListener, View.OnLongClickListener iconLongClickListener) { Resources res = launcher.getResources(); mLauncher = launcher;// w w w. java 2 s .c o m mApps = apps; mEmptySearchMessage = res.getString(R.string.all_apps_loading_message); mGridSizer = new GridSpanSizer(); mGridLayoutMgr = new AppsGridLayoutManager(launcher); mGridLayoutMgr.setSpanSizeLookup(mGridSizer); mItemDecoration = new GridItemDecoration(); mLayoutInflater = LayoutInflater.from(launcher); mTouchListener = touchListener; mIconClickListener = iconClickListener; mIconLongClickListener = iconLongClickListener; mSectionNamesMargin = res.getDimensionPixelSize(R.dimen.all_apps_grid_view_start_margin); mSectionHeaderOffset = res.getDimensionPixelSize(R.dimen.all_apps_grid_section_y_offset); mSectionTextPaint = new Paint(); mSectionTextPaint.setTextSize(res.getDimensionPixelSize(R.dimen.all_apps_grid_section_text_size)); mSectionTextPaint.setColor(res.getColor(R.color.all_apps_grid_section_text_color)); mSectionTextPaint.setAntiAlias(true); mPredictedAppsDividerPaint = new Paint(); mPredictedAppsDividerPaint.setStrokeWidth(Utilities.pxFromDp(1f, res.getDisplayMetrics())); mPredictedAppsDividerPaint.setColor(0x1E000000); mPredictedAppsDividerPaint.setAntiAlias(true); mPredictionBarDividerOffset = (-res.getDimensionPixelSize(R.dimen.all_apps_prediction_icon_bottom_padding) + res.getDimensionPixelSize(R.dimen.all_apps_icon_top_bottom_padding)) / 2; // Resolve the market app handling additional searches PackageManager pm = launcher.getPackageManager(); ResolveInfo marketInfo = pm.resolveActivity(createMarketSearchIntent(""), PackageManager.MATCH_DEFAULT_ONLY); if (marketInfo != null) { mMarketAppName = marketInfo.loadLabel(pm).toString(); } }
From source file:com.callba.phone.widget.refreshlayout.RefreshLayout.java
/** * Set the color resources used in the progress animation from color resources. * The first color will also be the color of the bar that grows in response * to a user swipe gesture./* ww w. j av a 2 s. c om*/ * * @param colorResIds */ public void setHeaderColorSchemeResources(int... colorResIds) { final Resources res = getResources(); int[] colorRes = new int[colorResIds.length]; for (int i = 0; i < colorResIds.length; i++) { colorRes[i] = res.getColor(colorResIds[i]); } setHeaderColorSchemeColors(colorRes); }
From source file:com.vrem.wifianalyzer.wifi.AccessPointsDetail.java
public void setView(@NonNull Resources resources, @NonNull View view, @NonNull WiFiDetail wiFiDetail, boolean child, boolean frequencyRange) { ((TextView) view.findViewById(R.id.ssid)).setText(wiFiDetail.getTitle()); TextView textIPAddress = (TextView) view.findViewById(R.id.ipAddress); TextView textLinkSpeed = (TextView) view.findViewById(R.id.linkSpeed); String ipAddress = wiFiDetail.getWiFiAdditional().getIPAddress(); if (StringUtils.isBlank(ipAddress)) { textIPAddress.setVisibility(View.GONE); textLinkSpeed.setVisibility(View.GONE); } else {//from ww w. j a v a 2 s .c om textIPAddress.setVisibility(View.VISIBLE); textIPAddress.setText(ipAddress); 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)); } } ImageView configuredImage = (ImageView) view.findViewById(R.id.configuredImage); if (wiFiDetail.getWiFiAdditional().isConfiguredNetwork()) { configuredImage.setVisibility(View.VISIBLE); configuredImage.setColorFilter(resources.getColor(R.color.connected)); } else { configuredImage.setVisibility(View.GONE); } 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()); TextView textVendor = ((TextView) view.findViewById(R.id.vendor)); String vendor = wiFiDetail.getWiFiAdditional().getVendorName(); if (StringUtils.isBlank(vendor)) { textVendor.setVisibility(View.GONE); } else { textVendor.setVisibility(View.VISIBLE); textVendor.setText(vendor); } if (child) { view.findViewById(R.id.tab).setVisibility(View.VISIBLE); } else { view.findViewById(R.id.tab).setVisibility(View.GONE); } if (frequencyRange) { view.findViewById(R.id.channel_frequency_range_row).setVisibility(View.VISIBLE); ((TextView) view.findViewById(R.id.channel_frequency_range)).setText(String.format("%d - %d %s", wiFiSignal.getFrequencyStart(), wiFiSignal.getFrequencyEnd(), WifiInfo.FREQUENCY_UNITS)); } else { view.findViewById(R.id.channel_frequency_range_row).setVisibility(View.GONE); } }