public void setTextTypeface(Typeface typeface) { if (this.textTypeface.equals(typeface)) { return; } this.textTypeface = typeface; invalidate(); }
if (!DEFAULT_TYPEFACE.equals(typeface)) { layoutBuilder.setTypeface(typeface); } else {
private boolean areTypefacesDifferent(Typeface first, Typeface second) { return (first != null && !first.equals(second)) || (first == null && second != null); }
@Override public String getName() { Typeface tf = this.paint.getTypeface(); tf = Typeface.create(tf, Typeface.NORMAL); if (tf.equals(Typeface.DEFAULT)) { return "Normal"; } if (tf.equals(Typeface.MONOSPACE)) { return "Monospace"; } if (tf.equals(Typeface.SANS_SERIF)) { return "Sans"; } if (tf.equals(Typeface.SERIF)) { return "Serif"; } return "Unknown"; }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || this.getClass() != o.getClass()) { return false; } TextCacheKey that = (TextCacheKey) o; return ((this.text == null) ? (that.text == null) : this.text.equals(that.text)) && ((this.textColor == null) ? (that.textColor == null) : this.textColor.equals(that.textColor)) && this.textSize == that.textSize && ((this.typeface == null) ? (that.typeface == null) : this.typeface.equals(that.typeface)) && this.enableOutline == that.enableOutline && ((this.outlineColor == null) ? (that.outlineColor == null) : this.outlineColor.equals(that.outlineColor)) && this.outlineWidth == that.outlineWidth; }
@Override public View getView(int position, View convertView, ViewGroup parent) { Views views; if (convertView == null){ convertView = inflater.inflate(R.layout.file_item,null); views = new Views(); views.imageView = (ImageView) convertView.findViewById(R.id.favorites_icon); views.textView = (TextView) convertView.findViewById(R.id.favorites_text); convertView.setTag(views); }else views = (Views)convertView.getTag(); views.textView.setText(files[position].getName()); if (tf == null) tf = views.textView.getTypeface(); if (!views.textView.getTypeface().equals(tf)) views.textView.setTypeface(tf); if (files[position].isDirectory()){ if (files[position].getName().toString().equals("LucidBrowser")) views.textView.setTypeface(null,Typeface.BOLD); views.imageView.setImageResource(R.drawable.ic_action_collection); }else{ views.imageView.setImageResource(R.drawable.ic_insert_drive_file); } return convertView; } };
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || this.getClass() != o.getClass()) { return false; } TextAttributes that = (TextAttributes) o; return this.textColor.equals(that.textColor) && this.textOffset.equals(that.textOffset) && this.textSize == that.textSize && ((this.typeface == null) ? (that.typeface == null) : this.typeface.equals(that.typeface)) && this.enableOutline == that.enableOutline && this.outlineColor.equals(that.outlineColor) && this.enableDepthTest == that.enableDepthTest && this.outlineWidth == that.outlineWidth; }
public void updatePadding() { float paddingRatio = NORMAL_FONT_PADDING_RATIO; float bottomPaddingRatio = NORMAL_FONT_BOTTOM_PADDING_RATIO; if (getPaint().getTypeface() != null && getPaint().getTypeface().equals(Typeface.DEFAULT_BOLD)) { paddingRatio = BOLD_FONT_PADDING_RATIO; bottomPaddingRatio = BOLD_FONT_BOTTOM_PADDING_RATIO; } if (getTypeface() != null && getTypeface().equals(SAN_SERIF_BOLD)) { paddingRatio = BOLD_FONT_PADDING_RATIO; bottomPaddingRatio = BOLD_FONT_BOTTOM_PADDING_RATIO; } if (getTypeface() != null && getTypeface().equals(SAN_SERIF_CONDENSED_BOLD)) { paddingRatio = BOLD_FONT_PADDING_RATIO; bottomPaddingRatio = BOLD_FONT_BOTTOM_PADDING_RATIO; } if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH && getText() != null && (getText().toString().equals(decimalSeperator) || getText().toString().equals(timeSeperator))) { bottomPaddingRatio = PRE_ICS_BOTTOM_PADDING_RATIO; } // no need to scale by display density because getTextSize() already returns the font // height in px setPadding(0, (int) (-paddingRatio * getTextSize()), mPaddingRight, (int) (-bottomPaddingRatio * getTextSize())); }