List of usage examples for android.graphics Typeface create
public static Typeface create(Typeface family, @Style int style)
From source file:org.appspot.apprtc.util.ThumbnailsCacheManager.java
public static void LoadImage(final String url, LoadImageCallback callback, final Resources resources, final String displayname, final boolean rounded, boolean fromCache) { final LoadImageCallback mCallback = callback; final Handler uiHandler = new Handler(); final int FG_COLOR = 0xFFFAFAFA; final String name = displayname; if (fromCache) { Bitmap bitmap = ThumbnailsCacheManager.getBitmapFromDiskCache(url); if (bitmap != null) { if (rounded) { RoundedBitmapDrawable roundedBitmap = RoundedBitmapDrawableFactory.create(resources, bitmap); roundedBitmap.setCircular(true); mCallback.onImageLoaded(roundedBitmap.getBitmap()); } else { mCallback.onImageLoaded(bitmap); }/*from w ww . jav a 2 s .c o m*/ return; } } AsyncHttpURLConnection httpConnection = new AsyncHttpURLConnection("GET", url, "", new AsyncHttpURLConnection.AsyncHttpEvents() { @Override public void onHttpError(String errorMessage) { Log.d("LoadImage", errorMessage); } @Override public void onHttpComplete(String response) { int size = 256; Bitmap bitmap = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); final String trimmedName = name == null ? "" : name.trim(); drawTile(canvas, trimmedName, 0, 0, size, size); ThumbnailsCacheManager.addBitmapToCache(url, bitmap); onHttpComplete(bitmap); } @Override public void onHttpComplete(final Bitmap response) { if (mCallback != null) { uiHandler.post(new Runnable() { @Override public void run() { if (rounded) { RoundedBitmapDrawable roundedBitmap = RoundedBitmapDrawableFactory .create(resources, response); roundedBitmap.setCircular(true); mCallback.onImageLoaded(roundedBitmap.getBitmap()); } else { mCallback.onImageLoaded(response); } } }); } } private boolean drawTile(Canvas canvas, String letter, int tileColor, int left, int top, int right, int bottom) { letter = letter.toUpperCase(Locale.getDefault()); Paint tilePaint = new Paint(), textPaint = new Paint(); tilePaint.setColor(tileColor); textPaint.setFlags(Paint.ANTI_ALIAS_FLAG); textPaint.setColor(FG_COLOR); textPaint.setTypeface(Typeface.create("sans-serif-light", Typeface.NORMAL)); textPaint.setTextSize((float) ((right - left) * 0.8)); Rect rect = new Rect(); canvas.drawRect(new Rect(left, top, right, bottom), tilePaint); textPaint.getTextBounds(letter, 0, 1, rect); float width = textPaint.measureText(letter); canvas.drawText(letter, (right + left) / 2 - width / 2, (top + bottom) / 2 + rect.height() / 2, textPaint); return true; } private boolean drawTile(Canvas canvas, String name, int left, int top, int right, int bottom) { if (name != null) { final String letter = getFirstLetter(name); final int color = ThumbnailsCacheManager.getColorForName(name); drawTile(canvas, letter, color, left, top, right, bottom); return true; } return false; } }); httpConnection.setBitmap(); httpConnection.send(); }
From source file:io.doist.datetimepicker.time.RadialTimePickerView.java
public RadialTimePickerView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); // Pull disabled alpha from theme. final TypedValue outValue = new TypedValue(); context.getTheme().resolveAttribute(android.R.attr.disabledAlpha, outValue, true); mDisabledAlpha = (int) (outValue.getFloat() * 255 + 0.5f); // process style attributes final Resources res = getResources(); final TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.TimePicker, defStyleAttr, 0); mTypeface = Typeface.create("sans-serif", Typeface.NORMAL); // Initialize all alpha values to opaque. for (int i = 0; i < mAlpha.length; i++) { mAlpha[i] = new IntHolder(ALPHA_OPAQUE); }/*from ww w .jav a 2 s . co m*/ for (int i = 0; i < mAlphaSelector.length; i++) { for (int j = 0; j < mAlphaSelector[i].length; j++) { mAlphaSelector[i][j] = new IntHolder(ALPHA_OPAQUE); } } final int numbersTextColor = a.getColor(R.styleable.TimePicker_numbersTextColor, res.getColor(R.color.timepicker_default_text_color_material)); mPaint[HOURS] = new Paint(); mPaint[HOURS].setAntiAlias(true); mPaint[HOURS].setTextAlign(Paint.Align.CENTER); mColor[HOURS] = numbersTextColor; mPaint[MINUTES] = new Paint(); mPaint[MINUTES].setAntiAlias(true); mPaint[MINUTES].setTextAlign(Paint.Align.CENTER); mColor[MINUTES] = numbersTextColor; mPaintCenter.setColor(numbersTextColor); mPaintCenter.setAntiAlias(true); mPaintCenter.setTextAlign(Paint.Align.CENTER); mPaintSelector[HOURS][SELECTOR_CIRCLE] = new Paint(); mPaintSelector[HOURS][SELECTOR_CIRCLE].setAntiAlias(true); mColorSelector[HOURS][SELECTOR_CIRCLE] = a.getColor(R.styleable.TimePicker_numbersSelectorColor, R.color.timepicker_default_selector_color_material); mPaintSelector[HOURS][SELECTOR_DOT] = new Paint(); mPaintSelector[HOURS][SELECTOR_DOT].setAntiAlias(true); mColorSelector[HOURS][SELECTOR_DOT] = a.getColor(R.styleable.TimePicker_numbersSelectorColor, R.color.timepicker_default_selector_color_material); mPaintSelector[HOURS][SELECTOR_LINE] = new Paint(); mPaintSelector[HOURS][SELECTOR_LINE].setAntiAlias(true); mPaintSelector[HOURS][SELECTOR_LINE].setStrokeWidth(2); mColorSelector[HOURS][SELECTOR_LINE] = a.getColor(R.styleable.TimePicker_numbersSelectorColor, R.color.timepicker_default_selector_color_material); mPaintSelector[MINUTES][SELECTOR_CIRCLE] = new Paint(); mPaintSelector[MINUTES][SELECTOR_CIRCLE].setAntiAlias(true); mColorSelector[MINUTES][SELECTOR_CIRCLE] = a.getColor(R.styleable.TimePicker_numbersSelectorColor, R.color.timepicker_default_selector_color_material); mPaintSelector[MINUTES][SELECTOR_DOT] = new Paint(); mPaintSelector[MINUTES][SELECTOR_DOT].setAntiAlias(true); mColorSelector[MINUTES][SELECTOR_DOT] = a.getColor(R.styleable.TimePicker_numbersSelectorColor, R.color.timepicker_default_selector_color_material); mPaintSelector[MINUTES][SELECTOR_LINE] = new Paint(); mPaintSelector[MINUTES][SELECTOR_LINE].setAntiAlias(true); mPaintSelector[MINUTES][SELECTOR_LINE].setStrokeWidth(2); mColorSelector[MINUTES][SELECTOR_LINE] = a.getColor(R.styleable.TimePicker_numbersSelectorColor, R.color.timepicker_default_selector_color_material); mPaintBackground.setColor(a.getColor(R.styleable.TimePicker_numbersBackgroundColor, res.getColor(R.color.timepicker_default_numbers_background_color_material))); mPaintBackground.setAntiAlias(true); if (DEBUG) { mPaintDebug.setColor(DEBUG_COLOR); mPaintDebug.setAntiAlias(true); mPaintDebug.setStrokeWidth(DEBUG_STROKE_WIDTH); mPaintDebug.setStyle(Paint.Style.STROKE); mPaintDebug.setTextAlign(Paint.Align.CENTER); } mShowHours = true; mIs24HourMode = false; mAmOrPm = AM; // Set up accessibility components. mTouchHelper = new RadialPickerTouchHelper(); ViewCompat.setAccessibilityDelegate(this, mTouchHelper); if (getImportantForAccessibility() == IMPORTANT_FOR_ACCESSIBILITY_AUTO) { setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_YES); } initHoursAndMinutesText(); initData(); mTransitionMidRadiusMultiplier = Float .parseFloat(res.getString(R.string.timepicker_transition_mid_radius_multiplier)); mTransitionEndRadiusMultiplier = Float .parseFloat(res.getString(R.string.timepicker_transition_end_radius_multiplier)); mTextGridHeights[HOURS] = new float[7]; mTextGridHeights[MINUTES] = new float[7]; mSelectionRadiusMultiplier = Float .parseFloat(res.getString(R.string.timepicker_selection_radius_multiplier)); a.recycle(); setOnTouchListener(this); setClickable(true); // Initial values final Calendar calendar = Calendar.getInstance(Locale.getDefault()); final int currentHour = calendar.get(Calendar.HOUR_OF_DAY); final int currentMinute = calendar.get(Calendar.MINUTE); setCurrentHourInternal(currentHour, false, false); setCurrentMinuteInternal(currentMinute, false); setHapticFeedbackEnabled(true); }
From source file:com.appeaser.sublimepickerlibrary.timepicker.RadialTimePickerView.java
private void init(AttributeSet attrs, int defStyleAttr, int defStyleRes) { Context context = getContext(); // Pull disabled alpha from theme. final TypedValue outValue = new TypedValue(); context.getTheme().resolveAttribute(android.R.attr.disabledAlpha, outValue, true); mDisabledAlpha = outValue.getFloat(); // process style attributes final Resources res = getResources(); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RadialTimePickerView, defStyleAttr, defStyleRes);//from ww w . j a v a2 s . com mTypeface = Typeface.create("sans-serif", Typeface.NORMAL); // Initialize all alpha values to opaque. for (int i = 0; i < mAlpha.length; i++) { mAlpha[i] = new IntHolder(ALPHA_OPAQUE); } mTextColor[HOURS] = a.getColorStateList(R.styleable.RadialTimePickerView_spNumbersTextColor); mTextColor[HOURS_INNER] = a.getColorStateList(R.styleable.RadialTimePickerView_spNumbersInnerTextColor); mTextColor[MINUTES] = mTextColor[HOURS]; mPaint[HOURS] = new Paint(); mPaint[HOURS].setAntiAlias(true); mPaint[HOURS].setTextAlign(Paint.Align.CENTER); mPaint[MINUTES] = new Paint(); mPaint[MINUTES].setAntiAlias(true); mPaint[MINUTES].setTextAlign(Paint.Align.CENTER); final ColorStateList selectorColors = a .getColorStateList(R.styleable.RadialTimePickerView_spNumbersSelectorColor); int selectorActivatedColor = Color.BLACK; if (selectorColors != null) { selectorActivatedColor = selectorColors .getColorForState(SUtils.resolveStateSet(SUtils.STATE_ENABLED | SUtils.STATE_ACTIVATED), 0); } mPaintCenter.setColor(selectorActivatedColor); mPaintCenter.setAntiAlias(true); final int[] activatedStateSet = SUtils.resolveStateSet(SUtils.STATE_ENABLED | SUtils.STATE_ACTIVATED); mSelectorColor = selectorActivatedColor; mSelectorDotColor = mTextColor[HOURS].getColorForState(activatedStateSet, 0); mPaintSelector[HOURS][SELECTOR_CIRCLE] = new Paint(); mPaintSelector[HOURS][SELECTOR_CIRCLE].setAntiAlias(true); mPaintSelector[HOURS][SELECTOR_DOT] = new Paint(); mPaintSelector[HOURS][SELECTOR_DOT].setAntiAlias(true); mPaintSelector[HOURS][SELECTOR_LINE] = new Paint(); mPaintSelector[HOURS][SELECTOR_LINE].setAntiAlias(true); mPaintSelector[HOURS][SELECTOR_LINE].setStrokeWidth(2); mPaintSelector[MINUTES][SELECTOR_CIRCLE] = new Paint(); mPaintSelector[MINUTES][SELECTOR_CIRCLE].setAntiAlias(true); mPaintSelector[MINUTES][SELECTOR_DOT] = new Paint(); mPaintSelector[MINUTES][SELECTOR_DOT].setAntiAlias(true); mPaintSelector[MINUTES][SELECTOR_LINE] = new Paint(); mPaintSelector[MINUTES][SELECTOR_LINE].setAntiAlias(true); mPaintSelector[MINUTES][SELECTOR_LINE].setStrokeWidth(2); mPaintBackground.setColor(a.getColor(R.styleable.RadialTimePickerView_spNumbersBackgroundColor, ContextCompat.getColor(context, R.color.timepicker_default_numbers_background_color_material))); mPaintBackground.setAntiAlias(true); mSelectorRadius = res.getDimensionPixelSize(R.dimen.sp_timepicker_selector_radius); mSelectorStroke = res.getDimensionPixelSize(R.dimen.sp_timepicker_selector_stroke); mSelectorDotRadius = res.getDimensionPixelSize(R.dimen.sp_timepicker_selector_dot_radius); mCenterDotRadius = res.getDimensionPixelSize(R.dimen.sp_timepicker_center_dot_radius); mTextSize[HOURS] = res.getDimensionPixelSize(R.dimen.sp_timepicker_text_size_normal); mTextSize[MINUTES] = res.getDimensionPixelSize(R.dimen.sp_timepicker_text_size_normal); mTextSize[HOURS_INNER] = res.getDimensionPixelSize(R.dimen.sp_timepicker_text_size_inner); mTextInset[HOURS] = res.getDimensionPixelSize(R.dimen.sp_timepicker_text_inset_normal); mTextInset[MINUTES] = res.getDimensionPixelSize(R.dimen.sp_timepicker_text_inset_normal); mTextInset[HOURS_INNER] = res.getDimensionPixelSize(R.dimen.sp_timepicker_text_inset_inner); mShowHours = true; mIs24HourMode = false; mAmOrPm = AM; // Set up accessibility components. mTouchHelper = new RadialPickerTouchHelper(); ViewCompat.setAccessibilityDelegate(this, mTouchHelper); if (ViewCompat.getImportantForAccessibility(this) == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO) { ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); } initHoursAndMinutesText(); initData(); a.recycle(); // Initial values final Calendar calendar = Calendar.getInstance(Locale.getDefault()); final int currentHour = calendar.get(Calendar.HOUR_OF_DAY); final int currentMinute = calendar.get(Calendar.MINUTE); setCurrentHourInternal(currentHour, false, false); setCurrentMinuteInternal(currentMinute, false); setHapticFeedbackEnabled(true); }
From source file:com.layer.atlas.AtlasMessagesList.java
public void parseStyle(Context context, AttributeSet attrs, int defStyle) { TypedArray ta = context.getTheme().obtainStyledAttributes(attrs, R.styleable.AtlasMessageList, R.attr.AtlasMessageList, defStyle); this.myTextColor = ta.getColor(R.styleable.AtlasMessageList_myTextColor, context.getResources().getColor(R.color.atlas_text_black)); this.myTextStyle = ta.getInt(R.styleable.AtlasMessageList_myTextStyle, Typeface.NORMAL); String myTextTypefaceName = ta.getString(R.styleable.AtlasMessageList_myTextTypeface); this.myTextTypeface = myTextTypefaceName != null ? Typeface.create(myTextTypefaceName, myTextStyle) : null; //this.myTextSize = ta.getDimension(R.styleable.AtlasMessageList_myTextSize, context.getResources().getDimension(R.dimen.atlas_text_size_general)); this.otherTextColor = ta.getColor(R.styleable.AtlasMessageList_theirTextColor, context.getResources().getColor(R.color.atlas_text_black)); this.otherTextStyle = ta.getInt(R.styleable.AtlasMessageList_theirTextStyle, Typeface.NORMAL); String otherTextTypefaceName = ta.getString(R.styleable.AtlasMessageList_theirTextTypeface); this.otherTextTypeface = otherTextTypefaceName != null ? Typeface.create(otherTextTypefaceName, otherTextStyle) : null;//from www . j a v a 2s . co m //this.otherTextSize = ta.getDimension(R.styleable.AtlasMessageList_theirTextSize, context.getResources().getDimension(R.dimen.atlas_text_size_general)); this.myBubbleColor = ta.getColor(R.styleable.AtlasMessageList_myBubbleColor, context.getResources().getColor(R.color.atlas_bubble_blue)); this.otherBubbleColor = ta.getColor(R.styleable.AtlasMessageList_theirBubbleColor, context.getResources().getColor(R.color.atlas_background_gray)); this.dateTextColor = ta.getColor(R.styleable.AtlasMessageList_dateTextColor, context.getResources().getColor(R.color.atlas_text_gray)); this.avatarTextColor = ta.getColor(R.styleable.AtlasMessageList_avatarTextColor, context.getResources().getColor(R.color.atlas_text_black)); this.avatarBackgroundColor = ta.getColor(R.styleable.AtlasMessageList_avatarBackgroundColor, context.getResources().getColor(R.color.atlas_background_gray)); ta.recycle(); }
From source file:com.tr4android.support.extension.picker.time.RadialTimePickerView.java
public RadialTimePickerView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs); // Pull disabled alpha from theme. final TypedValue outValue = new TypedValue(); context.getTheme().resolveAttribute(android.R.attr.disabledAlpha, outValue, true); mDisabledAlpha = outValue.getFloat(); // process style attributes final Resources res = getResources(); final TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.TimePickerDialog, defStyleAttr, defStyleRes);//from ww w . j a va 2s . c om mTypeface = Typeface.create("sans-serif", Typeface.NORMAL); // Initialize all alpha values to opaque. for (int i = 0; i < mAlpha.length; i++) { mAlpha[i] = new IntHolder(ALPHA_OPAQUE); } mTextColor[HOURS] = a.getColorStateList(R.styleable.TimePickerDialog_numbersTextColor); if (mTextColor[HOURS] == null) { mTextColor[HOURS] = PickerThemeUtils.getTextColorPrimaryActivatedStateList(context); } mTextColor[HOURS_INNER] = a.getColorStateList(R.styleable.TimePickerDialog_numbersInnerTextColor); if (mTextColor[HOURS_INNER] == null) { mTextColor[HOURS_INNER] = PickerThemeUtils.getTextColorSecondaryActivatedStateList(context); } mTextColor[MINUTES] = mTextColor[HOURS]; mPaint[HOURS] = new Paint(); mPaint[HOURS].setAntiAlias(true); mPaint[HOURS].setTextAlign(Paint.Align.CENTER); mPaint[MINUTES] = new Paint(); mPaint[MINUTES].setAntiAlias(true); mPaint[MINUTES].setTextAlign(Paint.Align.CENTER); final int[] selectedStateSet = new int[] { android.R.attr.state_enabled, android.R.attr.state_selected }; // Set up number selected color, if available. final ColorStateList numbersSelectorColor; if (a.hasValue(R.styleable.TimePickerDialog_numbersSelectorColor)) { numbersSelectorColor = a.getColorStateList(R.styleable.TimePickerDialog_numbersSelectorColor); } else { final TypedArray ta = context.obtainStyledAttributes(new int[] { R.attr.colorControlActivated }); numbersSelectorColor = ta.getColorStateList(0); ta.recycle(); } final int selectorActivatedColor = numbersSelectorColor.getColorForState(selectedStateSet, 0); mPaintCenter.setColor(selectorActivatedColor); mPaintCenter.setAntiAlias(true); mSelectorColor = selectorActivatedColor; mSelectorDotColor = mTextColor[HOURS].getColorForState(selectedStateSet, 0); mPaintSelector[HOURS][SELECTOR_CIRCLE] = new Paint(); mPaintSelector[HOURS][SELECTOR_CIRCLE].setAntiAlias(true); mPaintSelector[HOURS][SELECTOR_DOT] = new Paint(); mPaintSelector[HOURS][SELECTOR_DOT].setAntiAlias(true); mPaintSelector[HOURS][SELECTOR_LINE] = new Paint(); mPaintSelector[HOURS][SELECTOR_LINE].setAntiAlias(true); mPaintSelector[HOURS][SELECTOR_LINE].setStrokeWidth(2); mPaintSelector[MINUTES][SELECTOR_CIRCLE] = new Paint(); mPaintSelector[MINUTES][SELECTOR_CIRCLE].setAntiAlias(true); mPaintSelector[MINUTES][SELECTOR_DOT] = new Paint(); mPaintSelector[MINUTES][SELECTOR_DOT].setAntiAlias(true); mPaintSelector[MINUTES][SELECTOR_LINE] = new Paint(); mPaintSelector[MINUTES][SELECTOR_LINE].setAntiAlias(true); mPaintSelector[MINUTES][SELECTOR_LINE].setStrokeWidth(2); mPaintBackground.setColor(a.getColor(R.styleable.TimePickerDialog_numbersBackgroundColor, ContextCompat.getColor(context, android.R.color.transparent))); mPaintBackground.setAntiAlias(true); mSelectorRadius = res.getDimensionPixelSize(R.dimen.timepicker_selector_radius); mSelectorStroke = res.getDimensionPixelSize(R.dimen.timepicker_selector_stroke); mSelectorDotRadius = res.getDimensionPixelSize(R.dimen.timepicker_selector_dot_radius); mCenterDotRadius = res.getDimensionPixelSize(R.dimen.timepicker_center_dot_radius); mTextSize[HOURS] = res.getDimensionPixelSize(R.dimen.timepicker_text_size_normal); mTextSize[MINUTES] = res.getDimensionPixelSize(R.dimen.timepicker_text_size_normal); mTextSize[HOURS_INNER] = res.getDimensionPixelSize(R.dimen.timepicker_text_size_inner); mTextInset[HOURS] = res.getDimensionPixelSize(R.dimen.timepicker_text_inset_normal); mTextInset[MINUTES] = res.getDimensionPixelSize(R.dimen.timepicker_text_inset_normal); mTextInset[HOURS_INNER] = res.getDimensionPixelSize(R.dimen.timepicker_text_inset_inner); mShowHours = true; mIs24HourMode = false; mAmOrPm = AM; // Set up accessibility components. mTouchHelper = new RadialPickerTouchHelper(); ViewCompat.setAccessibilityDelegate(this, mTouchHelper); if (ViewCompat.getImportantForAccessibility(this) == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO) { ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES); } initHoursAndMinutesText(); initData(); a.recycle(); // Initial values final Calendar calendar = Calendar.getInstance(Locale.getDefault()); final int currentHour = calendar.get(Calendar.HOUR_OF_DAY); final int currentMinute = calendar.get(Calendar.MINUTE); setCurrentHourInternal(currentHour, false, false); setCurrentMinuteInternal(currentMinute, false); setHapticFeedbackEnabled(true); }
From source file:com.fjoglar.etsitnoticias.view.activities.NewsListActivity.java
private void setUpSearchView(MenuItem searchMenuItem, final MenuItem filterMenuItem) { SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) searchMenuItem.getActionView(); searchView.setMaxWidth(Integer.MAX_VALUE); searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); TextView searchText = (TextView) searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text); searchText.setTypeface(Typeface.create("sans-serif-condensed", Typeface.NORMAL)); // Hide filter option when SearchView is expanded, restore it when collapsed. MenuItemCompat.setOnActionExpandListener(searchMenuItem, new MenuItemCompat.OnActionExpandListener() { @Override/* w w w . java 2 s.c om*/ public boolean onMenuItemActionExpand(MenuItem item) { filterMenuItem.setVisible(false); return true; } @Override public boolean onMenuItemActionCollapse(MenuItem item) { filterMenuItem.setVisible(true); return true; } }); }
From source file:com.mobicage.rogerthat.plugins.friends.ServiceSearchActivity.java
private TextView setCatorySelected(LinearLayout label, final boolean selected) { final View labelIndicatorView = label.findViewById(R.id.indicator); final TextView labelTextView = (TextView) label.findViewById(R.id.category); if (selected) { labelIndicatorView.setVisibility(View.VISIBLE); labelTextView.setTypeface(Typeface.create(labelTextView.getTypeface(), Typeface.BOLD)); labelTextView.setTextColor(getResources().getColor(R.color.mc_blue2)); } else {//w w w . j av a 2 s . c o m labelIndicatorView.setVisibility(View.INVISIBLE); labelTextView.setTypeface(Typeface.create(labelTextView.getTypeface(), Typeface.NORMAL)); labelTextView.setTextColor(getResources().getColor(android.R.color.secondary_text_light)); } return labelTextView; }
From source file:com.zainsoft.ramzantimetable.QiblaActivity.java
/** Called when the activity is first created. */ @Override/*from w w w . j a v a2 s . co m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_qibla_direction); // registering for listeners Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); registerListeners(); // Checking if the GPS is on or off. If it was on the default location // will be set and if its on, appropriate Context context = getApplicationContext(); perfs = PreferenceManager.getDefaultSharedPreferences(context); perfs.registerOnSharedPreferenceChangeListener(this); String gpsPerfKey = getString(R.string.gps_pref_key); TextView text1 = (TextView) findViewById(R.id.location_text_line2); TextView text2 = (TextView) findViewById(R.id.noLocationText); Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/kufi.ttf"); tf = Typeface.create(tf, Typeface.BOLD); if ("fa".equals(Locale.getDefault().getLanguage())) { text1.setTypeface(tf); text2.setTypeface(tf); } else { text1.setTypeface(Typeface.SERIF); text2.setTypeface(Typeface.SERIF); } boolean isGPS = false; /* if(hasPermission( LOC_PERMS[0] )) { checkForGPSnShowQibla(); } else { requestLocationPermission(); } */ this.qiblaImageView = (ImageView) findViewById(R.id.arrowImage); this.compassImageView = (ImageView) findViewById(R.id.compassImage); }
From source file:talex.zsw.baselibrary.widget.NavigationTabBar.java
public void setTypeface(final String typeface) { Typeface tempTypeface;/*from w w w .ja v a 2s .c o m*/ // try // { // tempTypeface = Typeface.createFromAsset(getContext().getAssets(), typeface); // } catch (Exception e) // { tempTypeface = Typeface.create(Typeface.DEFAULT, Typeface.NORMAL); // e.printStackTrace(); // } setTypeface(tempTypeface); }
From source file:org.appspot.apprtc.util.ThumbnailsCacheManager.java
public static void LoadMenuImage(final String url, MenuItem menuItem, String displayname, final boolean rounded, Resources resources, boolean fromCache) { final Resources mResources = resources; final WeakReference<MenuItem> menuItemImage = new WeakReference<MenuItem>(menuItem); final Handler uiHandler = new Handler(); final int FG_COLOR = 0xFFFAFAFA; final String name = displayname; if (fromCache) { Bitmap bitmap = ThumbnailsCacheManager.getBitmapFromDiskCache(url); if (bitmap != null) { if (rounded) { RoundedBitmapDrawable roundedBitmap = RoundedBitmapDrawableFactory.create(mResources, bitmap); roundedBitmap.setCircular(true); menuItemImage.get().setIcon(roundedBitmap); } else { menuItemImage.get().setIcon(new BitmapDrawable(bitmap)); }//w ww . j a va 2s. co m return; } } AsyncHttpURLConnection httpConnection = new AsyncHttpURLConnection("GET", url, "", new AsyncHttpURLConnection.AsyncHttpEvents() { @Override public void onHttpError(String errorMessage) { Log.d("LoadImage", errorMessage); } @Override public void onHttpComplete(String response) { int size = 96; Bitmap bitmap = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); final String trimmedName = name == null ? "" : name.trim(); drawTile(canvas, trimmedName, 0, 0, size, size); ThumbnailsCacheManager.addBitmapToCache(url, bitmap); onHttpComplete(bitmap); } @Override public void onHttpComplete(final Bitmap response) { if (menuItemImage != null && menuItemImage.get() != null) { uiHandler.post(new Runnable() { @Override public void run() { if (rounded) { RoundedBitmapDrawable roundedBitmap = RoundedBitmapDrawableFactory .create(mResources, response); roundedBitmap.setCircular(true); menuItemImage.get().setIcon(roundedBitmap); } else { menuItemImage.get().setIcon(new BitmapDrawable(response)); } } }); } } private boolean drawTile(Canvas canvas, String letter, int tileColor, int left, int top, int right, int bottom) { letter = letter.toUpperCase(Locale.getDefault()); Paint tilePaint = new Paint(), textPaint = new Paint(); tilePaint.setColor(tileColor); textPaint.setFlags(Paint.ANTI_ALIAS_FLAG); textPaint.setColor(FG_COLOR); textPaint.setTypeface(Typeface.create("sans-serif-light", Typeface.NORMAL)); textPaint.setTextSize((float) ((right - left) * 0.8)); Rect rect = new Rect(); canvas.drawRect(new Rect(left, top, right, bottom), tilePaint); textPaint.getTextBounds(letter, 0, 1, rect); float width = textPaint.measureText(letter); canvas.drawText(letter, (right + left) / 2 - width / 2, (top + bottom) / 2 + rect.height() / 2, textPaint); return true; } private boolean drawTile(Canvas canvas, String name, int left, int top, int right, int bottom) { if (name != null) { final String letter = getFirstLetter(name); final int color = ThumbnailsCacheManager.getColorForName(name); drawTile(canvas, letter, color, left, top, right, bottom); return true; } return false; } }); httpConnection.setBitmap(); httpConnection.send(); }