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