Eliminate unnecessary parameter

This commit is contained in:
Moez Bhatti
2015-11-14 18:26:51 -05:00
parent f3515e100d
commit e89309ce1f
7 changed files with 11 additions and 17 deletions
@@ -50,14 +50,14 @@ public class TextViewUtils {
if (a.hasValue(R.styleable.RobotoTextView_typeface)) {
int typefaceValue = a.getInt(R.styleable.RobotoTextView_typeface, TypefaceManager.Typefaces.ROBOTO_REGULAR);
typeface = TypefaceManager.obtainTypeface(context, typefaceValue);
typeface = TypefaceManager.obtainTypeface(typefaceValue);
}
a.recycle();
}
if (typeface == null) {
typeface = TypefaceManager.obtainTypeface(context, TypefaceManager.Typefaces.ROBOTO_REGULAR);
typeface = TypefaceManager.obtainTypeface(TypefaceManager.Typefaces.ROBOTO_REGULAR);
}
setTypeface(textView, typeface);
@@ -1,6 +1,5 @@
package com.moez.QKSMS.common;
import android.content.Context;
import android.graphics.Typeface;
import android.os.Build;
import android.util.SparseArray;
@@ -12,7 +11,7 @@ public class TypefaceManager {
private final static SparseArray<android.graphics.Typeface> mTypefaces = new SparseArray<>();
public static android.graphics.Typeface obtainTypeface(Context context, int typefaceValue) throws IllegalArgumentException {
public static android.graphics.Typeface obtainTypeface(int typefaceValue) throws IllegalArgumentException {
android.graphics.Typeface typeface = mTypefaces.get(typefaceValue);
if (typeface == null) {
typeface = createTypeface(typefaceValue);
@@ -21,12 +20,7 @@ public class TypefaceManager {
return typeface;
}
public static android.graphics.Typeface obtainTypeface(Context context, int fontFamily, int textWeight, int textStyle) throws IllegalArgumentException {
int typefaceValue = getTypefaceValue(fontFamily, textWeight, textStyle);
return obtainTypeface(context, typefaceValue);
}
private static int getTypefaceValue(int fontFamily, int textWeight, int textStyle) {
public static android.graphics.Typeface obtainTypeface(int fontFamily, int textWeight, int textStyle) throws IllegalArgumentException {
int typeface;
if (fontFamily == FontFamily.ROBOTO) {
if (textWeight == TextWeight.NORMAL) {
@@ -115,7 +109,7 @@ public class TypefaceManager {
throw new IllegalArgumentException("`textWeight` attribute value " + textWeight +
" is not supported for this font family " + fontFamily);
}
} else if (fontFamily == FontFamily.LATO) {
} else if (fontFamily == FontFamily.LATO) {
if (textWeight == TextWeight.NORMAL) {
switch (textStyle) {
case TextStyle.NORMAL:
@@ -170,7 +164,7 @@ public class TypefaceManager {
} else {
throw new IllegalArgumentException("Unknown `fontFamily` attribute value " + fontFamily);
}
return typeface;
return obtainTypeface(typeface);
}
private static Typeface createTypeface(int typefaceValue) throws IllegalArgumentException {
@@ -203,7 +203,7 @@ public class ContactHelper {
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setColor(Color.WHITE);
paint.setTypeface(TypefaceManager.obtainTypeface(context, TypefaceManager.Typefaces.ROBOTO_LIGHT));
paint.setTypeface(TypefaceManager.obtainTypeface(TypefaceManager.Typefaces.ROBOTO_LIGHT));
paint.setTextSize(length / 2);
Rect bounds = new Rect();
@@ -57,7 +57,7 @@ public class AutoCompleteContactView extends RecipientEditTextView implements Li
@Override
public void refresh() {
setTypeface(TypefaceManager.obtainTypeface(mContext, FontManager.getFontFamily(mContext),
setTypeface(TypefaceManager.obtainTypeface(FontManager.getFontFamily(mContext),
FontManager.getFontWeight(mContext, false), TypefaceManager.TextStyle.NORMAL));
setTextSize(TypedValue.COMPLEX_UNIT_SP, FontManager.getTextSize(mContext, FontManager.TEXT_TYPE_PRIMARY));
@@ -77,7 +77,7 @@ public class AvatarView extends ImageView implements View.OnClickListener, LiveV
mPaint.setTextSize(Units.dpToPx(context, 32));
mPaint.setTextAlign(Paint.Align.CENTER);
mPaint.setAntiAlias(true);
mPaint.setTypeface(TypefaceManager.obtainTypeface(context, TypefaceManager.Typefaces.ROBOTO_LIGHT));
mPaint.setTypeface(TypefaceManager.obtainTypeface(TypefaceManager.Typefaces.ROBOTO_LIGHT));
final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AvatarView, defStyle, 0);
for (int i = 0; i < a.getIndexCount(); i++) {
@@ -97,7 +97,7 @@ public class QKEditText extends android.widget.EditText implements LiveView {
// Typeface and colors
int fontFamily = FontManager.getFontFamily(mContext);
int fontWeight = FontManager.getFontWeight(mContext, false);
setTypeface(TypefaceManager.obtainTypeface(mContext, fontFamily, fontWeight,
setTypeface(TypefaceManager.obtainTypeface(fontFamily, fontWeight,
TypefaceManager.TextStyle.NORMAL));
setTextColor(ThemeManager.getTextOnBackgroundPrimary());
setHintTextColor(ThemeManager.getTextOnBackgroundSecondary());
@@ -162,7 +162,7 @@ public class QKTextView extends TextView implements LiveView {
// Typeface
int fontFamily = FontManager.getFontFamily(mContext);
int fontWeight = FontManager.getFontWeight(mContext, FontManager.getIsFontHeavy(mType));
setTypeface(TypefaceManager.obtainTypeface(mContext, fontFamily, fontWeight,
setTypeface(TypefaceManager.obtainTypeface(fontFamily, fontWeight,
TypefaceManager.TextStyle.NORMAL));
// Text size and color